##// END OF EJS Templates
Fixes an error raised by cvs test with Postgresql (revision is varchar)....
Jean-Philippe Lang -
r5295:5fd891aa7224
parent child
Show More
@@ -1,160 +1,160
1 1 # redMine - project management software
2 2 # Copyright (C) 2006-2007 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 require File.expand_path('../../test_helper', __FILE__)
19 19 require 'pp'
20 20 class RepositoryCvsTest < ActiveSupport::TestCase
21 21 fixtures :projects
22 22
23 23 # No '..' in the repository path
24 24 REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/cvs_repository'
25 25 REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin?
26 26 # CVS module
27 27 MODULE_NAME = 'test'
28 28
29 29 def setup
30 30 @project = Project.find(3)
31 31 @repository = Repository::Cvs.create(:project => @project,
32 32 :root_url => REPOSITORY_PATH,
33 33 :url => MODULE_NAME,
34 34 :log_encoding => 'UTF-8')
35 35 assert @repository
36 36 end
37 37
38 38 if File.directory?(REPOSITORY_PATH)
39 39 def test_fetch_changesets_from_scratch
40 40 assert_equal 0, @repository.changesets.count
41 41 @repository.fetch_changesets
42 42 @repository.reload
43 43
44 44 assert_equal 5, @repository.changesets.count
45 45 assert_equal 14, @repository.changes.count
46 46 assert_not_nil @repository.changesets.find_by_comments('Two files changed')
47 47
48 48 r2 = @repository.changesets.find_by_revision('2')
49 49 assert_equal 'v1-20071213-162510', r2.scmid
50 50 end
51 51
52 52 def test_fetch_changesets_incremental
53 53 assert_equal 0, @repository.changesets.count
54 54 @repository.fetch_changesets
55 55 # Remove changesets with revision > 3
56 56 @repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 3}
57 57 @repository.reload
58 58 assert_equal 3, @repository.changesets.count
59 59 assert_equal %w|3 2 1|, @repository.changesets.collect(&:revision)
60 60
61 61 rev3_commit = @repository.changesets.find(:first, :order => 'committed_on DESC')
62 62 assert_equal '3', rev3_commit.revision
63 63 # 2007-12-14 01:27:22 +0900
64 64 rev3_committed_on = Time.gm(2007, 12, 13, 16, 27, 22)
65 65 assert_equal 'HEAD-20071213-162722', rev3_commit.scmid
66 66 assert_equal rev3_committed_on, rev3_commit.committed_on
67 67 latest_rev = @repository.latest_changeset
68 68 assert_equal rev3_committed_on, latest_rev.committed_on
69 69
70 70 @repository.fetch_changesets
71 71 @repository.reload
72 72 assert_equal 5, @repository.changesets.count
73 73
74 74 assert_equal %w|5 4 3 2 1|, @repository.changesets.collect(&:revision)
75 75 rev5_commit = @repository.changesets.find(:first, :order => 'committed_on DESC')
76 76 assert_equal 'HEAD-20071213-163001', rev5_commit.scmid
77 77 # 2007-12-14 01:30:01 +0900
78 78 rev5_committed_on = Time.gm(2007, 12, 13, 16, 30, 1)
79 79 assert_equal rev5_committed_on, rev5_commit.committed_on
80 80 end
81 81
82 82 def test_deleted_files_should_not_be_listed
83 83 assert_equal 0, @repository.changesets.count
84 84 @repository.fetch_changesets
85 85 @repository.reload
86 86 assert_equal 5, @repository.changesets.count
87 87
88 88 entries = @repository.entries('sources')
89 89 assert entries.detect {|e| e.name == 'watchers_controller.rb'}
90 90 assert_nil entries.detect {|e| e.name == 'welcome_controller.rb'}
91 91 end
92 92
93 93 def test_entries_rev3
94 94 @repository.fetch_changesets
95 95 @repository.reload
96 96 entries = @repository.entries('', '3')
97 97 assert_equal 3, entries.size
98 98 assert_equal entries[2].name, "README"
99 99 assert_equal entries[2].lastrev.time, Time.gm(2007, 12, 13, 16, 27, 22)
100 100 assert_equal entries[2].lastrev.identifier, '3'
101 101 assert_equal entries[2].lastrev.revision, '3'
102 102 assert_equal entries[2].lastrev.author, 'LANG'
103 103 end
104 104
105 105 def test_entries_invalid
106 106 @repository.fetch_changesets
107 107 @repository.reload
108 108 assert_nil @repository.entries('missing')
109 109 assert_nil @repository.entries('missing', '3')
110 110 end
111 111
112 112 def test_cat
113 113 @repository.fetch_changesets
114 114 @repository.reload
115 115 buf = @repository.cat('README')
116 116 assert buf
117 117 lines = buf.split("\n")
118 118 assert_equal 2, lines.length
119 119 assert_equal 'with one change', lines[1]
120 buf = @repository.cat('README', 1)
120 buf = @repository.cat('README', '1')
121 121 assert buf
122 122 lines = buf.split("\n")
123 123 assert_equal 1, lines.length
124 124 assert_equal 'CVS test repository', lines[0]
125 125 assert_nil @repository.cat('missing.rb')
126 126
127 127 # sources/welcome_controller.rb is removed at revision 5.
128 128 assert @repository.cat('sources/welcome_controller.rb', '4')
129 129 assert @repository.cat('sources/welcome_controller.rb', '5').blank?
130 130
131 131 # invalid revision
132 132 assert @repository.cat('README', '123').blank?
133 133 end
134 134
135 135 def test_annotate
136 136 @repository.fetch_changesets
137 137 @repository.reload
138 138 ann = @repository.annotate('README')
139 139 assert ann
140 140 assert_equal 2, ann.revisions.length
141 141 assert_equal '1.2', ann.revisions[1].revision
142 142 assert_equal 'LANG', ann.revisions[1].author
143 143 assert_equal 'with one change', ann.lines[1]
144 144
145 145 ann = @repository.annotate('README', '1')
146 146 assert ann
147 147 assert_equal 1, ann.revisions.length
148 148 assert_equal '1.1', ann.revisions[0].revision
149 149 assert_equal 'LANG', ann.revisions[0].author
150 150 assert_equal 'CVS test repository', ann.lines[0]
151 151
152 152 # invalid revision
153 153 assert_nil @repository.annotate('README', '123')
154 154 end
155 155
156 156 else
157 157 puts "CVS test repository NOT FOUND. Skipping unit tests !!!"
158 158 def test_fake; assert true end
159 159 end
160 160 end
General Comments 0
You need to be logged in to leave comments. Login now