To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / .svn / pristine / 07 / 071604c5dacdea2b6b0884f22cd68afddd0f1a2a.svn-base @ 1298:4f746d8966dd
History | View | Annotate | Download (3.53 KB)
| 1 |
# Redmine - project management software |
|---|---|
| 2 |
# Copyright (C) 2006-2012 Jean-Philippe Lang |
| 3 |
# |
| 4 |
# This program is free software; you can redistribute it and/or |
| 5 |
# modify it under the terms of the GNU General Public License |
| 6 |
# as published by the Free Software Foundation; either version 2 |
| 7 |
# of the License, or (at your option) any later version. |
| 8 |
# |
| 9 |
# This program is distributed in the hope that it will be useful, |
| 10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
# GNU General Public License for more details. |
| 13 |
# |
| 14 |
# You should have received a copy of the GNU General Public License |
| 15 |
# along with this program; if not, write to the Free Software |
| 16 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 17 |
|
| 18 |
require File.expand_path('../../../../../../test_helper', __FILE__)
|
| 19 |
begin |
| 20 |
require 'mocha' |
| 21 |
|
| 22 |
class CvsAdapterTest < ActiveSupport::TestCase |
| 23 |
REPOSITORY_PATH = Rails.root.join('tmp/test/cvs_repository').to_s
|
| 24 |
REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin? |
| 25 |
MODULE_NAME = 'test' |
| 26 |
|
| 27 |
if File.directory?(REPOSITORY_PATH) |
| 28 |
def setup |
| 29 |
@adapter = Redmine::Scm::Adapters::CvsAdapter.new(MODULE_NAME, REPOSITORY_PATH) |
| 30 |
end |
| 31 |
|
| 32 |
def test_scm_version |
| 33 |
to_test = { "\nConcurrent Versions System (CVS) 1.12.13 (client/server)\n" => [1,12,13],
|
| 34 |
"\r\n1.12.12\r\n1.12.11" => [1,12,12], |
| 35 |
"1.12.11\r\n1.12.10\r\n" => [1,12,11]} |
| 36 |
to_test.each do |s, v| |
| 37 |
test_scm_version_for(s, v) |
| 38 |
end |
| 39 |
end |
| 40 |
|
| 41 |
def test_revisions_all |
| 42 |
cnt = 0 |
| 43 |
@adapter.revisions('', nil, nil, :log_encoding => 'UTF-8') do |revision|
|
| 44 |
cnt += 1 |
| 45 |
end |
| 46 |
assert_equal 16, cnt |
| 47 |
end |
| 48 |
|
| 49 |
def test_revisions_from_rev3 |
| 50 |
rev3_committed_on = Time.gm(2007, 12, 13, 16, 27, 22) |
| 51 |
cnt = 0 |
| 52 |
@adapter.revisions('', rev3_committed_on, nil, :log_encoding => 'UTF-8') do |revision|
|
| 53 |
cnt += 1 |
| 54 |
end |
| 55 |
assert_equal 4, cnt |
| 56 |
end |
| 57 |
|
| 58 |
def test_entries_rev3 |
| 59 |
rev3_committed_on = Time.gm(2007, 12, 13, 16, 27, 22) |
| 60 |
entries = @adapter.entries('sources', rev3_committed_on)
|
| 61 |
assert_equal 2, entries.size |
| 62 |
assert_equal entries[0].name, "watchers_controller.rb" |
| 63 |
assert_equal entries[0].lastrev.time, Time.gm(2007, 12, 13, 16, 27, 22) |
| 64 |
end |
| 65 |
|
| 66 |
def test_path_encoding_default_utf8 |
| 67 |
adpt1 = Redmine::Scm::Adapters::CvsAdapter.new( |
| 68 |
MODULE_NAME, |
| 69 |
REPOSITORY_PATH |
| 70 |
) |
| 71 |
assert_equal "UTF-8", adpt1.path_encoding |
| 72 |
adpt2 = Redmine::Scm::Adapters::CvsAdapter.new( |
| 73 |
MODULE_NAME, |
| 74 |
REPOSITORY_PATH, |
| 75 |
nil, |
| 76 |
nil, |
| 77 |
"" |
| 78 |
) |
| 79 |
assert_equal "UTF-8", adpt2.path_encoding |
| 80 |
end |
| 81 |
|
| 82 |
private |
| 83 |
|
| 84 |
def test_scm_version_for(scm_command_version, version) |
| 85 |
@adapter.class.expects(:scm_version_from_command_line).returns(scm_command_version) |
| 86 |
assert_equal version, @adapter.class.scm_command_version |
| 87 |
end |
| 88 |
else |
| 89 |
puts "Cvs test repository NOT FOUND. Skipping unit tests !!!" |
| 90 |
def test_fake; assert true end |
| 91 |
end |
| 92 |
end |
| 93 |
|
| 94 |
rescue LoadError |
| 95 |
class CvsMochaFake < ActiveSupport::TestCase |
| 96 |
def test_fake; assert(false, "Requires mocha to run those tests") end |
| 97 |
end |
| 98 |
end |
| 99 |
|