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