@@ -10,6 +10,11 begin | |||||
10 |
|
10 | |||
11 | REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/mercurial_repository' |
|
11 | REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/mercurial_repository' | |
12 |
|
12 | |||
|
13 | if File.directory?(REPOSITORY_PATH) | |||
|
14 | def setup | |||
|
15 | @adapter = Redmine::Scm::Adapters::MercurialAdapter.new(REPOSITORY_PATH) | |||
|
16 | end | |||
|
17 | ||||
13 | def test_hgversion |
|
18 | def test_hgversion | |
14 | to_test = { "Mercurial Distributed SCM (version 0.9.5)\n" => [0,9,5], |
|
19 | to_test = { "Mercurial Distributed SCM (version 0.9.5)\n" => [0,9,5], | |
15 | "Mercurial Distributed SCM (1.0)\n" => [1,0], |
|
20 | "Mercurial Distributed SCM (1.0)\n" => [1,0], | |
@@ -37,18 +42,26 begin | |||||
37 | end |
|
42 | end | |
38 | end |
|
43 | end | |
39 |
|
44 | |||
|
45 | def test_cat | |||
|
46 | assert @adapter.cat("sources/welcome_controller.rb", 2) | |||
|
47 | assert_nil @adapter.cat("sources/welcome_controller.rb") | |||
|
48 | end | |||
|
49 | ||||
40 | private |
|
50 | private | |
41 |
|
51 | |||
42 | def test_hgversion_for(hgversion, version) |
|
52 | def test_hgversion_for(hgversion, version) | |
43 |
|
|
53 | @adapter.class.expects(:hgversion_from_command_line).returns(hgversion) | |
44 | adapter = Redmine::Scm::Adapters::MercurialAdapter |
|
54 | assert_equal version, @adapter.class.hgversion | |
45 | assert_equal version, adapter.hgversion |
|
|||
46 | end |
|
55 | end | |
47 |
|
56 | |||
48 | def test_template_path_for(version, template) |
|
57 | def test_template_path_for(version, template) | |
49 | adapter = Redmine::Scm::Adapters::MercurialAdapter |
|
58 | assert_equal "#{TEMPLATES_DIR}/#{TEMPLATE_NAME}-#{template}.#{TEMPLATE_EXTENSION}", | |
50 | assert_equal "#{TEMPLATES_DIR}/#{TEMPLATE_NAME}-#{template}.#{TEMPLATE_EXTENSION}", adapter.template_path_for(version) |
|
59 | @adapter.class.template_path_for(version) | |
51 | assert File.exist?(adapter.template_path_for(version)) |
|
60 | assert File.exist?(@adapter.class.template_path_for(version)) | |
|
61 | end | |||
|
62 | else | |||
|
63 | puts "Mercurial test repository NOT FOUND. Skipping unit tests !!!" | |||
|
64 | def test_fake; assert true end | |||
52 | end |
|
65 | end | |
53 | end |
|
66 | end | |
54 |
|
67 |
@@ -55,18 +55,11 class RepositoryMercurialTest < ActiveSupport::TestCase | |||||
55 | end |
|
55 | end | |
56 |
|
56 | |||
57 | def test_locate_on_outdated_repository |
|
57 | def test_locate_on_outdated_repository | |
58 | # Change the working dir state |
|
|||
59 | %x{hg -R #{REPOSITORY_PATH} up -r 0} |
|
|||
60 | assert_equal 1, @repository.entries("images", 0).size |
|
58 | assert_equal 1, @repository.entries("images", 0).size | |
61 | assert_equal 2, @repository.entries("images").size |
|
59 | assert_equal 2, @repository.entries("images").size | |
62 | assert_equal 2, @repository.entries("images", 2).size |
|
60 | assert_equal 2, @repository.entries("images", 2).size | |
63 | end |
|
61 | end | |
64 |
|
62 | |||
65 | def test_cat |
|
|||
66 | assert @repository.scm.cat("sources/welcome_controller.rb", 2) |
|
|||
67 | assert_nil @repository.scm.cat("sources/welcome_controller.rb") |
|
|||
68 | end |
|
|||
69 |
|
||||
70 | def test_isodatesec |
|
63 | def test_isodatesec | |
71 | # Template keyword 'isodatesec' supported in Mercurial 1.0 and higher |
|
64 | # Template keyword 'isodatesec' supported in Mercurial 1.0 and higher | |
72 | if @repository.scm.class.client_version_above?([1, 0]) |
|
65 | if @repository.scm.class.client_version_above?([1, 0]) |
General Comments 0
You need to be logged in to leave comments.
Login now