@@ -33,6 +33,25 module Redmine | |||||
33 | def sq_bin |
|
33 | def sq_bin | |
34 | @@sq_bin ||= shell_quote(BZR_BIN) |
|
34 | @@sq_bin ||= shell_quote(BZR_BIN) | |
35 | end |
|
35 | end | |
|
36 | ||||
|
37 | def client_version | |||
|
38 | @@client_version ||= (scm_command_version || []) | |||
|
39 | end | |||
|
40 | ||||
|
41 | def client_available | |||
|
42 | !client_version.empty? | |||
|
43 | end | |||
|
44 | ||||
|
45 | def scm_command_version | |||
|
46 | scm_version = scm_version_from_command_line | |||
|
47 | if m = scm_version.match(%r{\A(.*?)((\d+\.)+\d+)}) | |||
|
48 | m[2].scan(%r{\d+}).collect(&:to_i) | |||
|
49 | end | |||
|
50 | end | |||
|
51 | ||||
|
52 | def scm_version_from_command_line | |||
|
53 | shellout("#{sq_bin} --version") { |io| io.read }.to_s | |||
|
54 | end | |||
36 | end |
|
55 | end | |
37 |
|
56 | |||
38 | # Get info about the repository |
|
57 | # Get info about the repository |
@@ -5,12 +5,28 begin | |||||
5 | class BazaarAdapterTest < ActiveSupport::TestCase |
|
5 | class BazaarAdapterTest < ActiveSupport::TestCase | |
6 |
|
6 | |||
7 | REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/bazaar_repository' |
|
7 | REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/bazaar_repository' | |
|
8 | REPOSITORY_PATH.gsub!(/\/+/, '/') | |||
8 |
|
9 | |||
9 | if File.directory?(REPOSITORY_PATH) |
|
10 | if File.directory?(REPOSITORY_PATH) | |
10 | def setup |
|
11 | def setup | |
11 |
@adapter = Redmine::Scm::Adapters::BazaarAdapter.new( |
|
12 | @adapter = Redmine::Scm::Adapters::BazaarAdapter.new(REPOSITORY_PATH) | |
12 | end |
|
13 | end | |
13 |
|
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 | private | |||
|
25 | ||||
|
26 | def test_scm_version_for(scm_command_version, version) | |||
|
27 | @adapter.class.expects(:scm_version_from_command_line).returns(scm_command_version) | |||
|
28 | assert_equal version, @adapter.class.scm_command_version | |||
|
29 | end | |||
14 | else |
|
30 | else | |
15 | puts "Bazaar test repository NOT FOUND. Skipping unit tests !!!" |
|
31 | puts "Bazaar test repository NOT FOUND. Skipping unit tests !!!" | |
16 | def test_fake; assert true end |
|
32 | def test_fake; assert true end |
General Comments 0
You need to be logged in to leave comments.
Login now