comparison test/unit/lib/redmine/scm/adapters/bazaar_adapter_test.rb @ 245:051f544170fe

* Update to SVN trunk revision 4993
author Chris Cannam
date Thu, 03 Mar 2011 11:42:28 +0000
parents
children cbce1fd3b1b7
comparison
equal deleted inserted replaced
244:8972b600f4fb 245:051f544170fe
1 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 if File.directory?(REPOSITORY_PATH)
11 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
29 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
49 rescue LoadError
50 class BazaarMochaFake < ActiveSupport::TestCase
51 def test_fake; assert(false, "Requires mocha to run those tests") end
52 end
53 end
54