@@ -1,314 +1,316 | |||||
1 | # Redmine - project management software |
|
1 | # Redmine - project management software | |
2 | # Copyright (C) 2006-2011 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2011 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 RepositoryMercurialTest < ActiveSupport::TestCase |
|
20 | class RepositoryMercurialTest < ActiveSupport::TestCase | |
21 | fixtures :projects |
|
21 | fixtures :projects | |
22 |
|
22 | |||
23 | REPOSITORY_PATH = Rails.root.join('tmp/test/mercurial_repository').to_s |
|
23 | REPOSITORY_PATH = Rails.root.join('tmp/test/mercurial_repository').to_s | |
24 | NUM_REV = 29 |
|
24 | NUM_REV = 29 | |
25 | CHAR_1_HEX = "\xc3\x9c" |
|
25 | CHAR_1_HEX = "\xc3\x9c" | |
26 |
|
26 | |||
27 | if File.directory?(REPOSITORY_PATH) |
|
27 | if File.directory?(REPOSITORY_PATH) | |
28 | def setup |
|
28 | def setup | |
29 | klass = Repository::Mercurial |
|
29 | klass = Repository::Mercurial | |
30 | assert_equal "Mercurial", klass.scm_name |
|
30 | assert_equal "Mercurial", klass.scm_name | |
31 | assert klass.scm_adapter_class |
|
31 | assert klass.scm_adapter_class | |
32 | assert_not_equal "", klass.scm_command |
|
32 | assert_not_equal "", klass.scm_command | |
33 | assert_equal true, klass.scm_available |
|
33 | assert_equal true, klass.scm_available | |
34 |
|
34 | |||
35 | @project = Project.find(3) |
|
35 | @project = Project.find(3) | |
36 | @repository = Repository::Mercurial.create( |
|
36 | @repository = Repository::Mercurial.create( | |
37 | :project => @project, |
|
37 | :project => @project, | |
38 | :url => REPOSITORY_PATH, |
|
38 | :url => REPOSITORY_PATH, | |
39 | :path_encoding => 'ISO-8859-1' |
|
39 | :path_encoding => 'ISO-8859-1' | |
40 | ) |
|
40 | ) | |
41 | assert @repository |
|
41 | assert @repository | |
42 | @char_1 = CHAR_1_HEX.dup |
|
42 | @char_1 = CHAR_1_HEX.dup | |
43 | @tag_char_1 = "tag-#{CHAR_1_HEX}-00" |
|
43 | @tag_char_1 = "tag-#{CHAR_1_HEX}-00" | |
44 | @branch_char_0 = "branch-#{CHAR_1_HEX}-00" |
|
44 | @branch_char_0 = "branch-#{CHAR_1_HEX}-00" | |
45 | @branch_char_1 = "branch-#{CHAR_1_HEX}-01" |
|
45 | @branch_char_1 = "branch-#{CHAR_1_HEX}-01" | |
46 | if @char_1.respond_to?(:force_encoding) |
|
46 | if @char_1.respond_to?(:force_encoding) | |
47 | @char_1.force_encoding('UTF-8') |
|
47 | @char_1.force_encoding('UTF-8') | |
48 | @tag_char_1.force_encoding('UTF-8') |
|
48 | @tag_char_1.force_encoding('UTF-8') | |
49 | @branch_char_0.force_encoding('UTF-8') |
|
49 | @branch_char_0.force_encoding('UTF-8') | |
50 | @branch_char_1.force_encoding('UTF-8') |
|
50 | @branch_char_1.force_encoding('UTF-8') | |
51 | end |
|
51 | end | |
52 | end |
|
52 | end | |
53 |
|
53 | |||
54 | def test_fetch_changesets_from_scratch |
|
54 | def test_fetch_changesets_from_scratch | |
55 | assert_equal 0, @repository.changesets.count |
|
55 | assert_equal 0, @repository.changesets.count | |
56 | @repository.fetch_changesets |
|
56 | @repository.fetch_changesets | |
57 | @project.reload |
|
57 | @project.reload | |
58 | assert_equal NUM_REV, @repository.changesets.count |
|
58 | assert_equal NUM_REV, @repository.changesets.count | |
59 | assert_equal 37, @repository.changes.count |
|
59 | assert_equal 37, @repository.changes.count | |
60 | assert_equal "Initial import.\nThe repository contains 3 files.", |
|
60 | assert_equal "Initial import.\nThe repository contains 3 files.", | |
61 | @repository.changesets.find_by_revision('0').comments |
|
61 | @repository.changesets.find_by_revision('0').comments | |
62 | end |
|
62 | end | |
63 |
|
63 | |||
64 | def test_fetch_changesets_incremental |
|
64 | def test_fetch_changesets_incremental | |
65 | assert_equal 0, @repository.changesets.count |
|
65 | assert_equal 0, @repository.changesets.count | |
66 | @repository.fetch_changesets |
|
66 | @repository.fetch_changesets | |
67 | @project.reload |
|
67 | @project.reload | |
68 | assert_equal NUM_REV, @repository.changesets.count |
|
68 | assert_equal NUM_REV, @repository.changesets.count | |
69 | # Remove changesets with revision > 2 |
|
69 | # Remove changesets with revision > 2 | |
70 | @repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 2} |
|
70 | @repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 2} | |
71 | @project.reload |
|
71 | @project.reload | |
72 | assert_equal 3, @repository.changesets.count |
|
72 | assert_equal 3, @repository.changesets.count | |
73 |
|
73 | |||
74 | @repository.fetch_changesets |
|
74 | @repository.fetch_changesets | |
75 | @project.reload |
|
75 | @project.reload | |
76 | assert_equal 29, @repository.changesets.count |
|
76 | assert_equal 29, @repository.changesets.count | |
77 | end |
|
77 | end | |
78 |
|
78 | |||
79 | def test_isodatesec |
|
79 | def test_isodatesec | |
80 | # Template keyword 'isodatesec' supported in Mercurial 1.0 and higher |
|
80 | # Template keyword 'isodatesec' supported in Mercurial 1.0 and higher | |
81 | if @repository.scm.class.client_version_above?([1, 0]) |
|
81 | if @repository.scm.class.client_version_above?([1, 0]) | |
82 | assert_equal 0, @repository.changesets.count |
|
82 | assert_equal 0, @repository.changesets.count | |
83 | @repository.fetch_changesets |
|
83 | @repository.fetch_changesets | |
84 | @project.reload |
|
84 | @project.reload | |
85 | assert_equal NUM_REV, @repository.changesets.count |
|
85 | assert_equal NUM_REV, @repository.changesets.count | |
86 | rev0_committed_on = Time.gm(2007, 12, 14, 9, 22, 52) |
|
86 | rev0_committed_on = Time.gm(2007, 12, 14, 9, 22, 52) | |
87 | assert_equal @repository.changesets.find_by_revision('0').committed_on, rev0_committed_on |
|
87 | assert_equal @repository.changesets.find_by_revision('0').committed_on, rev0_committed_on | |
88 | end |
|
88 | end | |
89 | end |
|
89 | end | |
90 |
|
90 | |||
91 | def test_changeset_order_by_revision |
|
91 | def test_changeset_order_by_revision | |
92 | @repository.fetch_changesets |
|
92 | @repository.fetch_changesets | |
93 | @repository.reload |
|
93 | @repository.reload | |
94 |
|
94 | |||
95 | c0 = @repository.latest_changeset |
|
95 | c0 = @repository.latest_changeset | |
96 | c1 = @repository.changesets.find_by_revision('0') |
|
96 | c1 = @repository.changesets.find_by_revision('0') | |
97 | # sorted by revision (id), not by date |
|
97 | # sorted by revision (id), not by date | |
98 | assert c0.revision.to_i > c1.revision.to_i |
|
98 | assert c0.revision.to_i > c1.revision.to_i | |
99 | assert c0.committed_on < c1.committed_on |
|
99 | assert c0.committed_on < c1.committed_on | |
100 | end |
|
100 | end | |
101 |
|
101 | |||
102 | def test_latest_changesets |
|
102 | def test_latest_changesets | |
103 | @repository.fetch_changesets |
|
103 | @repository.fetch_changesets | |
104 | @repository.reload |
|
104 | @repository.reload | |
105 |
|
105 | |||
106 | # with_limit |
|
106 | # with_limit | |
107 | changesets = @repository.latest_changesets('', nil, 2) |
|
107 | changesets = @repository.latest_changesets('', nil, 2) | |
108 | assert_equal %w|28 27|, changesets.collect(&:revision) |
|
108 | assert_equal %w|28 27|, changesets.collect(&:revision) | |
109 |
|
109 | |||
110 | # with_filepath |
|
110 | # with_filepath | |
111 | changesets = @repository.latest_changesets( |
|
111 | changesets = @repository.latest_changesets( | |
112 | '/sql_escape/percent%dir/percent%file1.txt', nil) |
|
112 | '/sql_escape/percent%dir/percent%file1.txt', nil) | |
113 | assert_equal %w|11 10 9|, changesets.collect(&:revision) |
|
113 | assert_equal %w|11 10 9|, changesets.collect(&:revision) | |
114 |
|
114 | |||
115 | changesets = @repository.latest_changesets( |
|
115 | changesets = @repository.latest_changesets( | |
116 | '/sql_escape/underscore_dir/understrike_file.txt', nil) |
|
116 | '/sql_escape/underscore_dir/understrike_file.txt', nil) | |
117 | assert_equal %w|12 9|, changesets.collect(&:revision) |
|
117 | assert_equal %w|12 9|, changesets.collect(&:revision) | |
118 |
|
118 | |||
119 | changesets = @repository.latest_changesets('README', nil) |
|
119 | changesets = @repository.latest_changesets('README', nil) | |
120 | assert_equal %w|28 17 8 6 1 0|, changesets.collect(&:revision) |
|
120 | assert_equal %w|28 17 8 6 1 0|, changesets.collect(&:revision) | |
121 |
|
121 | |||
122 | changesets = @repository.latest_changesets('README','8') |
|
122 | changesets = @repository.latest_changesets('README','8') | |
123 | assert_equal %w|8 6 1 0|, changesets.collect(&:revision) |
|
123 | assert_equal %w|8 6 1 0|, changesets.collect(&:revision) | |
124 |
|
124 | |||
125 | changesets = @repository.latest_changesets('README','8', 2) |
|
125 | changesets = @repository.latest_changesets('README','8', 2) | |
126 | assert_equal %w|8 6|, changesets.collect(&:revision) |
|
126 | assert_equal %w|8 6|, changesets.collect(&:revision) | |
127 |
|
127 | |||
128 | # with_dirpath |
|
128 | # with_dirpath | |
129 | changesets = @repository.latest_changesets('images', nil) |
|
129 | changesets = @repository.latest_changesets('images', nil) | |
130 | assert_equal %w|1 0|, changesets.collect(&:revision) |
|
130 | assert_equal %w|1 0|, changesets.collect(&:revision) | |
131 |
|
131 | |||
132 | path = 'sql_escape/percent%dir' |
|
132 | path = 'sql_escape/percent%dir' | |
133 | changesets = @repository.latest_changesets(path, nil) |
|
133 | changesets = @repository.latest_changesets(path, nil) | |
134 | assert_equal %w|13 11 10 9|, changesets.collect(&:revision) |
|
134 | assert_equal %w|13 11 10 9|, changesets.collect(&:revision) | |
135 |
|
135 | |||
136 | changesets = @repository.latest_changesets(path, '11') |
|
136 | changesets = @repository.latest_changesets(path, '11') | |
137 | assert_equal %w|11 10 9|, changesets.collect(&:revision) |
|
137 | assert_equal %w|11 10 9|, changesets.collect(&:revision) | |
138 |
|
138 | |||
139 | changesets = @repository.latest_changesets(path, '11', 2) |
|
139 | changesets = @repository.latest_changesets(path, '11', 2) | |
140 | assert_equal %w|11 10|, changesets.collect(&:revision) |
|
140 | assert_equal %w|11 10|, changesets.collect(&:revision) | |
141 |
|
141 | |||
142 | path = 'sql_escape/underscore_dir' |
|
142 | path = 'sql_escape/underscore_dir' | |
143 | changesets = @repository.latest_changesets(path, nil) |
|
143 | changesets = @repository.latest_changesets(path, nil) | |
144 | assert_equal %w|13 12 9|, changesets.collect(&:revision) |
|
144 | assert_equal %w|13 12 9|, changesets.collect(&:revision) | |
145 |
|
145 | |||
146 | changesets = @repository.latest_changesets(path, '12') |
|
146 | changesets = @repository.latest_changesets(path, '12') | |
147 | assert_equal %w|12 9|, changesets.collect(&:revision) |
|
147 | assert_equal %w|12 9|, changesets.collect(&:revision) | |
148 |
|
148 | |||
149 | changesets = @repository.latest_changesets(path, '12', 1) |
|
149 | changesets = @repository.latest_changesets(path, '12', 1) | |
150 | assert_equal %w|12|, changesets.collect(&:revision) |
|
150 | assert_equal %w|12|, changesets.collect(&:revision) | |
151 |
|
151 | |||
152 | # tag |
|
152 | # tag | |
153 | changesets = @repository.latest_changesets('', 'tag_test.00') |
|
153 | changesets = @repository.latest_changesets('', 'tag_test.00') | |
154 | assert_equal %w|5 4 3 2 1 0|, changesets.collect(&:revision) |
|
154 | assert_equal %w|5 4 3 2 1 0|, changesets.collect(&:revision) | |
155 |
|
155 | |||
156 | changesets = @repository.latest_changesets('', 'tag_test.00', 2) |
|
156 | changesets = @repository.latest_changesets('', 'tag_test.00', 2) | |
157 | assert_equal %w|5 4|, changesets.collect(&:revision) |
|
157 | assert_equal %w|5 4|, changesets.collect(&:revision) | |
158 |
|
158 | |||
159 | changesets = @repository.latest_changesets('sources', 'tag_test.00') |
|
159 | changesets = @repository.latest_changesets('sources', 'tag_test.00') | |
160 | assert_equal %w|4 3 2 1 0|, changesets.collect(&:revision) |
|
160 | assert_equal %w|4 3 2 1 0|, changesets.collect(&:revision) | |
161 |
|
161 | |||
162 | changesets = @repository.latest_changesets('sources', 'tag_test.00', 2) |
|
162 | changesets = @repository.latest_changesets('sources', 'tag_test.00', 2) | |
163 | assert_equal %w|4 3|, changesets.collect(&:revision) |
|
163 | assert_equal %w|4 3|, changesets.collect(&:revision) | |
164 |
|
164 | |||
165 | # named branch |
|
165 | # named branch | |
166 | changesets = @repository.latest_changesets('', @branch_char_1) |
|
166 | changesets = @repository.latest_changesets('', @branch_char_1) | |
167 | assert_equal %w|27 26|, changesets.collect(&:revision) |
|
167 | assert_equal %w|27 26|, changesets.collect(&:revision) | |
168 |
|
168 | |||
169 | changesets = @repository.latest_changesets("latin-1-dir/test-#{@char_1}-subdir", @branch_char_1) |
|
169 | changesets = @repository.latest_changesets("latin-1-dir/test-#{@char_1}-subdir", @branch_char_1) | |
170 | assert_equal %w|27|, changesets.collect(&:revision) |
|
170 | assert_equal %w|27|, changesets.collect(&:revision) | |
171 | end |
|
171 | end | |
172 |
|
172 | |||
173 | def test_copied_files |
|
173 | def test_copied_files | |
174 | @repository.fetch_changesets |
|
174 | @repository.fetch_changesets | |
175 | @repository.reload |
|
175 | @repository.reload | |
176 |
|
176 | |||
177 | cs1 = @repository.changesets.find_by_revision('13') |
|
177 | cs1 = @repository.changesets.find_by_revision('13') | |
178 | assert_not_nil cs1 |
|
178 | assert_not_nil cs1 | |
179 | c1 = cs1.changes.sort_by(&:path) |
|
179 | c1 = cs1.changes.sort_by(&:path) | |
180 | assert_equal 2, c1.size |
|
180 | assert_equal 2, c1.size | |
181 |
|
181 | |||
182 | assert_equal 'A', c1[0].action |
|
182 | assert_equal 'A', c1[0].action | |
183 | assert_equal '/sql_escape/percent%dir/percentfile1.txt', c1[0].path |
|
183 | assert_equal '/sql_escape/percent%dir/percentfile1.txt', c1[0].path | |
184 | assert_equal '/sql_escape/percent%dir/percent%file1.txt', c1[0].from_path |
|
184 | assert_equal '/sql_escape/percent%dir/percent%file1.txt', c1[0].from_path | |
185 | assert_equal '3a330eb32958', c1[0].from_revision |
|
185 | assert_equal '3a330eb32958', c1[0].from_revision | |
186 |
|
186 | |||
187 | assert_equal 'A', c1[1].action |
|
187 | assert_equal 'A', c1[1].action | |
188 | assert_equal '/sql_escape/underscore_dir/understrike-file.txt', c1[1].path |
|
188 | assert_equal '/sql_escape/underscore_dir/understrike-file.txt', c1[1].path | |
189 | assert_equal '/sql_escape/underscore_dir/understrike_file.txt', c1[1].from_path |
|
189 | assert_equal '/sql_escape/underscore_dir/understrike_file.txt', c1[1].from_path | |
190 |
|
190 | |||
191 | cs2 = @repository.changesets.find_by_revision('15') |
|
191 | cs2 = @repository.changesets.find_by_revision('15') | |
192 | c2 = cs2.changes |
|
192 | c2 = cs2.changes | |
193 | assert_equal 1, c2.size |
|
193 | assert_equal 1, c2.size | |
194 |
|
194 | |||
195 | assert_equal 'A', c2[0].action |
|
195 | assert_equal 'A', c2[0].action | |
196 | assert_equal '/README (1)[2]&,%.-3_4', c2[0].path |
|
196 | assert_equal '/README (1)[2]&,%.-3_4', c2[0].path | |
197 | assert_equal '/README', c2[0].from_path |
|
197 | assert_equal '/README', c2[0].from_path | |
198 | assert_equal '933ca60293d7', c2[0].from_revision |
|
198 | assert_equal '933ca60293d7', c2[0].from_revision | |
199 |
|
199 | |||
200 | cs3 = @repository.changesets.find_by_revision('19') |
|
200 | cs3 = @repository.changesets.find_by_revision('19') | |
201 | c3 = cs3.changes |
|
201 | c3 = cs3.changes | |
202 | assert_equal 1, c3.size |
|
202 | assert_equal 1, c3.size | |
203 | assert_equal 'A', c3[0].action |
|
203 | assert_equal 'A', c3[0].action | |
204 | assert_equal "/latin-1-dir/test-#{@char_1}-1.txt", c3[0].path |
|
204 | assert_equal "/latin-1-dir/test-#{@char_1}-1.txt", c3[0].path | |
205 | assert_equal "/latin-1-dir/test-#{@char_1}.txt", c3[0].from_path |
|
205 | assert_equal "/latin-1-dir/test-#{@char_1}.txt", c3[0].from_path | |
206 | assert_equal '5d9891a1b425', c3[0].from_revision |
|
206 | assert_equal '5d9891a1b425', c3[0].from_revision | |
207 | end |
|
207 | end | |
208 |
|
208 | |||
209 | def test_find_changeset_by_name |
|
209 | def test_find_changeset_by_name | |
210 | assert_equal 0, @repository.changesets.count |
|
210 | assert_equal 0, @repository.changesets.count | |
211 | @repository.fetch_changesets |
|
211 | @repository.fetch_changesets | |
212 | @project.reload |
|
212 | @project.reload | |
213 | assert_equal NUM_REV, @repository.changesets.count |
|
213 | assert_equal NUM_REV, @repository.changesets.count | |
214 | %w|2 400bb8672109 400|.each do |r| |
|
214 | %w|2 400bb8672109 400|.each do |r| | |
215 | assert_equal '2', @repository.find_changeset_by_name(r).revision |
|
215 | assert_equal '2', @repository.find_changeset_by_name(r).revision | |
216 | end |
|
216 | end | |
217 | end |
|
217 | end | |
218 |
|
218 | |||
219 | def test_find_changeset_by_invalid_name |
|
219 | def test_find_changeset_by_invalid_name | |
220 | assert_equal 0, @repository.changesets.count |
|
220 | assert_equal 0, @repository.changesets.count | |
221 | @repository.fetch_changesets |
|
221 | @repository.fetch_changesets | |
222 | @project.reload |
|
222 | @project.reload | |
223 | assert_equal NUM_REV, @repository.changesets.count |
|
223 | assert_equal NUM_REV, @repository.changesets.count | |
224 | assert_nil @repository.find_changeset_by_name('100000') |
|
224 | assert_nil @repository.find_changeset_by_name('100000') | |
225 | end |
|
225 | end | |
226 |
|
226 | |||
227 | def test_identifier |
|
227 | def test_identifier | |
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 | assert_equal NUM_REV, @repository.changesets.count |
|
231 | assert_equal NUM_REV, @repository.changesets.count | |
232 | c = @repository.changesets.find_by_revision('2') |
|
232 | c = @repository.changesets.find_by_revision('2') | |
233 | assert_equal c.scmid, c.identifier |
|
233 | assert_equal c.scmid, c.identifier | |
234 | end |
|
234 | end | |
235 |
|
235 | |||
236 | def test_format_identifier |
|
236 | def test_format_identifier | |
|
237 | assert_equal 0, @repository.changesets.count | |||
237 | @repository.fetch_changesets |
|
238 | @repository.fetch_changesets | |
238 |
@ |
|
239 | @project.reload | |
|
240 | assert_equal NUM_REV, @repository.changesets.count | |||
239 | c = @repository.changesets.find_by_revision('2') |
|
241 | c = @repository.changesets.find_by_revision('2') | |
240 | assert_equal '2:400bb8672109', c.format_identifier |
|
242 | assert_equal '2:400bb8672109', c.format_identifier | |
241 | end |
|
243 | end | |
242 |
|
244 | |||
243 | def test_find_changeset_by_empty_name |
|
245 | def test_find_changeset_by_empty_name | |
244 | assert_equal 0, @repository.changesets.count |
|
246 | assert_equal 0, @repository.changesets.count | |
245 | @repository.fetch_changesets |
|
247 | @repository.fetch_changesets | |
246 | @project.reload |
|
248 | @project.reload | |
247 | assert_equal NUM_REV, @repository.changesets.count |
|
249 | assert_equal NUM_REV, @repository.changesets.count | |
248 | ['', ' ', nil].each do |r| |
|
250 | ['', ' ', nil].each do |r| | |
249 | assert_nil @repository.find_changeset_by_name(r) |
|
251 | assert_nil @repository.find_changeset_by_name(r) | |
250 | end |
|
252 | end | |
251 | end |
|
253 | end | |
252 |
|
254 | |||
253 | def test_activities |
|
255 | def test_activities | |
254 | c = Changeset.new(:repository => @repository, |
|
256 | c = Changeset.new(:repository => @repository, | |
255 | :committed_on => Time.now, |
|
257 | :committed_on => Time.now, | |
256 | :revision => '123', |
|
258 | :revision => '123', | |
257 | :scmid => 'abc400bb8672', |
|
259 | :scmid => 'abc400bb8672', | |
258 | :comments => 'test') |
|
260 | :comments => 'test') | |
259 | assert c.event_title.include?('123:abc400bb8672:') |
|
261 | assert c.event_title.include?('123:abc400bb8672:') | |
260 | assert_equal 'abc400bb8672', c.event_url[:rev] |
|
262 | assert_equal 'abc400bb8672', c.event_url[:rev] | |
261 | end |
|
263 | end | |
262 |
|
264 | |||
263 | def test_previous |
|
265 | def test_previous | |
264 | assert_equal 0, @repository.changesets.count |
|
266 | assert_equal 0, @repository.changesets.count | |
265 | @repository.fetch_changesets |
|
267 | @repository.fetch_changesets | |
266 | @project.reload |
|
268 | @project.reload | |
267 | assert_equal NUM_REV, @repository.changesets.count |
|
269 | assert_equal NUM_REV, @repository.changesets.count | |
268 | %w|28 3ae45e2d177d 3ae45|.each do |r1| |
|
270 | %w|28 3ae45e2d177d 3ae45|.each do |r1| | |
269 | changeset = @repository.find_changeset_by_name(r1) |
|
271 | changeset = @repository.find_changeset_by_name(r1) | |
270 | %w|27 7bbf4c738e71 7bbf|.each do |r2| |
|
272 | %w|27 7bbf4c738e71 7bbf|.each do |r2| | |
271 | assert_equal @repository.find_changeset_by_name(r2), changeset.previous |
|
273 | assert_equal @repository.find_changeset_by_name(r2), changeset.previous | |
272 | end |
|
274 | end | |
273 | end |
|
275 | end | |
274 | end |
|
276 | end | |
275 |
|
277 | |||
276 | def test_previous_nil |
|
278 | def test_previous_nil | |
277 | assert_equal 0, @repository.changesets.count |
|
279 | assert_equal 0, @repository.changesets.count | |
278 | @repository.fetch_changesets |
|
280 | @repository.fetch_changesets | |
279 | @project.reload |
|
281 | @project.reload | |
280 | assert_equal NUM_REV, @repository.changesets.count |
|
282 | assert_equal NUM_REV, @repository.changesets.count | |
281 | %w|0 0885933ad4f6 0885|.each do |r1| |
|
283 | %w|0 0885933ad4f6 0885|.each do |r1| | |
282 | changeset = @repository.find_changeset_by_name(r1) |
|
284 | changeset = @repository.find_changeset_by_name(r1) | |
283 | assert_nil changeset.previous |
|
285 | assert_nil changeset.previous | |
284 | end |
|
286 | end | |
285 | end |
|
287 | end | |
286 |
|
288 | |||
287 | def test_next |
|
289 | def test_next | |
288 | assert_equal 0, @repository.changesets.count |
|
290 | assert_equal 0, @repository.changesets.count | |
289 | @repository.fetch_changesets |
|
291 | @repository.fetch_changesets | |
290 | @project.reload |
|
292 | @project.reload | |
291 | assert_equal NUM_REV, @repository.changesets.count |
|
293 | assert_equal NUM_REV, @repository.changesets.count | |
292 | %w|27 7bbf4c738e71 7bbf|.each do |r2| |
|
294 | %w|27 7bbf4c738e71 7bbf|.each do |r2| | |
293 | changeset = @repository.find_changeset_by_name(r2) |
|
295 | changeset = @repository.find_changeset_by_name(r2) | |
294 | %w|28 3ae45e2d177d 3ae45|.each do |r1| |
|
296 | %w|28 3ae45e2d177d 3ae45|.each do |r1| | |
295 | assert_equal @repository.find_changeset_by_name(r1), changeset.next |
|
297 | assert_equal @repository.find_changeset_by_name(r1), changeset.next | |
296 | end |
|
298 | end | |
297 | end |
|
299 | end | |
298 | end |
|
300 | end | |
299 |
|
301 | |||
300 | def test_next_nil |
|
302 | def test_next_nil | |
301 | assert_equal 0, @repository.changesets.count |
|
303 | assert_equal 0, @repository.changesets.count | |
302 | @repository.fetch_changesets |
|
304 | @repository.fetch_changesets | |
303 | @project.reload |
|
305 | @project.reload | |
304 | assert_equal NUM_REV, @repository.changesets.count |
|
306 | assert_equal NUM_REV, @repository.changesets.count | |
305 | %w|28 3ae45e2d177d 3ae45|.each do |r1| |
|
307 | %w|28 3ae45e2d177d 3ae45|.each do |r1| | |
306 | changeset = @repository.find_changeset_by_name(r1) |
|
308 | changeset = @repository.find_changeset_by_name(r1) | |
307 | assert_nil changeset.next |
|
309 | assert_nil changeset.next | |
308 | end |
|
310 | end | |
309 | end |
|
311 | end | |
310 | else |
|
312 | else | |
311 | puts "Mercurial test repository NOT FOUND. Skipping unit tests !!!" |
|
313 | puts "Mercurial test repository NOT FOUND. Skipping unit tests !!!" | |
312 | def test_fake; assert true end |
|
314 | def test_fake; assert true end | |
313 | end |
|
315 | end | |
314 | end |
|
316 | end |
General Comments 0
You need to be logged in to leave comments.
Login now