To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / test / unit / lib / redmine / scm / adapters / darcs_adapter_test.rb @ 441:cbce1fd3b1b7
History | View | Annotate | Download (1.6 KB)
| 1 | 210:0579821a129a | Chris | require File.expand_path('../../../../../../test_helper', __FILE__) |
|---|---|---|---|
| 2 | begin
|
||
| 3 | require 'mocha'
|
||
| 4 | 441:cbce1fd3b1b7 | Chris | |
| 5 | 210:0579821a129a | Chris | class DarcsAdapterTest < ActiveSupport::TestCase |
| 6 | 441:cbce1fd3b1b7 | Chris | |
| 7 | 210:0579821a129a | Chris | REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/darcs_repository' |
| 8 | |||
| 9 | if File.directory?(REPOSITORY_PATH) |
||
| 10 | def setup |
||
| 11 | @adapter = Redmine::Scm::Adapters::DarcsAdapter.new(REPOSITORY_PATH) |
||
| 12 | end
|
||
| 13 | |||
| 14 | def test_darcsversion |
||
| 15 | to_test = { "1.0.9 (release)\n" => [1,0,9] ,
|
||
| 16 | "2.2.0 (release)\n" => [2,2,0] } |
||
| 17 | to_test.each do |s, v|
|
||
| 18 | test_darcsversion_for(s, v) |
||
| 19 | end
|
||
| 20 | end
|
||
| 21 | |||
| 22 | def test_revisions |
||
| 23 | id1 = '20080308225258-98289-761f654d669045eabee90b91b53a21ce5593cadf.gz'
|
||
| 24 | revs = @adapter.revisions('', nil, nil, {:with_path => true}) |
||
| 25 | assert_equal 6, revs.size
|
||
| 26 | assert_equal id1, revs[5].scmid
|
||
| 27 | paths = revs[5].paths
|
||
| 28 | assert_equal 5, paths.size
|
||
| 29 | assert_equal 'A', paths[0][:action] |
||
| 30 | assert_equal '/README', paths[0][:path] |
||
| 31 | assert_equal 'A', paths[1][:action] |
||
| 32 | assert_equal '/images', paths[1][:path] |
||
| 33 | end
|
||
| 34 | |||
| 35 | private |
||
| 36 | |||
| 37 | def test_darcsversion_for(darcsversion, version) |
||
| 38 | @adapter.class.expects(:darcs_binary_version_from_command_line).returns(darcsversion) |
||
| 39 | assert_equal version, @adapter.class.darcs_binary_version
|
||
| 40 | end
|
||
| 41 | |||
| 42 | else
|
||
| 43 | puts "Darcs test repository NOT FOUND. Skipping unit tests !!!"
|
||
| 44 | def test_fake; assert true end |
||
| 45 | end
|
||
| 46 | end
|
||
| 47 | |||
| 48 | rescue LoadError |
||
| 49 | class DarcsMochaFake < ActiveSupport::TestCase |
||
| 50 | def test_fake; assert(false, "Requires mocha to run those tests") end |
||
| 51 | end
|
||
| 52 | end
|