@@ -1,474 +1,481 | |||
|
1 | 1 | # Redmine - project management software |
|
2 | 2 | # Copyright (C) 2006-2014 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 | |
|
20 | 20 | class RepositoryMercurialTest < ActiveSupport::TestCase |
|
21 | 21 | fixtures :projects |
|
22 | 22 | |
|
23 | 23 | include Redmine::I18n |
|
24 | 24 | |
|
25 | 25 | REPOSITORY_PATH = Rails.root.join('tmp/test/mercurial_repository').to_s |
|
26 | 26 | NUM_REV = 32 |
|
27 | 27 | CHAR_1_HEX = "\xc3\x9c" |
|
28 | 28 | |
|
29 | 29 | def setup |
|
30 | 30 | @project = Project.find(3) |
|
31 | 31 | @repository = Repository::Mercurial.create( |
|
32 | 32 | :project => @project, |
|
33 | 33 | :url => REPOSITORY_PATH, |
|
34 | 34 | :path_encoding => 'ISO-8859-1' |
|
35 | 35 | ) |
|
36 | 36 | assert @repository |
|
37 | 37 | @char_1 = CHAR_1_HEX.dup |
|
38 | 38 | @tag_char_1 = "tag-#{CHAR_1_HEX}-00" |
|
39 | 39 | @branch_char_0 = "branch-#{CHAR_1_HEX}-00" |
|
40 | 40 | @branch_char_1 = "branch-#{CHAR_1_HEX}-01" |
|
41 | 41 | if @char_1.respond_to?(:force_encoding) |
|
42 | 42 | @char_1.force_encoding('UTF-8') |
|
43 | 43 | @tag_char_1.force_encoding('UTF-8') |
|
44 | 44 | @branch_char_0.force_encoding('UTF-8') |
|
45 | 45 | @branch_char_1.force_encoding('UTF-8') |
|
46 | 46 | end |
|
47 | 47 | end |
|
48 | 48 | |
|
49 | 49 | def test_blank_path_to_repository_error_message |
|
50 | 50 | set_language_if_valid 'en' |
|
51 | 51 | repo = Repository::Mercurial.new( |
|
52 | 52 | :project => @project, |
|
53 | 53 | :identifier => 'test' |
|
54 | 54 | ) |
|
55 | 55 | assert !repo.save |
|
56 | 56 | assert_include "Path to repository can't be blank", |
|
57 | 57 | repo.errors.full_messages |
|
58 | 58 | end |
|
59 | 59 | |
|
60 | 60 | def test_blank_path_to_repository_error_message_fr |
|
61 | 61 | set_language_if_valid 'fr' |
|
62 | 62 | str = "Chemin du d\xc3\xa9p\xc3\xb4t doit \xc3\xaatre renseign\xc3\xa9(e)" |
|
63 | 63 | str.force_encoding('UTF-8') if str.respond_to?(:force_encoding) |
|
64 | 64 | repo = Repository::Mercurial.new( |
|
65 | 65 | :project => @project, |
|
66 | 66 | :url => "", |
|
67 | 67 | :identifier => 'test', |
|
68 | 68 | :path_encoding => '' |
|
69 | 69 | ) |
|
70 | 70 | assert !repo.save |
|
71 | 71 | assert_include str, repo.errors.full_messages |
|
72 | 72 | end |
|
73 | 73 | |
|
74 | 74 | if File.directory?(REPOSITORY_PATH) |
|
75 | 75 | def test_scm_available |
|
76 | 76 | klass = Repository::Mercurial |
|
77 | 77 | assert_equal "Mercurial", klass.scm_name |
|
78 | 78 | assert klass.scm_adapter_class |
|
79 | 79 | assert_not_equal "", klass.scm_command |
|
80 | 80 | assert_equal true, klass.scm_available |
|
81 | 81 | end |
|
82 | 82 | |
|
83 | 83 | def test_entries_on_tip |
|
84 | 84 | entries = @repository.entries |
|
85 | 85 | assert_kind_of Redmine::Scm::Adapters::Entries, entries |
|
86 | 86 | end |
|
87 | 87 | |
|
88 | 88 | def test_entries_short_id |
|
89 | 89 | assert_equal 0, @repository.changesets.count |
|
90 | 90 | @repository.fetch_changesets |
|
91 | 91 | @project.reload |
|
92 | 92 | assert_equal NUM_REV, @repository.changesets.count |
|
93 | 93 | [2, '400bb8672109', '400', 400].each do |r| |
|
94 | 94 | entries1 = @repository.entries(nil, r) |
|
95 | 95 | assert entries1 |
|
96 | 96 | assert_kind_of Redmine::Scm::Adapters::Entries, entries1 |
|
97 | 97 | assert_equal 3, entries1.size |
|
98 | 98 | readme = entries1[2] |
|
99 | 99 | assert_equal '1', readme.lastrev.revision |
|
100 | 100 | assert_equal '9d5b5b004199', readme.lastrev.identifier |
|
101 | 101 | assert_equal '1', readme.changeset.revision |
|
102 | 102 | assert_equal '9d5b5b004199', readme.changeset.scmid |
|
103 | 103 | end |
|
104 | 104 | end |
|
105 | 105 | |
|
106 | 106 | def test_entry_on_tip |
|
107 | 107 | entry = @repository.entry |
|
108 | 108 | assert_kind_of Redmine::Scm::Adapters::Entry, entry |
|
109 | 109 | assert_equal "", entry.path |
|
110 | 110 | assert_equal 'dir', entry.kind |
|
111 | 111 | end |
|
112 | 112 | |
|
113 | 113 | def test_entry_short_id |
|
114 | 114 | ["README", "/README"].each do |path| |
|
115 | 115 | ["0", "0885933ad4f6", "0885933ad4f68d77c2649cd11f8311276e7ef7ce"].each do |rev| |
|
116 | 116 | entry = @repository.entry(path, rev) |
|
117 | 117 | assert_kind_of Redmine::Scm::Adapters::Entry, entry |
|
118 | 118 | assert_equal "README", entry.path |
|
119 | 119 | assert_equal "file", entry.kind |
|
120 | 120 | assert_equal '0', entry.lastrev.revision |
|
121 | 121 | assert_equal '0885933ad4f6', entry.lastrev.identifier |
|
122 | 122 | end |
|
123 | 123 | end |
|
124 | 124 | ["sources", "/sources", "/sources/"].each do |path| |
|
125 | 125 | ["0", "0885933ad4f6", "0885933ad4f68d77c2649cd11f8311276e7ef7ce"].each do |rev| |
|
126 | 126 | entry = @repository.entry(path, rev) |
|
127 | 127 | assert_kind_of Redmine::Scm::Adapters::Entry, entry |
|
128 | 128 | assert_equal "sources", entry.path |
|
129 | 129 | assert_equal "dir", entry.kind |
|
130 | 130 | end |
|
131 | 131 | end |
|
132 | 132 | ["sources/watchers_controller.rb", "/sources/watchers_controller.rb"].each do |path| |
|
133 | 133 | ["0", "0885933ad4f6", "0885933ad4f68d77c2649cd11f8311276e7ef7ce"].each do |rev| |
|
134 | 134 | entry = @repository.entry(path, rev) |
|
135 | 135 | assert_kind_of Redmine::Scm::Adapters::Entry, entry |
|
136 | 136 | assert_equal "sources/watchers_controller.rb", entry.path |
|
137 | 137 | assert_equal "file", entry.kind |
|
138 | 138 | assert_equal '0', entry.lastrev.revision |
|
139 | 139 | assert_equal '0885933ad4f6', entry.lastrev.identifier |
|
140 | 140 | end |
|
141 | 141 | end |
|
142 | 142 | end |
|
143 | 143 | |
|
144 | 144 | def test_fetch_changesets_from_scratch |
|
145 | 145 | assert_equal 0, @repository.changesets.count |
|
146 | 146 | @repository.fetch_changesets |
|
147 | 147 | @project.reload |
|
148 | 148 | assert_equal NUM_REV, @repository.changesets.count |
|
149 | 149 | assert_equal 46, @repository.filechanges.count |
|
150 | 150 | rev0 = @repository.changesets.find_by_revision('0') |
|
151 | 151 | assert_equal "Initial import.\nThe repository contains 3 files.", |
|
152 | 152 | rev0.comments |
|
153 | 153 | assert_equal "0885933ad4f6", rev0.scmid |
|
154 | 154 | end |
|
155 | 155 | |
|
156 | 156 | def test_fetch_changesets_incremental |
|
157 | 157 | assert_equal 0, @repository.changesets.count |
|
158 | 158 | @repository.fetch_changesets |
|
159 | 159 | @project.reload |
|
160 | 160 | assert_equal NUM_REV, @repository.changesets.count |
|
161 | 161 | # Remove changesets with revision > 2 |
|
162 | 162 | @repository.changesets.each {|c| c.destroy if c.revision.to_i > 2} |
|
163 | 163 | @project.reload |
|
164 | 164 | @repository.reload |
|
165 | 165 | assert_equal 3, @repository.changesets.count |
|
166 | 166 | |
|
167 | 167 | @repository.fetch_changesets |
|
168 | 168 | @project.reload |
|
169 | 169 | assert_equal NUM_REV, @repository.changesets.count |
|
170 | 170 | end |
|
171 | 171 | |
|
172 | 172 | def test_isodatesec |
|
173 | 173 | # Template keyword 'isodatesec' supported in Mercurial 1.0 and higher |
|
174 | 174 | if @repository.scm.class.client_version_above?([1, 0]) |
|
175 | 175 | assert_equal 0, @repository.changesets.count |
|
176 | 176 | @repository.fetch_changesets |
|
177 | 177 | @project.reload |
|
178 | 178 | assert_equal NUM_REV, @repository.changesets.count |
|
179 | 179 | rev0_committed_on = Time.gm(2007, 12, 14, 9, 22, 52) |
|
180 | 180 | assert_equal @repository.changesets.find_by_revision('0').committed_on, rev0_committed_on |
|
181 | 181 | end |
|
182 | 182 | end |
|
183 | 183 | |
|
184 | 184 | def test_changeset_order_by_revision |
|
185 | 185 | assert_equal 0, @repository.changesets.count |
|
186 | 186 | @repository.fetch_changesets |
|
187 | 187 | @project.reload |
|
188 | 188 | assert_equal NUM_REV, @repository.changesets.count |
|
189 | 189 | |
|
190 | 190 | c0 = @repository.latest_changeset |
|
191 | 191 | c1 = @repository.changesets.find_by_revision('0') |
|
192 | 192 | # sorted by revision (id), not by date |
|
193 | 193 | assert c0.revision.to_i > c1.revision.to_i |
|
194 | 194 | assert c0.committed_on < c1.committed_on |
|
195 | 195 | end |
|
196 | 196 | |
|
197 | 197 | def test_latest_changesets |
|
198 | 198 | assert_equal 0, @repository.changesets.count |
|
199 | 199 | @repository.fetch_changesets |
|
200 | 200 | @project.reload |
|
201 | 201 | assert_equal NUM_REV, @repository.changesets.count |
|
202 | 202 | |
|
203 | 203 | # with_limit |
|
204 | 204 | changesets = @repository.latest_changesets('', nil, 2) |
|
205 | 205 | assert_equal %w|31 30|, changesets.collect(&:revision) |
|
206 | 206 | |
|
207 | 207 | # with_filepath |
|
208 | 208 | changesets = @repository.latest_changesets( |
|
209 | 209 | '/sql_escape/percent%dir/percent%file1.txt', nil) |
|
210 | 210 | assert_equal %w|30 11 10 9|, changesets.collect(&:revision) |
|
211 | 211 | |
|
212 | 212 | changesets = @repository.latest_changesets( |
|
213 | 213 | '/sql_escape/underscore_dir/understrike_file.txt', nil) |
|
214 | 214 | assert_equal %w|30 12 9|, changesets.collect(&:revision) |
|
215 | 215 | |
|
216 | 216 | changesets = @repository.latest_changesets('README', nil) |
|
217 | 217 | assert_equal %w|31 30 28 17 8 6 1 0|, changesets.collect(&:revision) |
|
218 | 218 | |
|
219 | 219 | changesets = @repository.latest_changesets('README','8') |
|
220 | 220 | assert_equal %w|8 6 1 0|, changesets.collect(&:revision) |
|
221 | 221 | |
|
222 | 222 | changesets = @repository.latest_changesets('README','8', 2) |
|
223 | 223 | assert_equal %w|8 6|, changesets.collect(&:revision) |
|
224 | 224 | |
|
225 | 225 | # with_dirpath |
|
226 | 226 | changesets = @repository.latest_changesets('images', nil) |
|
227 | 227 | assert_equal %w|1 0|, changesets.collect(&:revision) |
|
228 | 228 | |
|
229 | 229 | path = 'sql_escape/percent%dir' |
|
230 | 230 | changesets = @repository.latest_changesets(path, nil) |
|
231 | 231 | assert_equal %w|30 13 11 10 9|, changesets.collect(&:revision) |
|
232 | 232 | |
|
233 | 233 | changesets = @repository.latest_changesets(path, '11') |
|
234 | 234 | assert_equal %w|11 10 9|, changesets.collect(&:revision) |
|
235 | 235 | |
|
236 | 236 | changesets = @repository.latest_changesets(path, '11', 2) |
|
237 | 237 | assert_equal %w|11 10|, changesets.collect(&:revision) |
|
238 | 238 | |
|
239 | 239 | path = 'sql_escape/underscore_dir' |
|
240 | 240 | changesets = @repository.latest_changesets(path, nil) |
|
241 | 241 | assert_equal %w|30 13 12 9|, changesets.collect(&:revision) |
|
242 | 242 | |
|
243 | 243 | changesets = @repository.latest_changesets(path, '12') |
|
244 | 244 | assert_equal %w|12 9|, changesets.collect(&:revision) |
|
245 | 245 | |
|
246 | 246 | changesets = @repository.latest_changesets(path, '12', 1) |
|
247 | 247 | assert_equal %w|12|, changesets.collect(&:revision) |
|
248 | 248 | end |
|
249 | 249 | |
|
250 | 250 | def test_latest_changesets_tag |
|
251 | 251 | assert_equal 0, @repository.changesets.count |
|
252 | 252 | @repository.fetch_changesets |
|
253 | 253 | @project.reload |
|
254 | 254 | assert_equal NUM_REV, @repository.changesets.count |
|
255 | 255 | |
|
256 | 256 | changesets = @repository.latest_changesets('', 'tag_test.00') |
|
257 | 257 | assert_equal %w|5 4 3 2 1 0|, changesets.collect(&:revision) |
|
258 | end | |
|
259 | ||
|
260 | def test_latest_changesets_tag_with_path | |
|
261 | assert_equal 0, @repository.changesets.count | |
|
262 | @repository.fetch_changesets | |
|
263 | @project.reload | |
|
264 | assert_equal NUM_REV, @repository.changesets.count | |
|
258 | 265 | |
|
259 | 266 | changesets = @repository.latest_changesets('sources', 'tag_test.00') |
|
260 | 267 | assert_equal %w|4 3 2 1 0|, changesets.collect(&:revision) |
|
261 | 268 | end |
|
262 | 269 | |
|
263 | 270 | def test_latest_changesets_tag_with_limit |
|
264 | 271 | assert_equal 0, @repository.changesets.count |
|
265 | 272 | @repository.fetch_changesets |
|
266 | 273 | @project.reload |
|
267 | 274 | assert_equal NUM_REV, @repository.changesets.count |
|
268 | 275 | |
|
269 | 276 | changesets = @repository.latest_changesets('', 'tag_test.00', 2) |
|
270 | 277 | assert_equal %w|5 4|, changesets.collect(&:revision) |
|
271 | 278 | |
|
272 | 279 | changesets = @repository.latest_changesets('sources', 'tag_test.00', 2) |
|
273 | 280 | assert_equal %w|4 3|, changesets.collect(&:revision) |
|
274 | 281 | end |
|
275 | 282 | |
|
276 | 283 | def test_latest_changesets_branch |
|
277 | 284 | assert_equal 0, @repository.changesets.count |
|
278 | 285 | @repository.fetch_changesets |
|
279 | 286 | @project.reload |
|
280 | 287 | assert_equal NUM_REV, @repository.changesets.count |
|
281 | 288 | |
|
282 | 289 | if @repository.scm.class.client_version_above?([1, 6]) |
|
283 | 290 | changesets = @repository.latest_changesets('', @branch_char_1) |
|
284 | 291 | assert_equal %w|27 26|, changesets.collect(&:revision) |
|
285 | 292 | end |
|
286 | 293 | |
|
287 | 294 | changesets = @repository.latest_changesets("latin-1-dir/test-#{@char_1}-subdir", @branch_char_1) |
|
288 | 295 | assert_equal %w|27|, changesets.collect(&:revision) |
|
289 | 296 | end |
|
290 | 297 | |
|
291 | 298 | def test_latest_changesets_default_branch |
|
292 | 299 | assert_equal 0, @repository.changesets.count |
|
293 | 300 | @repository.fetch_changesets |
|
294 | 301 | @project.reload |
|
295 | 302 | assert_equal NUM_REV, @repository.changesets.count |
|
296 | 303 | changesets = @repository.latest_changesets('', 'default') |
|
297 | 304 | assert_equal %w|31 28 24 6 4 3 2 1 0|, changesets.collect(&:revision) |
|
298 | 305 | end |
|
299 | 306 | |
|
300 | 307 | def test_copied_files |
|
301 | 308 | assert_equal 0, @repository.changesets.count |
|
302 | 309 | @repository.fetch_changesets |
|
303 | 310 | @project.reload |
|
304 | 311 | assert_equal NUM_REV, @repository.changesets.count |
|
305 | 312 | |
|
306 | 313 | cs1 = @repository.changesets.find_by_revision('13') |
|
307 | 314 | assert_not_nil cs1 |
|
308 | 315 | c1 = cs1.filechanges.sort_by(&:path) |
|
309 | 316 | assert_equal 2, c1.size |
|
310 | 317 | |
|
311 | 318 | assert_equal 'A', c1[0].action |
|
312 | 319 | assert_equal '/sql_escape/percent%dir/percentfile1.txt', c1[0].path |
|
313 | 320 | assert_equal '/sql_escape/percent%dir/percent%file1.txt', c1[0].from_path |
|
314 | 321 | assert_equal '3a330eb32958', c1[0].from_revision |
|
315 | 322 | |
|
316 | 323 | assert_equal 'A', c1[1].action |
|
317 | 324 | assert_equal '/sql_escape/underscore_dir/understrike-file.txt', c1[1].path |
|
318 | 325 | assert_equal '/sql_escape/underscore_dir/understrike_file.txt', c1[1].from_path |
|
319 | 326 | |
|
320 | 327 | cs2 = @repository.changesets.find_by_revision('15') |
|
321 | 328 | c2 = cs2.filechanges |
|
322 | 329 | assert_equal 1, c2.size |
|
323 | 330 | |
|
324 | 331 | assert_equal 'A', c2[0].action |
|
325 | 332 | assert_equal '/README (1)[2]&,%.-3_4', c2[0].path |
|
326 | 333 | assert_equal '/README', c2[0].from_path |
|
327 | 334 | assert_equal '933ca60293d7', c2[0].from_revision |
|
328 | 335 | |
|
329 | 336 | cs3 = @repository.changesets.find_by_revision('19') |
|
330 | 337 | c3 = cs3.filechanges |
|
331 | 338 | assert_equal 1, c3.size |
|
332 | 339 | assert_equal 'A', c3[0].action |
|
333 | 340 | assert_equal "/latin-1-dir/test-#{@char_1}-1.txt", c3[0].path |
|
334 | 341 | assert_equal "/latin-1-dir/test-#{@char_1}.txt", c3[0].from_path |
|
335 | 342 | assert_equal '5d9891a1b425', c3[0].from_revision |
|
336 | 343 | end |
|
337 | 344 | |
|
338 | 345 | def test_find_changeset_by_name |
|
339 | 346 | assert_equal 0, @repository.changesets.count |
|
340 | 347 | @repository.fetch_changesets |
|
341 | 348 | @project.reload |
|
342 | 349 | assert_equal NUM_REV, @repository.changesets.count |
|
343 | 350 | %w|2 400bb8672109 400|.each do |r| |
|
344 | 351 | assert_equal '2', @repository.find_changeset_by_name(r).revision |
|
345 | 352 | end |
|
346 | 353 | end |
|
347 | 354 | |
|
348 | 355 | def test_find_changeset_by_invalid_name |
|
349 | 356 | assert_equal 0, @repository.changesets.count |
|
350 | 357 | @repository.fetch_changesets |
|
351 | 358 | @project.reload |
|
352 | 359 | assert_equal NUM_REV, @repository.changesets.count |
|
353 | 360 | assert_nil @repository.find_changeset_by_name('100000') |
|
354 | 361 | end |
|
355 | 362 | |
|
356 | 363 | def test_identifier |
|
357 | 364 | assert_equal 0, @repository.changesets.count |
|
358 | 365 | @repository.fetch_changesets |
|
359 | 366 | @project.reload |
|
360 | 367 | assert_equal NUM_REV, @repository.changesets.count |
|
361 | 368 | c = @repository.changesets.find_by_revision('2') |
|
362 | 369 | assert_equal c.scmid, c.identifier |
|
363 | 370 | end |
|
364 | 371 | |
|
365 | 372 | def test_format_identifier |
|
366 | 373 | assert_equal 0, @repository.changesets.count |
|
367 | 374 | @repository.fetch_changesets |
|
368 | 375 | @project.reload |
|
369 | 376 | assert_equal NUM_REV, @repository.changesets.count |
|
370 | 377 | c = @repository.changesets.find_by_revision('2') |
|
371 | 378 | assert_equal '2:400bb8672109', c.format_identifier |
|
372 | 379 | end |
|
373 | 380 | |
|
374 | 381 | def test_format_identifier_long_id |
|
375 | 382 | assert_equal 0, @repository.changesets.count |
|
376 | 383 | Changeset.create!(:repository => @repository, |
|
377 | 384 | :committed_on => Time.now, |
|
378 | 385 | :revision => '0', |
|
379 | 386 | :scmid => '0885933ad4f68d77c2649cd11f8311276e7ef7ce', |
|
380 | 387 | :comments => 'test') |
|
381 | 388 | c = @repository.changesets.find_by_revision('0') |
|
382 | 389 | assert_equal '0:0885933ad4f6', c.format_identifier |
|
383 | 390 | end |
|
384 | 391 | |
|
385 | 392 | def test_find_changeset_by_empty_name |
|
386 | 393 | assert_equal 0, @repository.changesets.count |
|
387 | 394 | @repository.fetch_changesets |
|
388 | 395 | @project.reload |
|
389 | 396 | assert_equal NUM_REV, @repository.changesets.count |
|
390 | 397 | ['', ' ', nil].each do |r| |
|
391 | 398 | assert_nil @repository.find_changeset_by_name(r) |
|
392 | 399 | end |
|
393 | 400 | end |
|
394 | 401 | |
|
395 | 402 | def test_parents |
|
396 | 403 | assert_equal 0, @repository.changesets.count |
|
397 | 404 | @repository.fetch_changesets |
|
398 | 405 | @project.reload |
|
399 | 406 | assert_equal NUM_REV, @repository.changesets.count |
|
400 | 407 | r1 = @repository.changesets.find_by_revision('0') |
|
401 | 408 | assert_equal [], r1.parents |
|
402 | 409 | r2 = @repository.changesets.find_by_revision('1') |
|
403 | 410 | assert_equal 1, r2.parents.length |
|
404 | 411 | assert_equal "0885933ad4f6", |
|
405 | 412 | r2.parents[0].identifier |
|
406 | 413 | r3 = @repository.changesets.find_by_revision('30') |
|
407 | 414 | assert_equal 2, r3.parents.length |
|
408 | 415 | r4 = [r3.parents[0].identifier, r3.parents[1].identifier].sort |
|
409 | 416 | assert_equal "3a330eb32958", r4[0] |
|
410 | 417 | assert_equal "a94b0528f24f", r4[1] |
|
411 | 418 | end |
|
412 | 419 | |
|
413 | 420 | def test_activities |
|
414 | 421 | c = Changeset.new(:repository => @repository, |
|
415 | 422 | :committed_on => Time.now, |
|
416 | 423 | :revision => '123', |
|
417 | 424 | :scmid => 'abc400bb8672', |
|
418 | 425 | :comments => 'test') |
|
419 | 426 | assert c.event_title.include?('123:abc400bb8672:') |
|
420 | 427 | assert_equal 'abc400bb8672', c.event_url[:rev] |
|
421 | 428 | end |
|
422 | 429 | |
|
423 | 430 | def test_previous |
|
424 | 431 | assert_equal 0, @repository.changesets.count |
|
425 | 432 | @repository.fetch_changesets |
|
426 | 433 | @project.reload |
|
427 | 434 | assert_equal NUM_REV, @repository.changesets.count |
|
428 | 435 | %w|28 3ae45e2d177d 3ae45|.each do |r1| |
|
429 | 436 | changeset = @repository.find_changeset_by_name(r1) |
|
430 | 437 | %w|27 7bbf4c738e71 7bbf|.each do |r2| |
|
431 | 438 | assert_equal @repository.find_changeset_by_name(r2), changeset.previous |
|
432 | 439 | end |
|
433 | 440 | end |
|
434 | 441 | end |
|
435 | 442 | |
|
436 | 443 | def test_previous_nil |
|
437 | 444 | assert_equal 0, @repository.changesets.count |
|
438 | 445 | @repository.fetch_changesets |
|
439 | 446 | @project.reload |
|
440 | 447 | assert_equal NUM_REV, @repository.changesets.count |
|
441 | 448 | %w|0 0885933ad4f6 0885|.each do |r1| |
|
442 | 449 | changeset = @repository.find_changeset_by_name(r1) |
|
443 | 450 | assert_nil changeset.previous |
|
444 | 451 | end |
|
445 | 452 | end |
|
446 | 453 | |
|
447 | 454 | def test_next |
|
448 | 455 | assert_equal 0, @repository.changesets.count |
|
449 | 456 | @repository.fetch_changesets |
|
450 | 457 | @project.reload |
|
451 | 458 | assert_equal NUM_REV, @repository.changesets.count |
|
452 | 459 | %w|27 7bbf4c738e71 7bbf|.each do |r2| |
|
453 | 460 | changeset = @repository.find_changeset_by_name(r2) |
|
454 | 461 | %w|28 3ae45e2d177d 3ae45|.each do |r1| |
|
455 | 462 | assert_equal @repository.find_changeset_by_name(r1), changeset.next |
|
456 | 463 | end |
|
457 | 464 | end |
|
458 | 465 | end |
|
459 | 466 | |
|
460 | 467 | def test_next_nil |
|
461 | 468 | assert_equal 0, @repository.changesets.count |
|
462 | 469 | @repository.fetch_changesets |
|
463 | 470 | @project.reload |
|
464 | 471 | assert_equal NUM_REV, @repository.changesets.count |
|
465 | 472 | %w|31 31eeee7395c8 31eee|.each do |r1| |
|
466 | 473 | changeset = @repository.find_changeset_by_name(r1) |
|
467 | 474 | assert_nil changeset.next |
|
468 | 475 | end |
|
469 | 476 | end |
|
470 | 477 | else |
|
471 | 478 | puts "Mercurial test repository NOT FOUND. Skipping unit tests !!!" |
|
472 | 479 | def test_fake; assert true end |
|
473 | 480 | end |
|
474 | 481 | end |
General Comments 0
You need to be logged in to leave comments.
Login now