@@ -1,437 +1,433 | |||
|
1 | 1 | # encoding: utf-8 |
|
2 | 2 | |
|
3 | 3 | # This file includes UTF-8 "Felix Schäfer". |
|
4 | 4 | # We need to consider Ruby 1.9 compatibility. |
|
5 | 5 | |
|
6 | 6 | require File.expand_path('../../../../../../test_helper', __FILE__) |
|
7 | 7 | begin |
|
8 | 8 | require 'mocha' |
|
9 | 9 | |
|
10 | 10 | class GitAdapterTest < ActiveSupport::TestCase |
|
11 | 11 | REPOSITORY_PATH = Rails.root.join('tmp/test/git_repository').to_s |
|
12 | 12 | |
|
13 | 13 | FELIX_UTF8 = "Felix Schäfer" |
|
14 | 14 | FELIX_HEX = "Felix Sch\xC3\xA4fer" |
|
15 | 15 | CHAR_1_HEX = "\xc3\x9c" |
|
16 | 16 | |
|
17 | 17 | ## Ruby uses ANSI api to fork a process on Windows. |
|
18 | 18 | ## Japanese Shift_JIS and Traditional Chinese Big5 have 0x5c(backslash) problem |
|
19 | 19 | ## and these are incompatible with ASCII. |
|
20 | 20 | # WINDOWS_PASS = Redmine::Platform.mswin? |
|
21 | 21 | WINDOWS_PASS = false |
|
22 | 22 | |
|
23 | 23 | ## Git, Mercurial and CVS path encodings are binary. |
|
24 | 24 | ## Subversion supports URL encoding for path. |
|
25 | 25 | ## Redmine Mercurial adapter and extension use URL encoding. |
|
26 | 26 | ## Git accepts only binary path in command line parameter. |
|
27 | 27 | ## So, there is no way to use binary command line parameter in JRuby. |
|
28 | 28 | JRUBY_SKIP = (RUBY_PLATFORM == 'java') |
|
29 | 29 | JRUBY_SKIP_STR = "TODO: This test fails in JRuby" |
|
30 | 30 | |
|
31 | 31 | if File.directory?(REPOSITORY_PATH) |
|
32 | 32 | def setup |
|
33 | 33 | adapter_class = Redmine::Scm::Adapters::GitAdapter |
|
34 | 34 | assert adapter_class |
|
35 | 35 | assert adapter_class.client_command |
|
36 | 36 | assert_equal true, adapter_class.client_available |
|
37 | 37 | assert_equal true, adapter_class.client_version_above?([1]) |
|
38 | 38 | assert_equal true, adapter_class.client_version_above?([1, 0]) |
|
39 | 39 | |
|
40 | 40 | @adapter = Redmine::Scm::Adapters::GitAdapter.new( |
|
41 | 41 | REPOSITORY_PATH, |
|
42 | 42 | nil, |
|
43 | 43 | nil, |
|
44 | 44 | nil, |
|
45 | 45 | 'ISO-8859-1' |
|
46 | 46 | ) |
|
47 | 47 | assert @adapter |
|
48 | 48 | @char_1 = CHAR_1_HEX.dup |
|
49 | 49 | if @char_1.respond_to?(:force_encoding) |
|
50 | 50 | @char_1.force_encoding('UTF-8') |
|
51 | 51 | end |
|
52 | 52 | end |
|
53 | 53 | |
|
54 | 54 | def test_scm_version |
|
55 | 55 | to_test = { "git version 1.7.3.4\n" => [1,7,3,4], |
|
56 | 56 | "1.6.1\n1.7\n1.8" => [1,6,1], |
|
57 | 57 | "1.6.2\r\n1.8.1\r\n1.9.1" => [1,6,2]} |
|
58 | 58 | to_test.each do |s, v| |
|
59 | 59 | test_scm_version_for(s, v) |
|
60 | 60 | end |
|
61 | 61 | end |
|
62 | 62 | |
|
63 | 63 | def test_branches |
|
64 | 64 | brs = [] |
|
65 | 65 | @adapter.branches.each do |b| |
|
66 | 66 | brs << b |
|
67 | 67 | end |
|
68 | 68 | assert_equal 4, brs.length |
|
69 | 69 | assert_equal 'latin-1-path-encoding', brs[0].to_s |
|
70 | 70 | assert_equal '1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127', brs[0].revision |
|
71 | 71 | assert_equal brs[0].scmid, brs[0].revision |
|
72 | 72 | assert_equal 'master', brs[1].to_s |
|
73 | 73 | assert_equal '83ca5fd546063a3c7dc2e568ba3355661a9e2b2c', brs[1].revision |
|
74 | 74 | assert_equal brs[1].scmid, brs[1].revision |
|
75 | 75 | assert_equal 'test-latin-1', brs[2].to_s |
|
76 | 76 | assert_equal '67e7792ce20ccae2e4bb73eed09bb397819c8834', brs[2].revision |
|
77 | 77 | assert_equal brs[2].scmid, brs[2].revision |
|
78 | 78 | assert_equal 'test_branch', brs[3].to_s |
|
79 | 79 | assert_equal 'fba357b886984ee71185ad2065e65fc0417d9b92', brs[3].revision |
|
80 | 80 | assert_equal brs[3].scmid, brs[3].revision |
|
81 | 81 | end |
|
82 | 82 | |
|
83 | 83 | def test_tags |
|
84 | 84 | assert_equal [ |
|
85 | 85 | "tag00.lightweight", |
|
86 | 86 | "tag01.annotated", |
|
87 | 87 | ], @adapter.tags |
|
88 | 88 | end |
|
89 | 89 | |
|
90 | 90 | def test_getting_all_revisions |
|
91 | 91 | assert_equal 21, @adapter.revisions('',nil,nil,:all => true).length |
|
92 | 92 | end |
|
93 | 93 | |
|
94 | def test_getting_certain_revisions | |
|
95 | assert_equal 1, @adapter.revisions('','899a15d^','899a15d').length | |
|
96 | end | |
|
97 | ||
|
98 | 94 | def test_revisions_reverse |
|
99 | 95 | revs1 = @adapter.revisions('',nil,nil,{:all => true, :reverse => true }) |
|
100 | 96 | assert_equal 21, revs1.length |
|
101 | 97 | assert_equal '7234cb2750b63f47bff735edc50a1c0a433c2518', revs1[0].identifier |
|
102 | 98 | assert_equal '1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127', revs1[20].identifier |
|
103 | 99 | end |
|
104 | 100 | |
|
105 | 101 | def test_revisions_master_all |
|
106 | 102 | revs1 = [] |
|
107 | 103 | @adapter.revisions('', nil, "master",{}) do |rev| |
|
108 | 104 | revs1 << rev |
|
109 | 105 | end |
|
110 | 106 | assert_equal 15, revs1.length |
|
111 | 107 | assert_equal '83ca5fd546063a3c7dc2e568ba3355661a9e2b2c', revs1[ 0].identifier |
|
112 | 108 | assert_equal '7234cb2750b63f47bff735edc50a1c0a433c2518', revs1[-1].identifier |
|
113 | 109 | |
|
114 | 110 | revs2 = [] |
|
115 | 111 | @adapter.revisions('', nil, "master", |
|
116 | 112 | {:reverse => true}) do |rev| |
|
117 | 113 | revs2 << rev |
|
118 | 114 | end |
|
119 | 115 | assert_equal 15, revs2.length |
|
120 | 116 | assert_equal '83ca5fd546063a3c7dc2e568ba3355661a9e2b2c', revs2[-1].identifier |
|
121 | 117 | assert_equal '7234cb2750b63f47bff735edc50a1c0a433c2518', revs2[ 0].identifier |
|
122 | 118 | end |
|
123 | 119 | |
|
124 | 120 | def test_revisions_master_merged_rev |
|
125 | 121 | revs1 = [] |
|
126 | 122 | @adapter.revisions('', |
|
127 | 123 | "713f4944648826f558cf548222f813dabe7cbb04", |
|
128 | 124 | "master", |
|
129 | 125 | {:reverse => true}) do |rev| |
|
130 | 126 | revs1 << rev |
|
131 | 127 | end |
|
132 | 128 | assert_equal 8, revs1.length |
|
133 | 129 | assert_equal 'fba357b886984ee71185ad2065e65fc0417d9b92', revs1[ 0].identifier |
|
134 | 130 | assert_equal '7e61ac704deecde634b51e59daa8110435dcb3da', revs1[ 1].identifier |
|
135 | 131 | # 4a07fe31b is not a child of 713f49446 |
|
136 | 132 | assert_equal '4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8', revs1[ 2].identifier |
|
137 | 133 | # Merged revision |
|
138 | 134 | assert_equal '32ae898b720c2f7eec2723d5bdd558b4cb2d3ddf', revs1[ 3].identifier |
|
139 | 135 | assert_equal '83ca5fd546063a3c7dc2e568ba3355661a9e2b2c', revs1[-1].identifier |
|
140 | 136 | |
|
141 | 137 | revs2 = [] |
|
142 | 138 | @adapter.revisions('', |
|
143 | 139 | "fba357b886984ee71185ad2065e65fc0417d9b92", |
|
144 | 140 | "master", |
|
145 | 141 | {:reverse => true}) do |rev| |
|
146 | 142 | revs2 << rev |
|
147 | 143 | end |
|
148 | 144 | assert_equal 7, revs2.length |
|
149 | 145 | assert_equal '7e61ac704deecde634b51e59daa8110435dcb3da', revs2[ 0].identifier |
|
150 | 146 | # 4a07fe31b is not a child of fba357b8869 |
|
151 | 147 | assert_equal '4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8', revs2[ 1].identifier |
|
152 | 148 | # Merged revision |
|
153 | 149 | assert_equal '32ae898b720c2f7eec2723d5bdd558b4cb2d3ddf', revs2[ 2].identifier |
|
154 | 150 | assert_equal '83ca5fd546063a3c7dc2e568ba3355661a9e2b2c', revs2[-1].identifier |
|
155 | 151 | end |
|
156 | 152 | |
|
157 | 153 | def test_revisions_branch_latin_1_path_encoding_all |
|
158 | 154 | revs1 = [] |
|
159 | 155 | @adapter.revisions('', nil, "latin-1-path-encoding",{}) do |rev| |
|
160 | 156 | revs1 << rev |
|
161 | 157 | end |
|
162 | 158 | assert_equal 8, revs1.length |
|
163 | 159 | assert_equal '1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127', revs1[ 0].identifier |
|
164 | 160 | assert_equal '7234cb2750b63f47bff735edc50a1c0a433c2518', revs1[-1].identifier |
|
165 | 161 | |
|
166 | 162 | revs2 = [] |
|
167 | 163 | @adapter.revisions('', nil, "latin-1-path-encoding", |
|
168 | 164 | {:reverse => true}) do |rev| |
|
169 | 165 | revs2 << rev |
|
170 | 166 | end |
|
171 | 167 | assert_equal 8, revs2.length |
|
172 | 168 | assert_equal '1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127', revs2[-1].identifier |
|
173 | 169 | assert_equal '7234cb2750b63f47bff735edc50a1c0a433c2518', revs2[ 0].identifier |
|
174 | 170 | end |
|
175 | 171 | |
|
176 | 172 | def test_revisions_branch_latin_1_path_encoding_with_rev |
|
177 | 173 | revs1 = [] |
|
178 | 174 | @adapter.revisions('', |
|
179 | 175 | '7234cb2750b63f47bff735edc50a1c0a433c2518', |
|
180 | 176 | "latin-1-path-encoding", |
|
181 | 177 | {:reverse => true}) do |rev| |
|
182 | 178 | revs1 << rev |
|
183 | 179 | end |
|
184 | 180 | assert_equal 7, revs1.length |
|
185 | 181 | assert_equal '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', revs1[ 0].identifier |
|
186 | 182 | assert_equal '1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127', revs1[-1].identifier |
|
187 | 183 | |
|
188 | 184 | revs2 = [] |
|
189 | 185 | @adapter.revisions('', |
|
190 | 186 | '57ca437c0acbbcb749821fdf3726a1367056d364', |
|
191 | 187 | "latin-1-path-encoding", |
|
192 | 188 | {:reverse => true}) do |rev| |
|
193 | 189 | revs2 << rev |
|
194 | 190 | end |
|
195 | 191 | assert_equal 3, revs2.length |
|
196 | 192 | assert_equal '4fc55c43bf3d3dc2efb66145365ddc17639ce81e', revs2[ 0].identifier |
|
197 | 193 | assert_equal '1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127', revs2[-1].identifier |
|
198 | 194 | end |
|
199 | 195 | |
|
200 | 196 | def test_revisions_invalid_rev |
|
201 | 197 | revs1 = [] |
|
202 | 198 | @adapter.revisions('', |
|
203 | 199 | '1234abcd', |
|
204 | 200 | "master", |
|
205 | 201 | {:reverse => true}) do |rev| |
|
206 | 202 | revs1 << rev |
|
207 | 203 | end |
|
208 | 204 | assert_equal [], revs1 |
|
209 | 205 | end |
|
210 | 206 | |
|
211 | 207 | def test_getting_revisions_with_spaces_in_filename |
|
212 | 208 | assert_equal 1, @adapter.revisions("filemane with spaces.txt", |
|
213 | 209 | nil, nil, :all => true).length |
|
214 | 210 | end |
|
215 | 211 | |
|
216 | 212 | def test_parents |
|
217 | 213 | revs1 = [] |
|
218 | 214 | @adapter.revisions('', |
|
219 | 215 | nil, |
|
220 | 216 | "master", |
|
221 | 217 | {:reverse => true}) do |rev| |
|
222 | 218 | revs1 << rev |
|
223 | 219 | end |
|
224 | 220 | assert_equal 15, revs1.length |
|
225 | 221 | assert_equal "7234cb2750b63f47bff735edc50a1c0a433c2518", |
|
226 | 222 | revs1[0].identifier |
|
227 | 223 | assert_equal nil, revs1[0].parents |
|
228 | 224 | assert_equal "899a15dba03a3b350b89c3f537e4bbe02a03cdc9", |
|
229 | 225 | revs1[1].identifier |
|
230 | 226 | assert_equal 1, revs1[1].parents.length |
|
231 | 227 | assert_equal "7234cb2750b63f47bff735edc50a1c0a433c2518", |
|
232 | 228 | revs1[1].parents[0] |
|
233 | 229 | assert_equal "32ae898b720c2f7eec2723d5bdd558b4cb2d3ddf", |
|
234 | 230 | revs1[10].identifier |
|
235 | 231 | assert_equal 2, revs1[10].parents.length |
|
236 | 232 | assert_equal "4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8", |
|
237 | 233 | revs1[10].parents[0] |
|
238 | 234 | assert_equal "7e61ac704deecde634b51e59daa8110435dcb3da", |
|
239 | 235 | revs1[10].parents[1] |
|
240 | 236 | end |
|
241 | 237 | |
|
242 | 238 | def test_getting_revisions_with_leading_and_trailing_spaces_in_filename |
|
243 | 239 | assert_equal " filename with a leading space.txt ", |
|
244 | 240 | @adapter.revisions(" filename with a leading space.txt ", |
|
245 | 241 | nil, nil, :all => true)[0].paths[0][:path] |
|
246 | 242 | end |
|
247 | 243 | |
|
248 | 244 | def test_getting_entries_with_leading_and_trailing_spaces_in_filename |
|
249 | 245 | assert_equal " filename with a leading space.txt ", |
|
250 | 246 | @adapter.entries('', |
|
251 | 247 | '83ca5fd546063a3c7dc2e568ba3355661a9e2b2c')[3].name |
|
252 | 248 | end |
|
253 | 249 | |
|
254 | 250 | def test_annotate |
|
255 | 251 | annotate = @adapter.annotate('sources/watchers_controller.rb') |
|
256 | 252 | assert_kind_of Redmine::Scm::Adapters::Annotate, annotate |
|
257 | 253 | assert_equal 41, annotate.lines.size |
|
258 | 254 | assert_equal "# This program is free software; you can redistribute it and/or", |
|
259 | 255 | annotate.lines[4].strip |
|
260 | 256 | assert_equal "7234cb2750b63f47bff735edc50a1c0a433c2518", |
|
261 | 257 | annotate.revisions[4].identifier |
|
262 | 258 | assert_equal "jsmith", annotate.revisions[4].author |
|
263 | 259 | end |
|
264 | 260 | |
|
265 | 261 | def test_annotate_moved_file |
|
266 | 262 | annotate = @adapter.annotate('renamed_test.txt') |
|
267 | 263 | assert_kind_of Redmine::Scm::Adapters::Annotate, annotate |
|
268 | 264 | assert_equal 2, annotate.lines.size |
|
269 | 265 | end |
|
270 | 266 | |
|
271 | 267 | def test_last_rev |
|
272 | 268 | last_rev = @adapter.lastrev("README", |
|
273 | 269 | "4f26664364207fa8b1af9f8722647ab2d4ac5d43") |
|
274 | 270 | assert_equal "4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8", last_rev.scmid |
|
275 | 271 | assert_equal "4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8", last_rev.identifier |
|
276 | 272 | assert_equal "Adam Soltys <asoltys@gmail.com>", last_rev.author |
|
277 | 273 | assert_equal "2009-06-24 05:27:38".to_time, last_rev.time |
|
278 | 274 | end |
|
279 | 275 | |
|
280 | 276 | def test_last_rev_with_spaces_in_filename |
|
281 | 277 | last_rev = @adapter.lastrev("filemane with spaces.txt", |
|
282 | 278 | "ed5bb786bbda2dee66a2d50faf51429dbc043a7b") |
|
283 | 279 | str_felix_utf8 = FELIX_UTF8.dup |
|
284 | 280 | str_felix_hex = FELIX_HEX.dup |
|
285 | 281 | last_rev_author = last_rev.author |
|
286 | 282 | if last_rev_author.respond_to?(:force_encoding) |
|
287 | 283 | last_rev_author.force_encoding('UTF-8') |
|
288 | 284 | end |
|
289 | 285 | assert_equal "ed5bb786bbda2dee66a2d50faf51429dbc043a7b", last_rev.scmid |
|
290 | 286 | assert_equal "ed5bb786bbda2dee66a2d50faf51429dbc043a7b", last_rev.identifier |
|
291 | 287 | assert_equal "#{str_felix_utf8} <felix@fachschaften.org>", |
|
292 | 288 | last_rev.author |
|
293 | 289 | assert_equal "#{str_felix_hex} <felix@fachschaften.org>", |
|
294 | 290 | last_rev.author |
|
295 | 291 | assert_equal "2010-09-18 19:59:46".to_time, last_rev.time |
|
296 | 292 | end |
|
297 | 293 | |
|
298 | 294 | def test_latin_1_path |
|
299 | 295 | if WINDOWS_PASS |
|
300 | 296 | # |
|
301 | 297 | elsif JRUBY_SKIP |
|
302 | 298 | puts JRUBY_SKIP_STR |
|
303 | 299 | else |
|
304 | 300 | p2 = "latin-1-dir/test-#{@char_1}-2.txt" |
|
305 | 301 | ['4fc55c43bf3d3dc2efb66145365ddc17639ce81e', '4fc55c43bf3'].each do |r1| |
|
306 | 302 | assert @adapter.diff(p2, r1) |
|
307 | 303 | assert @adapter.cat(p2, r1) |
|
308 | 304 | assert_equal 1, @adapter.annotate(p2, r1).lines.length |
|
309 | 305 | ['64f1f3e89ad1cb57976ff0ad99a107012ba3481d', '64f1f3e89ad1cb5797'].each do |r2| |
|
310 | 306 | assert @adapter.diff(p2, r1, r2) |
|
311 | 307 | end |
|
312 | 308 | end |
|
313 | 309 | end |
|
314 | 310 | end |
|
315 | 311 | |
|
316 | 312 | def test_entries_tag |
|
317 | 313 | entries1 = @adapter.entries(nil, 'tag01.annotated', |
|
318 | 314 | options = {:report_last_commit => true}) |
|
319 | 315 | assert entries1 |
|
320 | 316 | assert_equal 3, entries1.size |
|
321 | 317 | assert_equal 'sources', entries1[1].name |
|
322 | 318 | assert_equal 'sources', entries1[1].path |
|
323 | 319 | assert_equal 'dir', entries1[1].kind |
|
324 | 320 | readme = entries1[2] |
|
325 | 321 | assert_equal 'README', readme.name |
|
326 | 322 | assert_equal 'README', readme.path |
|
327 | 323 | assert_equal 'file', readme.kind |
|
328 | 324 | assert_equal 27, readme.size |
|
329 | 325 | assert_equal '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', readme.lastrev.identifier |
|
330 | 326 | assert_equal Time.gm(2007, 12, 14, 9, 24, 1), readme.lastrev.time |
|
331 | 327 | end |
|
332 | 328 | |
|
333 | 329 | def test_entries_branch |
|
334 | 330 | entries1 = @adapter.entries(nil, 'test_branch', |
|
335 | 331 | options = {:report_last_commit => true}) |
|
336 | 332 | assert entries1 |
|
337 | 333 | assert_equal 4, entries1.size |
|
338 | 334 | assert_equal 'sources', entries1[1].name |
|
339 | 335 | assert_equal 'sources', entries1[1].path |
|
340 | 336 | assert_equal 'dir', entries1[1].kind |
|
341 | 337 | readme = entries1[2] |
|
342 | 338 | assert_equal 'README', readme.name |
|
343 | 339 | assert_equal 'README', readme.path |
|
344 | 340 | assert_equal 'file', readme.kind |
|
345 | 341 | assert_equal 159, readme.size |
|
346 | 342 | assert_equal '713f4944648826f558cf548222f813dabe7cbb04', readme.lastrev.identifier |
|
347 | 343 | assert_equal Time.gm(2009, 6, 19, 4, 37, 23), readme.lastrev.time |
|
348 | 344 | end |
|
349 | 345 | |
|
350 | 346 | def test_entries_latin_1_files |
|
351 | 347 | entries1 = @adapter.entries('latin-1-dir', '64f1f3e8') |
|
352 | 348 | assert entries1 |
|
353 | 349 | assert_equal 3, entries1.size |
|
354 | 350 | f1 = entries1[1] |
|
355 | 351 | assert_equal "test-#{@char_1}-2.txt", f1.name |
|
356 | 352 | assert_equal "latin-1-dir/test-#{@char_1}-2.txt", f1.path |
|
357 | 353 | assert_equal 'file', f1.kind |
|
358 | 354 | end |
|
359 | 355 | |
|
360 | 356 | def test_entries_latin_1_dir |
|
361 | 357 | if WINDOWS_PASS |
|
362 | 358 | # |
|
363 | 359 | elsif JRUBY_SKIP |
|
364 | 360 | puts JRUBY_SKIP_STR |
|
365 | 361 | else |
|
366 | 362 | entries1 = @adapter.entries("latin-1-dir/test-#{@char_1}-subdir", |
|
367 | 363 | '1ca7f5ed') |
|
368 | 364 | assert entries1 |
|
369 | 365 | assert_equal 3, entries1.size |
|
370 | 366 | f1 = entries1[1] |
|
371 | 367 | assert_equal "test-#{@char_1}-2.txt", f1.name |
|
372 | 368 | assert_equal "latin-1-dir/test-#{@char_1}-subdir/test-#{@char_1}-2.txt", f1.path |
|
373 | 369 | assert_equal 'file', f1.kind |
|
374 | 370 | end |
|
375 | 371 | end |
|
376 | 372 | |
|
377 | 373 | def test_path_encoding_default_utf8 |
|
378 | 374 | adpt1 = Redmine::Scm::Adapters::GitAdapter.new( |
|
379 | 375 | REPOSITORY_PATH |
|
380 | 376 | ) |
|
381 | 377 | assert_equal "UTF-8", adpt1.path_encoding |
|
382 | 378 | adpt2 = Redmine::Scm::Adapters::GitAdapter.new( |
|
383 | 379 | REPOSITORY_PATH, |
|
384 | 380 | nil, |
|
385 | 381 | nil, |
|
386 | 382 | nil, |
|
387 | 383 | "" |
|
388 | 384 | ) |
|
389 | 385 | assert_equal "UTF-8", adpt2.path_encoding |
|
390 | 386 | end |
|
391 | 387 | |
|
392 | 388 | def test_cat_path_invalid |
|
393 | 389 | assert_nil @adapter.cat('invalid') |
|
394 | 390 | end |
|
395 | 391 | |
|
396 | 392 | def test_cat_revision_invalid |
|
397 | 393 | assert @adapter.cat('README') |
|
398 | 394 | assert_nil @adapter.cat('README', 'abcd1234efgh') |
|
399 | 395 | end |
|
400 | 396 | |
|
401 | 397 | def test_diff_path_invalid |
|
402 | 398 | assert_equal [], @adapter.diff('invalid', '713f4944648826f5') |
|
403 | 399 | end |
|
404 | 400 | |
|
405 | 401 | def test_diff_revision_invalid |
|
406 | 402 | assert_nil @adapter.diff(nil, 'abcd1234efgh') |
|
407 | 403 | assert_nil @adapter.diff(nil, '713f4944648826f5', 'abcd1234efgh') |
|
408 | 404 | assert_nil @adapter.diff(nil, 'abcd1234efgh', '713f4944648826f5') |
|
409 | 405 | end |
|
410 | 406 | |
|
411 | 407 | def test_annotate_path_invalid |
|
412 | 408 | assert_nil @adapter.annotate('invalid') |
|
413 | 409 | end |
|
414 | 410 | |
|
415 | 411 | def test_annotate_revision_invalid |
|
416 | 412 | assert @adapter.annotate('README') |
|
417 | 413 | assert_nil @adapter.annotate('README', 'abcd1234efgh') |
|
418 | 414 | end |
|
419 | 415 | |
|
420 | 416 | private |
|
421 | 417 | |
|
422 | 418 | def test_scm_version_for(scm_command_version, version) |
|
423 | 419 | @adapter.class.expects(:scm_version_from_command_line).returns(scm_command_version) |
|
424 | 420 | assert_equal version, @adapter.class.scm_command_version |
|
425 | 421 | end |
|
426 | 422 | |
|
427 | 423 | else |
|
428 | 424 | puts "Git test repository NOT FOUND. Skipping unit tests !!!" |
|
429 | 425 | def test_fake; assert true end |
|
430 | 426 | end |
|
431 | 427 | end |
|
432 | 428 | |
|
433 | 429 | rescue LoadError |
|
434 | 430 | class GitMochaFake < ActiveSupport::TestCase |
|
435 | 431 | def test_fake; assert(false, "Requires mocha to run those tests") end |
|
436 | 432 | end |
|
437 | 433 | end |
General Comments 0
You need to be logged in to leave comments.
Login now