|
1 |
|
1 |
2 |
require File.dirname(__FILE__) + '/../../../../../test_helper'
|
2 |
3 |
begin
|
3 |
4 |
require 'mocha'
|
... | ... | |
9 |
10 |
TEMPLATE_EXTENSION = Redmine::Scm::Adapters::MercurialAdapter::TEMPLATE_EXTENSION
|
10 |
11 |
|
11 |
12 |
REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/mercurial_repository'
|
|
13 |
|
|
14 |
def setup
|
|
15 |
@adapter = Redmine::Scm::Adapters::MercurialAdapter
|
|
16 |
end
|
12 |
17 |
|
13 |
18 |
def test_hgversion
|
14 |
|
to_test = { "0.9.5" => [0,9,5],
|
15 |
|
"1.0" => [1,0],
|
16 |
|
"1e4ddc9ac9f7+20080325" => nil,
|
17 |
|
"1.0.1+20080525" => [1,0,1],
|
18 |
|
"1916e629a29d" => nil}
|
|
19 |
to_test = {
|
|
20 |
"0.9.5" => [0,9,5],
|
|
21 |
"1.0" => [1,0],
|
|
22 |
"1e4ddc9ac9f7+20080325" => [],
|
|
23 |
"1.0.1+20080525" => [1,0,1],
|
|
24 |
"1916e629a29d" => [] ,
|
|
25 |
"1.6" => [1,6],
|
|
26 |
"1.6.1" => [1,6,1],
|
|
27 |
"Mercurial Distributed SCM (version 1.6.3)" => [1,6,3],
|
|
28 |
"Mercurial Distributed SCM (version 1.7)" => [1,7],
|
|
29 |
## Italian
|
|
30 |
# $ make local
|
|
31 |
# $ LANG=it ./hg --version
|
|
32 |
"Mercurial SCM Distribuito (versione 1.6.3+61-1c9bb7e00f71)" => [1,6,3],
|
|
33 |
# Multi lines CRLF.
|
|
34 |
"Mercurial Distributed SCM (version 1.6.3)\r\n1.7\r\n(1.8.1)" => [1,6,3],
|
|
35 |
# Multi lines LF.
|
|
36 |
"Mercurial Distributed SCM (version 1.7)\n1.7.1\n(1.8.1)" => [1,7],
|
|
37 |
}
|
19 |
38 |
|
20 |
39 |
to_test.each do |s, v|
|
21 |
40 |
test_hgversion_for(s, v)
|
... | ... | |
23 |
42 |
end
|
24 |
43 |
|
25 |
44 |
def test_template_path
|
26 |
|
to_test = { [0,9,5] => "0.9.5",
|
27 |
|
[1,0] => "1.0",
|
28 |
|
[] => "1.0",
|
29 |
|
[1,0,1] => "1.0"}
|
|
45 |
to_test = {
|
|
46 |
[0,9,5] => "0.9.5",
|
|
47 |
[1,0] => "1.0" ,
|
|
48 |
[] => "1.0" ,
|
|
49 |
[1,0,1] => "1.0" ,
|
|
50 |
[1,6] => "1.0" ,
|
|
51 |
[1,6,1] => "1.0" ,
|
|
52 |
}
|
30 |
53 |
|
31 |
54 |
to_test.each do |v, template|
|
32 |
55 |
test_template_path_for(v, template)
|
... | ... | |
36 |
59 |
private
|
37 |
60 |
|
38 |
61 |
def test_hgversion_for(hgversion, version)
|
39 |
|
Redmine::Scm::Adapters::MercurialAdapter.expects(:hgversion_from_command_line).returns(hgversion)
|
40 |
|
adapter = Redmine::Scm::Adapters::MercurialAdapter
|
41 |
|
assert_equal version, adapter.hgversion
|
|
62 |
@adapter.expects(:hgversion_from_command_line).returns(hgversion)
|
|
63 |
assert_equal version, @adapter.hgversion
|
42 |
64 |
end
|
43 |
65 |
|
44 |
66 |
def test_template_path_for(version, template)
|
45 |
|
adapter = Redmine::Scm::Adapters::MercurialAdapter
|
46 |
|
assert_equal "#{TEMPLATES_DIR}/#{TEMPLATE_NAME}-#{template}.#{TEMPLATE_EXTENSION}", adapter.template_path_for(version)
|
47 |
|
assert File.exist?(adapter.template_path_for(version))
|
|
67 |
assert_equal "#{TEMPLATES_DIR}/#{TEMPLATE_NAME}-#{template}.#{TEMPLATE_EXTENSION}",
|
|
68 |
@adapter.template_path_for(version)
|
|
69 |
assert File.exist?(@adapter.template_path_for(version))
|
48 |
70 |
end
|
49 |
71 |
end
|
50 |
72 |
|
51 |
73 |
rescue LoadError
|
52 |
|
def test_fake; assert(false, "Requires mocha to run those tests") end
|
|
74 |
class MercurialMochaFake < ActiveSupport::TestCase
|
|
75 |
def test_fake; assert(false, "Requires mocha to run those tests") end
|
|
76 |
end
|
53 |
77 |
end
|
|
78 |
|