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