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 / cvs_adapter_test.rb @ 442:753f1380d6bc
History | View | Annotate | Download (2.77 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 CvsAdapterTest < ActiveSupport::TestCase |
| 6 | 441:cbce1fd3b1b7 | Chris | |
| 7 | 210:0579821a129a | Chris | REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/cvs_repository' |
| 8 | 245:051f544170fe | Chris | REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin? |
| 9 | 210:0579821a129a | Chris | MODULE_NAME = 'test' |
| 10 | |||
| 11 | 441:cbce1fd3b1b7 | Chris | if File.directory?(REPOSITORY_PATH) |
| 12 | 210:0579821a129a | Chris | def setup |
| 13 | @adapter = Redmine::Scm::Adapters::CvsAdapter.new(MODULE_NAME, REPOSITORY_PATH) |
||
| 14 | end
|
||
| 15 | |||
| 16 | 245:051f544170fe | Chris | def test_scm_version |
| 17 | to_test = { "\nConcurrent Versions System (CVS) 1.12.13 (client/server)\n" => [1,12,13],
|
||
| 18 | "\r\n1.12.12\r\n1.12.11" => [1,12,12], |
||
| 19 | "1.12.11\r\n1.12.10\r\n" => [1,12,11]} |
||
| 20 | to_test.each do |s, v|
|
||
| 21 | test_scm_version_for(s, v) |
||
| 22 | end
|
||
| 23 | end
|
||
| 24 | |||
| 25 | 210:0579821a129a | Chris | def test_revisions_all |
| 26 | cnt = 0
|
||
| 27 | 441:cbce1fd3b1b7 | Chris | @adapter.revisions('', nil, nil, :log_encoding => 'UTF-8') do |revision| |
| 28 | 210:0579821a129a | Chris | cnt += 1
|
| 29 | end
|
||
| 30 | 441:cbce1fd3b1b7 | Chris | assert_equal 16, cnt
|
| 31 | 210:0579821a129a | Chris | end
|
| 32 | |||
| 33 | def test_revisions_from_rev3 |
||
| 34 | rev3_committed_on = Time.gm(2007, 12, 13, 16, 27, 22) |
||
| 35 | cnt = 0
|
||
| 36 | 441:cbce1fd3b1b7 | Chris | @adapter.revisions('', rev3_committed_on, nil, :log_encoding => 'UTF-8') do |revision| |
| 37 | 210:0579821a129a | Chris | cnt += 1
|
| 38 | end
|
||
| 39 | 441:cbce1fd3b1b7 | Chris | assert_equal 4, cnt
|
| 40 | end
|
||
| 41 | |||
| 42 | def test_entries_rev3 |
||
| 43 | rev3_committed_on = Time.gm(2007, 12, 13, 16, 27, 22) |
||
| 44 | entries = @adapter.entries('sources', rev3_committed_on) |
||
| 45 | assert_equal 2, entries.size
|
||
| 46 | assert_equal entries[0].name, "watchers_controller.rb" |
||
| 47 | assert_equal entries[0].lastrev.time, Time.gm(2007, 12, 13, 16, 27, 22) |
||
| 48 | end
|
||
| 49 | |||
| 50 | def test_path_encoding_default_utf8 |
||
| 51 | adpt1 = Redmine::Scm::Adapters::CvsAdapter.new( |
||
| 52 | MODULE_NAME,
|
||
| 53 | REPOSITORY_PATH
|
||
| 54 | ) |
||
| 55 | assert_equal "UTF-8", adpt1.path_encoding
|
||
| 56 | adpt2 = Redmine::Scm::Adapters::CvsAdapter.new( |
||
| 57 | MODULE_NAME,
|
||
| 58 | REPOSITORY_PATH,
|
||
| 59 | nil,
|
||
| 60 | nil,
|
||
| 61 | ""
|
||
| 62 | ) |
||
| 63 | assert_equal "UTF-8", adpt2.path_encoding
|
||
| 64 | 210:0579821a129a | Chris | end
|
| 65 | 245:051f544170fe | Chris | |
| 66 | private |
||
| 67 | |||
| 68 | def test_scm_version_for(scm_command_version, version) |
||
| 69 | @adapter.class.expects(:scm_version_from_command_line).returns(scm_command_version) |
||
| 70 | assert_equal version, @adapter.class.scm_command_version
|
||
| 71 | end
|
||
| 72 | 210:0579821a129a | Chris | else
|
| 73 | puts "Cvs test repository NOT FOUND. Skipping unit tests !!!"
|
||
| 74 | def test_fake; assert true end |
||
| 75 | end
|
||
| 76 | end
|
||
| 77 | |||
| 78 | rescue LoadError |
||
| 79 | class CvsMochaFake < ActiveSupport::TestCase |
||
| 80 | def test_fake; assert(false, "Requires mocha to run those tests") end |
||
| 81 | end
|
||
| 82 | end
|