##// END OF EJS Templates
scm: git: fix test revision value of unit app test...
Toshi MARUYAMA -
r9151:d2c80656f145
parent child
Show More
@@ -1,555 +1,555
1 1 # Redmine - project management software
2 2 # Copyright (C) 2006-2011 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 RepositoryGitTest < ActiveSupport::TestCase
21 21 fixtures :projects, :repositories, :enabled_modules, :users, :roles
22 22
23 23 include Redmine::I18n
24 24
25 25 REPOSITORY_PATH = Rails.root.join('tmp/test/git_repository').to_s
26 26 REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin?
27 27
28 28 NUM_REV = 28
29 29 NUM_HEAD = 6
30 30
31 31 FELIX_HEX = "Felix Sch\xC3\xA4fer"
32 32 CHAR_1_HEX = "\xc3\x9c"
33 33
34 34 ## Ruby uses ANSI api to fork a process on Windows.
35 35 ## Japanese Shift_JIS and Traditional Chinese Big5 have 0x5c(backslash) problem
36 36 ## and these are incompatible with ASCII.
37 37 # WINDOWS_PASS = Redmine::Platform.mswin?
38 38 WINDOWS_PASS = false
39 39
40 40 ## Git, Mercurial and CVS path encodings are binary.
41 41 ## Subversion supports URL encoding for path.
42 42 ## Redmine Mercurial adapter and extension use URL encoding.
43 43 ## Git accepts only binary path in command line parameter.
44 44 ## So, there is no way to use binary command line parameter in JRuby.
45 45 JRUBY_SKIP = (RUBY_PLATFORM == 'java')
46 46 JRUBY_SKIP_STR = "TODO: This test fails in JRuby"
47 47
48 48 def setup
49 49 @project = Project.find(3)
50 50 @repository = Repository::Git.create(
51 51 :project => @project,
52 52 :url => REPOSITORY_PATH,
53 53 :path_encoding => 'ISO-8859-1'
54 54 )
55 55 assert @repository
56 56 @char_1 = CHAR_1_HEX.dup
57 57 if @char_1.respond_to?(:force_encoding)
58 58 @char_1.force_encoding('UTF-8')
59 59 end
60 60 end
61 61
62 62 def test_blank_path_to_repository_error_message
63 63 set_language_if_valid 'en'
64 64 repo = Repository::Git.new(
65 65 :project => @project,
66 66 :identifier => 'test'
67 67 )
68 68 assert !repo.save
69 69 assert_include "Path to repository can't be blank",
70 70 repo.errors.full_messages
71 71 end
72 72
73 73 def test_blank_path_to_repository_error_message_fr
74 74 set_language_if_valid 'fr'
75 75 str = "Chemin du d\xc3\xa9p\xc3\xb4t doit \xc3\xaatre renseign\xc3\xa9(e)"
76 76 str.force_encoding('UTF-8') if str.respond_to?(:force_encoding)
77 77 repo = Repository::Git.new(
78 78 :project => @project,
79 79 :url => "",
80 80 :identifier => 'test',
81 81 :path_encoding => ''
82 82 )
83 83 assert !repo.save
84 84 assert_include str, repo.errors.full_messages
85 85 end
86 86
87 87 if File.directory?(REPOSITORY_PATH)
88 88 def test_scm_available
89 89 klass = Repository::Git
90 90 assert_equal "Git", klass.scm_name
91 91 assert klass.scm_adapter_class
92 92 assert_not_equal "", klass.scm_command
93 93 assert_equal true, klass.scm_available
94 94 end
95 95
96 96 def test_fetch_changesets_from_scratch
97 97 assert_nil @repository.extra_info
98 98
99 99 assert_equal 0, @repository.changesets.count
100 100 @repository.fetch_changesets
101 101 @project.reload
102 102
103 103 assert_equal NUM_REV, @repository.changesets.count
104 104 assert_equal 39, @repository.changes.count
105 105
106 106 commit = @repository.changesets.find_by_revision("7234cb2750b63f47bff735edc50a1c0a433c2518")
107 107 assert_equal "7234cb2750b63f47bff735edc50a1c0a433c2518", commit.scmid
108 108 assert_equal "Initial import.\nThe repository contains 3 files.", commit.comments
109 109 assert_equal "jsmith <jsmith@foo.bar>", commit.committer
110 110 assert_equal User.find_by_login('jsmith'), commit.user
111 111 # TODO: add a commit with commit time <> author time to the test repository
112 112 assert_equal "2007-12-14 09:22:52".to_time, commit.committed_on
113 113 assert_equal "2007-12-14".to_date, commit.commit_date
114 114 assert_equal 3, commit.changes.count
115 115 change = commit.changes.sort_by(&:path).first
116 116 assert_equal "README", change.path
117 117 assert_equal "A", change.action
118 118
119 119 assert_equal NUM_HEAD, @repository.extra_info["heads"].size
120 120 end
121 121
122 122 def test_fetch_changesets_incremental
123 123 assert_equal 0, @repository.changesets.count
124 124 @repository.fetch_changesets
125 125 @project.reload
126 126 assert_equal NUM_REV, @repository.changesets.count
127 127 extra_info_heads = @repository.extra_info["heads"].dup
128 128 assert_equal NUM_HEAD, extra_info_heads.size
129 129 extra_info_heads.delete_if { |x| x == "83ca5fd546063a3c7dc2e568ba3355661a9e2b2c" }
130 130 assert_equal 4, extra_info_heads.size
131 131
132 132 del_revs = [
133 133 "83ca5fd546063a3c7dc2e568ba3355661a9e2b2c",
134 134 "ed5bb786bbda2dee66a2d50faf51429dbc043a7b",
135 135 "4f26664364207fa8b1af9f8722647ab2d4ac5d43",
136 136 "deff712f05a90d96edbd70facc47d944be5897e3",
137 137 "32ae898b720c2f7eec2723d5bdd558b4cb2d3ddf",
138 138 "7e61ac704deecde634b51e59daa8110435dcb3da",
139 139 ]
140 140 @repository.changesets.each do |rev|
141 141 rev.destroy if del_revs.detect {|r| r == rev.scmid.to_s }
142 142 end
143 143 @project.reload
144 144 cs1 = @repository.changesets
145 145 assert_equal NUM_REV - 6, cs1.count
146 146 extra_info_heads << "4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8"
147 147 h = {}
148 148 h["heads"] = extra_info_heads
149 149 @repository.merge_extra_info(h)
150 150 @repository.save
151 151 @project.reload
152 152 assert @repository.extra_info["heads"].index("4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8")
153 153 @repository.fetch_changesets
154 154 @project.reload
155 155 assert_equal NUM_REV, @repository.changesets.count
156 156 assert_equal NUM_HEAD, @repository.extra_info["heads"].size
157 157 assert @repository.extra_info["heads"].index("83ca5fd546063a3c7dc2e568ba3355661a9e2b2c")
158 158 end
159 159
160 160 def test_fetch_changesets_history_editing
161 161 assert_equal 0, @repository.changesets.count
162 162 @repository.fetch_changesets
163 163 @project.reload
164 164 assert_equal NUM_REV, @repository.changesets.count
165 165 extra_info_heads = @repository.extra_info["heads"].dup
166 166 assert_equal NUM_HEAD, extra_info_heads.size
167 167 extra_info_heads.delete_if { |x| x == "83ca5fd546063a3c7dc2e568ba3355661a9e2b2c" }
168 168 assert_equal 4, extra_info_heads.size
169 169
170 170 del_revs = [
171 171 "83ca5fd546063a3c7dc2e568ba3355661a9e2b2c",
172 172 "ed5bb786bbda2dee66a2d50faf51429dbc043a7b",
173 173 "4f26664364207fa8b1af9f8722647ab2d4ac5d43",
174 174 "deff712f05a90d96edbd70facc47d944be5897e3",
175 175 "32ae898b720c2f7eec2723d5bdd558b4cb2d3ddf",
176 176 "7e61ac704deecde634b51e59daa8110435dcb3da",
177 177 ]
178 178 @repository.changesets.each do |rev|
179 179 rev.destroy if del_revs.detect {|r| r == rev.scmid.to_s }
180 180 end
181 181 @project.reload
182 182 assert_equal NUM_REV - 6, @repository.changesets.count
183 183
184 184 c = Changeset.new(:repository => @repository,
185 185 :committed_on => Time.now,
186 186 :revision => "abcd1234efgh",
187 187 :scmid => "abcd1234efgh",
188 188 :comments => 'test')
189 189 assert c.save
190 190 @project.reload
191 191 assert_equal NUM_REV - 5, @repository.changesets.count
192 192
193 extra_info_heads << "abcd1234efgh"
193 extra_info_heads << "1234abcd5678"
194 194 h = {}
195 195 h["heads"] = extra_info_heads
196 196 @repository.merge_extra_info(h)
197 197 @repository.save
198 198 @project.reload
199 199 h1 = @repository.extra_info["heads"].dup
200 assert h1.index("abcd1234efgh")
200 assert h1.index("1234abcd5678")
201 201 assert_equal 5, h1.size
202 202
203 203 @repository.fetch_changesets
204 204 @project.reload
205 205 assert_equal NUM_REV - 5, @repository.changesets.count
206 206 h2 = @repository.extra_info["heads"].dup
207 207 assert_equal h1, h2
208 208 end
209 209
210 210 def test_parents
211 211 assert_equal 0, @repository.changesets.count
212 212 @repository.fetch_changesets
213 213 @project.reload
214 214 assert_equal NUM_REV, @repository.changesets.count
215 215 r1 = @repository.find_changeset_by_name("7234cb2750b63")
216 216 assert_equal [], r1.parents
217 217 r2 = @repository.find_changeset_by_name("899a15dba03a3")
218 218 assert_equal 1, r2.parents.length
219 219 assert_equal "7234cb2750b63f47bff735edc50a1c0a433c2518",
220 220 r2.parents[0].identifier
221 221 r3 = @repository.find_changeset_by_name("32ae898b720c2")
222 222 assert_equal 2, r3.parents.length
223 223 r4 = [r3.parents[0].identifier, r3.parents[1].identifier].sort
224 224 assert_equal "4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8", r4[0]
225 225 assert_equal "7e61ac704deecde634b51e59daa8110435dcb3da", r4[1]
226 226 end
227 227
228 228 def test_db_consistent_ordering_init
229 229 assert_nil @repository.extra_info
230 230 assert_equal 0, @repository.changesets.count
231 231 @repository.fetch_changesets
232 232 @project.reload
233 233 assert_equal 1, @repository.extra_info["db_consistent"]["ordering"]
234 234 end
235 235
236 236 def test_db_consistent_ordering_before_1_2
237 237 assert_nil @repository.extra_info
238 238 assert_equal 0, @repository.changesets.count
239 239 @repository.fetch_changesets
240 240 @project.reload
241 241 assert_equal NUM_REV, @repository.changesets.count
242 242 assert_not_nil @repository.extra_info
243 243 h = {}
244 244 h["heads"] = []
245 245 h["branches"] = {}
246 246 h["db_consistent"] = {}
247 247 @repository.merge_extra_info(h)
248 248 @repository.save
249 249 assert_equal NUM_REV, @repository.changesets.count
250 250 @repository.fetch_changesets
251 251 @project.reload
252 252 assert_equal 0, @repository.extra_info["db_consistent"]["ordering"]
253 253
254 254 extra_info_heads = @repository.extra_info["heads"].dup
255 255 extra_info_heads.delete_if { |x| x == "83ca5fd546063a3c7dc2e568ba3355661a9e2b2c" }
256 256 del_revs = [
257 257 "83ca5fd546063a3c7dc2e568ba3355661a9e2b2c",
258 258 "ed5bb786bbda2dee66a2d50faf51429dbc043a7b",
259 259 "4f26664364207fa8b1af9f8722647ab2d4ac5d43",
260 260 "deff712f05a90d96edbd70facc47d944be5897e3",
261 261 "32ae898b720c2f7eec2723d5bdd558b4cb2d3ddf",
262 262 "7e61ac704deecde634b51e59daa8110435dcb3da",
263 263 ]
264 264 @repository.changesets.each do |rev|
265 265 rev.destroy if del_revs.detect {|r| r == rev.scmid.to_s }
266 266 end
267 267 @project.reload
268 268 cs1 = @repository.changesets
269 269 assert_equal NUM_REV - 6, cs1.count
270 270 assert_equal 0, @repository.extra_info["db_consistent"]["ordering"]
271 271
272 272 extra_info_heads << "4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8"
273 273 h = {}
274 274 h["heads"] = extra_info_heads
275 275 @repository.merge_extra_info(h)
276 276 @repository.save
277 277 @project.reload
278 278 assert @repository.extra_info["heads"].index("4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8")
279 279 @repository.fetch_changesets
280 280 @project.reload
281 281 assert_equal NUM_REV, @repository.changesets.count
282 282 assert_equal NUM_HEAD, @repository.extra_info["heads"].size
283 283
284 284 assert_equal 0, @repository.extra_info["db_consistent"]["ordering"]
285 285 end
286 286
287 287 def test_heads_from_branches_hash
288 288 assert_nil @repository.extra_info
289 289 assert_equal 0, @repository.changesets.count
290 290 assert_equal [], @repository.heads_from_branches_hash
291 291 h = {}
292 292 h["branches"] = {}
293 293 h["branches"]["test1"] = {}
294 294 h["branches"]["test1"]["last_scmid"] = "1234abcd"
295 295 h["branches"]["test2"] = {}
296 296 h["branches"]["test2"]["last_scmid"] = "abcd1234"
297 297 @repository.merge_extra_info(h)
298 298 @repository.save
299 299 @project.reload
300 300 assert_equal ["1234abcd", "abcd1234"], @repository.heads_from_branches_hash.sort
301 301 end
302 302
303 303 def test_latest_changesets
304 304 assert_equal 0, @repository.changesets.count
305 305 @repository.fetch_changesets
306 306 @project.reload
307 307 assert_equal NUM_REV, @repository.changesets.count
308 308 # with limit
309 309 changesets = @repository.latest_changesets('', 'master', 2)
310 310 assert_equal 2, changesets.size
311 311
312 312 # with path
313 313 changesets = @repository.latest_changesets('images', 'master')
314 314 assert_equal [
315 315 'deff712f05a90d96edbd70facc47d944be5897e3',
316 316 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
317 317 '7234cb2750b63f47bff735edc50a1c0a433c2518',
318 318 ], changesets.collect(&:revision)
319 319
320 320 changesets = @repository.latest_changesets('README', nil)
321 321 assert_equal [
322 322 '32ae898b720c2f7eec2723d5bdd558b4cb2d3ddf',
323 323 '4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8',
324 324 '713f4944648826f558cf548222f813dabe7cbb04',
325 325 '61b685fbe55ab05b5ac68402d5720c1a6ac973d1',
326 326 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
327 327 '7234cb2750b63f47bff735edc50a1c0a433c2518',
328 328 ], changesets.collect(&:revision)
329 329
330 330 # with path, revision and limit
331 331 changesets = @repository.latest_changesets('images', '899a15dba')
332 332 assert_equal [
333 333 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
334 334 '7234cb2750b63f47bff735edc50a1c0a433c2518',
335 335 ], changesets.collect(&:revision)
336 336
337 337 changesets = @repository.latest_changesets('images', '899a15dba', 1)
338 338 assert_equal [
339 339 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
340 340 ], changesets.collect(&:revision)
341 341
342 342 changesets = @repository.latest_changesets('README', '899a15dba')
343 343 assert_equal [
344 344 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
345 345 '7234cb2750b63f47bff735edc50a1c0a433c2518',
346 346 ], changesets.collect(&:revision)
347 347
348 348 changesets = @repository.latest_changesets('README', '899a15dba', 1)
349 349 assert_equal [
350 350 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
351 351 ], changesets.collect(&:revision)
352 352
353 353 # with path, tag and limit
354 354 changesets = @repository.latest_changesets('images', 'tag01.annotated')
355 355 assert_equal [
356 356 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
357 357 '7234cb2750b63f47bff735edc50a1c0a433c2518',
358 358 ], changesets.collect(&:revision)
359 359
360 360 changesets = @repository.latest_changesets('images', 'tag01.annotated', 1)
361 361 assert_equal [
362 362 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
363 363 ], changesets.collect(&:revision)
364 364
365 365 changesets = @repository.latest_changesets('README', 'tag01.annotated')
366 366 assert_equal [
367 367 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
368 368 '7234cb2750b63f47bff735edc50a1c0a433c2518',
369 369 ], changesets.collect(&:revision)
370 370
371 371 changesets = @repository.latest_changesets('README', 'tag01.annotated', 1)
372 372 assert_equal [
373 373 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
374 374 ], changesets.collect(&:revision)
375 375
376 376 # with path, branch and limit
377 377 changesets = @repository.latest_changesets('images', 'test_branch')
378 378 assert_equal [
379 379 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
380 380 '7234cb2750b63f47bff735edc50a1c0a433c2518',
381 381 ], changesets.collect(&:revision)
382 382
383 383 changesets = @repository.latest_changesets('images', 'test_branch', 1)
384 384 assert_equal [
385 385 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
386 386 ], changesets.collect(&:revision)
387 387
388 388 changesets = @repository.latest_changesets('README', 'test_branch')
389 389 assert_equal [
390 390 '713f4944648826f558cf548222f813dabe7cbb04',
391 391 '61b685fbe55ab05b5ac68402d5720c1a6ac973d1',
392 392 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
393 393 '7234cb2750b63f47bff735edc50a1c0a433c2518',
394 394 ], changesets.collect(&:revision)
395 395
396 396 changesets = @repository.latest_changesets('README', 'test_branch', 2)
397 397 assert_equal [
398 398 '713f4944648826f558cf548222f813dabe7cbb04',
399 399 '61b685fbe55ab05b5ac68402d5720c1a6ac973d1',
400 400 ], changesets.collect(&:revision)
401 401
402 402 if JRUBY_SKIP
403 403 puts JRUBY_SKIP_STR
404 404 else
405 405 # latin-1 encoding path
406 406 changesets = @repository.latest_changesets(
407 407 "latin-1-dir/test-#{@char_1}-2.txt", '64f1f3e89')
408 408 assert_equal [
409 409 '64f1f3e89ad1cb57976ff0ad99a107012ba3481d',
410 410 '4fc55c43bf3d3dc2efb66145365ddc17639ce81e',
411 411 ], changesets.collect(&:revision)
412 412
413 413 changesets = @repository.latest_changesets(
414 414 "latin-1-dir/test-#{@char_1}-2.txt", '64f1f3e89', 1)
415 415 assert_equal [
416 416 '64f1f3e89ad1cb57976ff0ad99a107012ba3481d',
417 417 ], changesets.collect(&:revision)
418 418 end
419 419 end
420 420
421 421 def test_latest_changesets_latin_1_dir
422 422 if WINDOWS_PASS
423 423 #
424 424 elsif JRUBY_SKIP
425 425 puts JRUBY_SKIP_STR
426 426 else
427 427 assert_equal 0, @repository.changesets.count
428 428 @repository.fetch_changesets
429 429 @project.reload
430 430 assert_equal NUM_REV, @repository.changesets.count
431 431 changesets = @repository.latest_changesets(
432 432 "latin-1-dir/test-#{@char_1}-subdir", '1ca7f5ed')
433 433 assert_equal [
434 434 '1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127',
435 435 ], changesets.collect(&:revision)
436 436 end
437 437 end
438 438
439 439 def test_find_changeset_by_name
440 440 assert_equal 0, @repository.changesets.count
441 441 @repository.fetch_changesets
442 442 @project.reload
443 443 assert_equal NUM_REV, @repository.changesets.count
444 444 ['7234cb2750b63f47bff735edc50a1c0a433c2518', '7234cb2750b'].each do |r|
445 445 assert_equal '7234cb2750b63f47bff735edc50a1c0a433c2518',
446 446 @repository.find_changeset_by_name(r).revision
447 447 end
448 448 end
449 449
450 450 def test_find_changeset_by_empty_name
451 451 assert_equal 0, @repository.changesets.count
452 452 @repository.fetch_changesets
453 453 @project.reload
454 454 assert_equal NUM_REV, @repository.changesets.count
455 455 ['', ' ', nil].each do |r|
456 456 assert_nil @repository.find_changeset_by_name(r)
457 457 end
458 458 end
459 459
460 460 def test_identifier
461 461 assert_equal 0, @repository.changesets.count
462 462 @repository.fetch_changesets
463 463 @project.reload
464 464 assert_equal NUM_REV, @repository.changesets.count
465 465 c = @repository.changesets.find_by_revision(
466 466 '7234cb2750b63f47bff735edc50a1c0a433c2518')
467 467 assert_equal c.scmid, c.identifier
468 468 end
469 469
470 470 def test_format_identifier
471 471 assert_equal 0, @repository.changesets.count
472 472 @repository.fetch_changesets
473 473 @project.reload
474 474 assert_equal NUM_REV, @repository.changesets.count
475 475 c = @repository.changesets.find_by_revision(
476 476 '7234cb2750b63f47bff735edc50a1c0a433c2518')
477 477 assert_equal '7234cb27', c.format_identifier
478 478 end
479 479
480 480 def test_activities
481 481 c = Changeset.new(:repository => @repository,
482 482 :committed_on => Time.now,
483 483 :revision => 'abc7234cb2750b63f47bff735edc50a1c0a433c2',
484 484 :scmid => 'abc7234cb2750b63f47bff735edc50a1c0a433c2',
485 485 :comments => 'test')
486 486 assert c.event_title.include?('abc7234c:')
487 487 assert_equal 'abc7234cb2750b63f47bff735edc50a1c0a433c2', c.event_url[:rev]
488 488 end
489 489
490 490 def test_log_utf8
491 491 assert_equal 0, @repository.changesets.count
492 492 @repository.fetch_changesets
493 493 @project.reload
494 494 assert_equal NUM_REV, @repository.changesets.count
495 495 str_felix_hex = FELIX_HEX.dup
496 496 if str_felix_hex.respond_to?(:force_encoding)
497 497 str_felix_hex.force_encoding('UTF-8')
498 498 end
499 499 c = @repository.changesets.find_by_revision(
500 500 'ed5bb786bbda2dee66a2d50faf51429dbc043a7b')
501 501 assert_equal "#{str_felix_hex} <felix@fachschaften.org>", c.committer
502 502 end
503 503
504 504 def test_previous
505 505 assert_equal 0, @repository.changesets.count
506 506 @repository.fetch_changesets
507 507 @project.reload
508 508 assert_equal NUM_REV, @repository.changesets.count
509 509 %w|1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127 1ca7f5ed|.each do |r1|
510 510 changeset = @repository.find_changeset_by_name(r1)
511 511 %w|64f1f3e89ad1cb57976ff0ad99a107012ba3481d 64f1f3e89ad1|.each do |r2|
512 512 assert_equal @repository.find_changeset_by_name(r2), changeset.previous
513 513 end
514 514 end
515 515 end
516 516
517 517 def test_previous_nil
518 518 assert_equal 0, @repository.changesets.count
519 519 @repository.fetch_changesets
520 520 @project.reload
521 521 assert_equal NUM_REV, @repository.changesets.count
522 522 %w|7234cb2750b63f47bff735edc50a1c0a433c2518 7234cb275|.each do |r1|
523 523 changeset = @repository.find_changeset_by_name(r1)
524 524 assert_nil changeset.previous
525 525 end
526 526 end
527 527
528 528 def test_next
529 529 assert_equal 0, @repository.changesets.count
530 530 @repository.fetch_changesets
531 531 @project.reload
532 532 assert_equal NUM_REV, @repository.changesets.count
533 533 %w|64f1f3e89ad1cb57976ff0ad99a107012ba3481d 64f1f3e89ad1|.each do |r2|
534 534 changeset = @repository.find_changeset_by_name(r2)
535 535 %w|1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127 1ca7f5ed|.each do |r1|
536 536 assert_equal @repository.find_changeset_by_name(r1), changeset.next
537 537 end
538 538 end
539 539 end
540 540
541 541 def test_next_nil
542 542 assert_equal 0, @repository.changesets.count
543 543 @repository.fetch_changesets
544 544 @project.reload
545 545 assert_equal NUM_REV, @repository.changesets.count
546 546 %w|2a682156a3b6e77a8bf9cd4590e8db757f3c6c78 2a682156a3b6e77a|.each do |r1|
547 547 changeset = @repository.find_changeset_by_name(r1)
548 548 assert_nil changeset.next
549 549 end
550 550 end
551 551 else
552 552 puts "Git test repository NOT FOUND. Skipping unit tests !!!"
553 553 def test_fake; assert true end
554 554 end
555 555 end
General Comments 0
You need to be logged in to leave comments. Login now