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