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