To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Tag: | Revision:

root / test / unit / lib / redmine / scm / adapters / bazaar_adapter_test.rb @ 442:753f1380d6bc

History | View | Annotate | Download (1.71 KB)

1 245:051f544170fe Chris
require File.expand_path('../../../../../../test_helper', __FILE__)
2
begin
3
  require 'mocha'
4
5
  class BazaarAdapterTest < ActiveSupport::TestCase
6
7
    REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/bazaar_repository'
8
    REPOSITORY_PATH.gsub!(/\/+/, '/')
9
10 441:cbce1fd3b1b7 Chris
    if File.directory?(REPOSITORY_PATH)
11 245:051f544170fe Chris
      def setup
12
        @adapter = Redmine::Scm::Adapters::BazaarAdapter.new(REPOSITORY_PATH)
13
      end
14
15
      def test_scm_version
16
        to_test = { "Bazaar (bzr) 2.1.2\n"             => [2,1,2],
17
                    "2.1.1\n1.7\n1.8"                  => [2,1,1],
18
                    "2.0.1\r\n1.8.1\r\n1.9.1"          => [2,0,1]}
19
        to_test.each do |s, v|
20
          test_scm_version_for(s, v)
21
        end
22
      end
23
24
      def test_cat
25
        cat = @adapter.cat('directory/document.txt')
26
        assert cat =~ /Write the contents of a file as of a given revision to standard output/
27
      end
28 441:cbce1fd3b1b7 Chris
29 245:051f544170fe Chris
      def test_annotate
30
        annotate = @adapter.annotate('doc-mkdir.txt')
31
        assert_equal 17, annotate.lines.size
32
        assert_equal '1', annotate.revisions[0].identifier
33
        assert_equal 'jsmith@', annotate.revisions[0].author
34
        assert_equal 'mkdir', annotate.lines[0]
35
      end
36
37
      private
38
39
      def test_scm_version_for(scm_command_version, version)
40
        @adapter.class.expects(:scm_version_from_command_line).returns(scm_command_version)
41
        assert_equal version, @adapter.class.scm_command_version
42
      end
43
    else
44
      puts "Bazaar test repository NOT FOUND. Skipping unit tests !!!"
45
      def test_fake; assert true end
46
    end
47
  end
48
rescue LoadError
49
  class BazaarMochaFake < ActiveSupport::TestCase
50
    def test_fake; assert(false, "Requires mocha to run those tests")  end
51
  end
52
end