@@ -1,297 +1,297 | |||||
1 | # Redmine - project management software |
|
1 | # Redmine - project management software | |
2 | # Copyright (C) 2006-2014 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2014 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 RepositoryBazaarTest < ActiveSupport::TestCase |
|
20 | class RepositoryBazaarTest < ActiveSupport::TestCase | |
21 | fixtures :projects |
|
21 | fixtures :projects | |
22 |
|
22 | |||
23 | include Redmine::I18n |
|
23 | include Redmine::I18n | |
24 |
|
24 | |||
25 | REPOSITORY_PATH = repository_path('bazaar') |
|
25 | REPOSITORY_PATH = repository_path('bazaar') | |
26 | REPOSITORY_PATH_TRUNK = File.join(REPOSITORY_PATH, "trunk") |
|
26 | REPOSITORY_PATH_TRUNK = File.join(REPOSITORY_PATH, "trunk") | |
27 | NUM_REV = 4 |
|
27 | NUM_REV = 4 | |
28 |
|
28 | |||
29 | REPOSITORY_PATH_NON_ASCII = Rails.root.join(REPOSITORY_PATH + '/' + 'non_ascii').to_s |
|
29 | REPOSITORY_PATH_NON_ASCII = Rails.root.join(REPOSITORY_PATH + '/' + 'non_ascii').to_s | |
30 |
|
30 | |||
31 | # Bazaar core does not support xml output such as Subversion and Mercurial. |
|
31 | # Bazaar core does not support xml output such as Subversion and Mercurial. | |
32 | # "bzr" command output and command line parameter depend on locale. |
|
32 | # "bzr" command output and command line parameter depend on locale. | |
33 | # So, non ASCII path tests cannot run independent locale. |
|
33 | # So, non ASCII path tests cannot run independent locale. | |
34 | # |
|
34 | # | |
35 | # If you want to run Bazaar non ASCII path tests on Linux *Ruby 1.9*, |
|
35 | # If you want to run Bazaar non ASCII path tests on Linux *Ruby 1.9*, | |
36 | # you need to set locale character set "ISO-8859-1". |
|
36 | # you need to set locale character set "ISO-8859-1". | |
37 | # E.g. "LANG=en_US.ISO-8859-1". |
|
37 | # E.g. "LANG=en_US.ISO-8859-1". | |
38 | # On Linux other platforms (e.g. Ruby 1.8, JRuby), |
|
38 | # On Linux other platforms (e.g. Ruby 1.8, JRuby), | |
39 | # you need to set "RUN_LATIN1_OUTPUT_TEST = true" manually. |
|
39 | # you need to set "RUN_LATIN1_OUTPUT_TEST = true" manually. | |
40 | # |
|
40 | # | |
41 | # On Windows, because it is too hard to change system locale, |
|
41 | # On Windows, because it is too hard to change system locale, | |
42 | # you cannot run Bazaar non ASCII path tests. |
|
42 | # you cannot run Bazaar non ASCII path tests. | |
43 | # |
|
43 | # | |
44 | RUN_LATIN1_OUTPUT_TEST = (RUBY_PLATFORM != 'java' && |
|
44 | RUN_LATIN1_OUTPUT_TEST = (RUBY_PLATFORM != 'java' && | |
45 | Encoding.locale_charmap == "ISO-8859-1") |
|
45 | Encoding.locale_charmap == "ISO-8859-1") | |
46 |
|
46 | |||
47 | CHAR_1_UTF8_HEX = "\xc3\x9c".force_encoding('UTF-8') |
|
47 | CHAR_1_UTF8_HEX = "\xc3\x9c".force_encoding('UTF-8') | |
48 | CHAR_1_LATIN1_HEX = "\xdc".force_encoding('ASCII-8BIT') |
|
48 | CHAR_1_LATIN1_HEX = "\xdc".force_encoding('ASCII-8BIT') | |
49 |
|
49 | |||
50 | def setup |
|
50 | def setup | |
51 | @project = Project.find(3) |
|
51 | @project = Project.find(3) | |
52 | @repository = Repository::Bazaar.create( |
|
52 | @repository = Repository::Bazaar.create( | |
53 | :project => @project, :url => REPOSITORY_PATH_TRUNK, |
|
53 | :project => @project, :url => REPOSITORY_PATH_TRUNK, | |
54 | :log_encoding => 'UTF-8') |
|
54 | :log_encoding => 'UTF-8') | |
55 | assert @repository |
|
55 | assert @repository | |
56 | end |
|
56 | end | |
57 |
|
57 | |||
58 | def test_blank_path_to_repository_error_message |
|
58 | def test_blank_path_to_repository_error_message | |
59 | set_language_if_valid 'en' |
|
59 | set_language_if_valid 'en' | |
60 | repo = Repository::Bazaar.new( |
|
60 | repo = Repository::Bazaar.new( | |
61 | :project => @project, |
|
61 | :project => @project, | |
62 | :identifier => 'test', |
|
62 | :identifier => 'test', | |
63 | :log_encoding => 'UTF-8' |
|
63 | :log_encoding => 'UTF-8' | |
64 | ) |
|
64 | ) | |
65 | assert !repo.save |
|
65 | assert !repo.save | |
66 | assert_include "Path to repository can't be blank", |
|
66 | assert_include "Path to repository can't be blank", | |
67 | repo.errors.full_messages |
|
67 | repo.errors.full_messages | |
68 | end |
|
68 | end | |
69 |
|
69 | |||
70 | def test_blank_path_to_repository_error_message_fr |
|
70 | def test_blank_path_to_repository_error_message_fr | |
71 | set_language_if_valid 'fr' |
|
71 | set_language_if_valid 'fr' | |
72 | str = "Chemin du d\xc3\xa9p\xc3\xb4t doit \xc3\xaatre renseign\xc3\xa9(e)".force_encoding('UTF-8') |
|
72 | str = "Chemin du d\xc3\xa9p\xc3\xb4t doit \xc3\xaatre renseign\xc3\xa9(e)".force_encoding('UTF-8') | |
73 | repo = Repository::Bazaar.new( |
|
73 | repo = Repository::Bazaar.new( | |
74 | :project => @project, |
|
74 | :project => @project, | |
75 | :url => "", |
|
75 | :url => "", | |
76 | :identifier => 'test', |
|
76 | :identifier => 'test', | |
77 | :log_encoding => 'UTF-8' |
|
77 | :log_encoding => 'UTF-8' | |
78 | ) |
|
78 | ) | |
79 | assert !repo.save |
|
79 | assert !repo.save | |
80 | assert_include str, repo.errors.full_messages |
|
80 | assert_include str, repo.errors.full_messages | |
81 | end |
|
81 | end | |
82 |
|
82 | |||
83 | if File.directory?(REPOSITORY_PATH_TRUNK) |
|
83 | if File.directory?(REPOSITORY_PATH_TRUNK) | |
84 | def test_fetch_changesets_from_scratch |
|
84 | def test_fetch_changesets_from_scratch | |
85 | assert_equal 0, @repository.changesets.count |
|
85 | assert_equal 0, @repository.changesets.count | |
86 | @repository.fetch_changesets |
|
86 | @repository.fetch_changesets | |
87 | @project.reload |
|
87 | @project.reload | |
88 |
|
88 | |||
89 | assert_equal NUM_REV, @repository.changesets.count |
|
89 | assert_equal NUM_REV, @repository.changesets.count | |
90 | assert_equal 9, @repository.filechanges.count |
|
90 | assert_equal 9, @repository.filechanges.count | |
91 | assert_equal 'Initial import', @repository.changesets.find_by_revision('1').comments |
|
91 | assert_equal 'Initial import', @repository.changesets.find_by_revision('1').comments | |
92 | end |
|
92 | end | |
93 |
|
93 | |||
94 | def test_fetch_changesets_incremental |
|
94 | def test_fetch_changesets_incremental | |
95 | assert_equal 0, @repository.changesets.count |
|
95 | assert_equal 0, @repository.changesets.count | |
96 | @repository.fetch_changesets |
|
96 | @repository.fetch_changesets | |
97 | @project.reload |
|
97 | @project.reload | |
98 | assert_equal NUM_REV, @repository.changesets.count |
|
98 | assert_equal NUM_REV, @repository.changesets.count | |
99 | # Remove changesets with revision > 5 |
|
99 | # Remove changesets with revision > 5 | |
100 | @repository.changesets.each {|c| c.destroy if c.revision.to_i > 2} |
|
100 | @repository.changesets.each {|c| c.destroy if c.revision.to_i > 2} | |
101 | @project.reload |
|
101 | @project.reload | |
102 | @repository.reload |
|
102 | @repository.reload | |
103 | assert_equal 2, @repository.changesets.count |
|
103 | assert_equal 2, @repository.changesets.count | |
104 |
|
104 | |||
105 | @repository.fetch_changesets |
|
105 | @repository.fetch_changesets | |
106 | @project.reload |
|
106 | @project.reload | |
107 | assert_equal NUM_REV, @repository.changesets.count |
|
107 | assert_equal NUM_REV, @repository.changesets.count | |
108 | end |
|
108 | end | |
109 |
|
109 | |||
110 | def test_entries |
|
110 | def test_entries | |
111 | entries = @repository.entries |
|
111 | entries = @repository.entries | |
112 | assert_kind_of Redmine::Scm::Adapters::Entries, entries |
|
112 | assert_kind_of Redmine::Scm::Adapters::Entries, entries | |
113 | assert_equal 2, entries.size |
|
113 | assert_equal 2, entries.size | |
114 |
|
114 | |||
115 | assert_equal 'dir', entries[0].kind |
|
115 | assert_equal 'dir', entries[0].kind | |
116 | assert_equal 'directory', entries[0].name |
|
116 | assert_equal 'directory', entries[0].name | |
117 | assert_equal 'directory', entries[0].path |
|
117 | assert_equal 'directory', entries[0].path | |
118 |
|
118 | |||
119 | assert_equal 'file', entries[1].kind |
|
119 | assert_equal 'file', entries[1].kind | |
120 | assert_equal 'doc-mkdir.txt', entries[1].name |
|
120 | assert_equal 'doc-mkdir.txt', entries[1].name | |
121 | assert_equal 'doc-mkdir.txt', entries[1].path |
|
121 | assert_equal 'doc-mkdir.txt', entries[1].path | |
122 | end |
|
122 | end | |
123 |
|
123 | |||
124 | def test_entries_in_subdirectory |
|
124 | def test_entries_in_subdirectory | |
125 | entries = @repository.entries('directory') |
|
125 | entries = @repository.entries('directory') | |
126 | assert_equal 3, entries.size |
|
126 | assert_equal 3, entries.size | |
127 |
|
127 | |||
128 | assert_equal 'file', entries.last.kind |
|
128 | assert_equal 'file', entries.last.kind | |
129 | assert_equal 'edit.png', entries.last.name |
|
129 | assert_equal 'edit.png', entries.last.name | |
130 | assert_equal 'directory/edit.png', entries.last.path |
|
130 | assert_equal 'directory/edit.png', entries.last.path | |
131 | end |
|
131 | end | |
132 |
|
132 | |||
133 | def test_previous |
|
133 | def test_previous | |
134 | assert_equal 0, @repository.changesets.count |
|
134 | assert_equal 0, @repository.changesets.count | |
135 | @repository.fetch_changesets |
|
135 | @repository.fetch_changesets | |
136 | @project.reload |
|
136 | @project.reload | |
137 | assert_equal NUM_REV, @repository.changesets.count |
|
137 | assert_equal NUM_REV, @repository.changesets.count | |
138 | changeset = @repository.find_changeset_by_name('3') |
|
138 | changeset = @repository.find_changeset_by_name('3') | |
139 | assert_equal @repository.find_changeset_by_name('2'), changeset.previous |
|
139 | assert_equal @repository.find_changeset_by_name('2'), changeset.previous | |
140 | end |
|
140 | end | |
141 |
|
141 | |||
142 | def test_previous_nil |
|
142 | def test_previous_nil | |
143 | assert_equal 0, @repository.changesets.count |
|
143 | assert_equal 0, @repository.changesets.count | |
144 | @repository.fetch_changesets |
|
144 | @repository.fetch_changesets | |
145 | @project.reload |
|
145 | @project.reload | |
146 | assert_equal NUM_REV, @repository.changesets.count |
|
146 | assert_equal NUM_REV, @repository.changesets.count | |
147 | changeset = @repository.find_changeset_by_name('1') |
|
147 | changeset = @repository.find_changeset_by_name('1') | |
148 | assert_nil changeset.previous |
|
148 | assert_nil changeset.previous | |
149 | end |
|
149 | end | |
150 |
|
150 | |||
151 | def test_next |
|
151 | def test_next | |
152 | assert_equal 0, @repository.changesets.count |
|
152 | assert_equal 0, @repository.changesets.count | |
153 | @repository.fetch_changesets |
|
153 | @repository.fetch_changesets | |
154 | @project.reload |
|
154 | @project.reload | |
155 | assert_equal NUM_REV, @repository.changesets.count |
|
155 | assert_equal NUM_REV, @repository.changesets.count | |
156 | changeset = @repository.find_changeset_by_name('2') |
|
156 | changeset = @repository.find_changeset_by_name('2') | |
157 | assert_equal @repository.find_changeset_by_name('3'), changeset.next |
|
157 | assert_equal @repository.find_changeset_by_name('3'), changeset.next | |
158 | end |
|
158 | end | |
159 |
|
159 | |||
160 | def test_next_nil |
|
160 | def test_next_nil | |
161 | assert_equal 0, @repository.changesets.count |
|
161 | assert_equal 0, @repository.changesets.count | |
162 | @repository.fetch_changesets |
|
162 | @repository.fetch_changesets | |
163 | @project.reload |
|
163 | @project.reload | |
164 | assert_equal NUM_REV, @repository.changesets.count |
|
164 | assert_equal NUM_REV, @repository.changesets.count | |
165 | changeset = @repository.find_changeset_by_name('4') |
|
165 | changeset = @repository.find_changeset_by_name('4') | |
166 | assert_nil changeset.next |
|
166 | assert_nil changeset.next | |
167 | end |
|
167 | end | |
168 |
|
168 | |||
169 | if File.directory?(REPOSITORY_PATH_NON_ASCII) && RUN_LATIN1_OUTPUT_TEST |
|
169 | if File.directory?(REPOSITORY_PATH_NON_ASCII) && RUN_LATIN1_OUTPUT_TEST | |
170 | def test_cat_latin1_path |
|
170 | def test_cat_latin1_path | |
171 | latin1_repo = create_latin1_repo |
|
171 | latin1_repo = create_latin1_repo | |
172 | buf = latin1_repo.cat( |
|
172 | buf = latin1_repo.cat( | |
173 | "test-#{CHAR_1_UTF8_HEX}-dir/test-#{CHAR_1_UTF8_HEX}-2.txt", 2) |
|
173 | "test-#{CHAR_1_UTF8_HEX}-dir/test-#{CHAR_1_UTF8_HEX}-2.txt", 2) | |
174 | assert buf |
|
174 | assert buf | |
175 | lines = buf.split("\n") |
|
175 | lines = buf.split("\n") | |
176 | assert_equal 2, lines.length |
|
176 | assert_equal 2, lines.length | |
177 | assert_equal 'It is written in Python.', lines[1] |
|
177 | assert_equal 'It is written in Python.', lines[1] | |
178 |
|
178 | |||
179 | buf = latin1_repo.cat( |
|
179 | buf = latin1_repo.cat( | |
180 | "test-#{CHAR_1_UTF8_HEX}-dir/test-#{CHAR_1_UTF8_HEX}-1.txt", 2) |
|
180 | "test-#{CHAR_1_UTF8_HEX}-dir/test-#{CHAR_1_UTF8_HEX}-1.txt", 2) | |
181 | assert buf |
|
181 | assert buf | |
182 | lines = buf.split("\n") |
|
182 | lines = buf.split("\n") | |
183 | assert_equal 1, lines.length |
|
183 | assert_equal 1, lines.length | |
184 | assert_equal "test-#{CHAR_1_LATIN1_HEX}.txt", lines[0] |
|
184 | assert_equal "test-#{CHAR_1_LATIN1_HEX}.txt", lines[0] | |
185 | end |
|
185 | end | |
186 |
|
186 | |||
187 | def test_annotate_latin1_path |
|
187 | def test_annotate_latin1_path | |
188 | latin1_repo = create_latin1_repo |
|
188 | latin1_repo = create_latin1_repo | |
189 | ann1 = latin1_repo.annotate( |
|
189 | ann1 = latin1_repo.annotate( | |
190 | "test-#{CHAR_1_UTF8_HEX}-dir/test-#{CHAR_1_UTF8_HEX}-2.txt", 2) |
|
190 | "test-#{CHAR_1_UTF8_HEX}-dir/test-#{CHAR_1_UTF8_HEX}-2.txt", 2) | |
191 | assert_equal 2, ann1.lines.size |
|
191 | assert_equal 2, ann1.lines.size | |
192 | assert_equal '2', ann1.revisions[0].identifier |
|
192 | assert_equal '2', ann1.revisions[0].identifier | |
193 | assert_equal 'test00@', ann1.revisions[0].author |
|
193 | assert_equal 'test00@', ann1.revisions[0].author | |
194 | assert_equal 'It is written in Python.', ann1.lines[1] |
|
194 | assert_equal 'It is written in Python.', ann1.lines[1] | |
195 | ann2 = latin1_repo.annotate( |
|
195 | ann2 = latin1_repo.annotate( | |
196 | "test-#{CHAR_1_UTF8_HEX}-dir/test-#{CHAR_1_UTF8_HEX}-1.txt", 2) |
|
196 | "test-#{CHAR_1_UTF8_HEX}-dir/test-#{CHAR_1_UTF8_HEX}-1.txt", 2) | |
197 | assert_equal 1, ann2.lines.size |
|
197 | assert_equal 1, ann2.lines.size | |
198 | assert_equal '2', ann2.revisions[0].identifier |
|
198 | assert_equal '2', ann2.revisions[0].identifier | |
199 | assert_equal 'test00@', ann2.revisions[0].author |
|
199 | assert_equal 'test00@', ann2.revisions[0].author | |
200 | assert_equal "test-#{CHAR_1_LATIN1_HEX}.txt", ann2.lines[0] |
|
200 | assert_equal "test-#{CHAR_1_LATIN1_HEX}.txt", ann2.lines[0] | |
201 | end |
|
201 | end | |
202 |
|
202 | |||
203 | def test_diff_latin1_path |
|
203 | def test_diff_latin1_path | |
204 | latin1_repo = create_latin1_repo |
|
204 | latin1_repo = create_latin1_repo | |
205 | diff1 = latin1_repo.diff( |
|
205 | diff1 = latin1_repo.diff( | |
206 | "test-#{CHAR_1_UTF8_HEX}-dir/test-#{CHAR_1_UTF8_HEX}-1.txt", 2, 1) |
|
206 | "test-#{CHAR_1_UTF8_HEX}-dir/test-#{CHAR_1_UTF8_HEX}-1.txt", 2, 1) | |
207 | assert_equal 7, diff1.size |
|
207 | assert_equal 7, diff1.size | |
208 | buf = diff1[5].gsub(/\r\n|\r|\n/, "") |
|
208 | buf = diff1[5].gsub(/\r\n|\r|\n/, "") | |
209 | assert_equal "+test-#{CHAR_1_LATIN1_HEX}.txt", buf |
|
209 | assert_equal "+test-#{CHAR_1_LATIN1_HEX}.txt", buf | |
210 | end |
|
210 | end | |
211 |
|
211 | |||
212 | def test_entries_latin1_path |
|
212 | def test_entries_latin1_path | |
213 | latin1_repo = create_latin1_repo |
|
213 | latin1_repo = create_latin1_repo | |
214 | entries = latin1_repo.entries("test-#{CHAR_1_UTF8_HEX}-dir", 2) |
|
214 | entries = latin1_repo.entries("test-#{CHAR_1_UTF8_HEX}-dir", 2) | |
215 | assert_kind_of Redmine::Scm::Adapters::Entries, entries |
|
215 | assert_kind_of Redmine::Scm::Adapters::Entries, entries | |
216 | assert_equal 3, entries.size |
|
216 | assert_equal 3, entries.size | |
217 | assert_equal 'file', entries[1].kind |
|
217 | assert_equal 'file', entries[1].kind | |
218 | assert_equal "test-#{CHAR_1_UTF8_HEX}-1.txt", entries[0].name |
|
218 | assert_equal "test-#{CHAR_1_UTF8_HEX}-1.txt", entries[0].name | |
219 | assert_equal "test-#{CHAR_1_UTF8_HEX}-dir/test-#{CHAR_1_UTF8_HEX}-1.txt", entries[0].path |
|
219 | assert_equal "test-#{CHAR_1_UTF8_HEX}-dir/test-#{CHAR_1_UTF8_HEX}-1.txt", entries[0].path | |
220 | end |
|
220 | end | |
221 |
|
221 | |||
222 | def test_entry_latin1_path |
|
222 | def test_entry_latin1_path | |
223 | latin1_repo = create_latin1_repo |
|
223 | latin1_repo = create_latin1_repo | |
224 | ["test-#{CHAR_1_UTF8_HEX}-dir", |
|
224 | ["test-#{CHAR_1_UTF8_HEX}-dir", | |
225 | "/test-#{CHAR_1_UTF8_HEX}-dir", |
|
225 | "/test-#{CHAR_1_UTF8_HEX}-dir", | |
226 | "/test-#{CHAR_1_UTF8_HEX}-dir/" |
|
226 | "/test-#{CHAR_1_UTF8_HEX}-dir/" | |
227 | ].each do |path| |
|
227 | ].each do |path| | |
228 | entry = latin1_repo.entry(path, 2) |
|
228 | entry = latin1_repo.entry(path, 2) | |
229 | assert_equal "test-#{CHAR_1_UTF8_HEX}-dir", entry.path |
|
229 | assert_equal "test-#{CHAR_1_UTF8_HEX}-dir", entry.path | |
230 | assert_equal "dir", entry.kind |
|
230 | assert_equal "dir", entry.kind | |
231 | end |
|
231 | end | |
232 | ["test-#{CHAR_1_UTF8_HEX}-dir/test-#{CHAR_1_UTF8_HEX}-1.txt", |
|
232 | ["test-#{CHAR_1_UTF8_HEX}-dir/test-#{CHAR_1_UTF8_HEX}-1.txt", | |
233 | "/test-#{CHAR_1_UTF8_HEX}-dir/test-#{CHAR_1_UTF8_HEX}-1.txt" |
|
233 | "/test-#{CHAR_1_UTF8_HEX}-dir/test-#{CHAR_1_UTF8_HEX}-1.txt" | |
234 | ].each do |path| |
|
234 | ].each do |path| | |
235 | entry = latin1_repo.entry(path, 2) |
|
235 | entry = latin1_repo.entry(path, 2) | |
236 | assert_equal "test-#{CHAR_1_UTF8_HEX}-dir/test-#{CHAR_1_UTF8_HEX}-1.txt", |
|
236 | assert_equal "test-#{CHAR_1_UTF8_HEX}-dir/test-#{CHAR_1_UTF8_HEX}-1.txt", | |
237 | entry.path |
|
237 | entry.path | |
238 | assert_equal "file", entry.kind |
|
238 | assert_equal "file", entry.kind | |
239 | end |
|
239 | end | |
240 | end |
|
240 | end | |
241 |
|
241 | |||
242 | def test_changeset_latin1_path |
|
242 | def test_changeset_latin1_path | |
243 | latin1_repo = create_latin1_repo |
|
243 | latin1_repo = create_latin1_repo | |
244 | assert_equal 0, latin1_repo.changesets.count |
|
244 | assert_equal 0, latin1_repo.changesets.count | |
245 | latin1_repo.fetch_changesets |
|
245 | latin1_repo.fetch_changesets | |
246 | @project.reload |
|
246 | @project.reload | |
247 | assert_equal 3, latin1_repo.changesets.count |
|
247 | assert_equal 3, latin1_repo.changesets.count | |
248 |
|
248 | |||
249 | cs2 = latin1_repo.changesets.find_by_revision('2') |
|
249 | cs2 = latin1_repo.changesets.find_by_revision('2') | |
250 | assert_not_nil cs2 |
|
250 | assert_not_nil cs2 | |
251 | assert_equal "test-#{CHAR_1_UTF8_HEX}", cs2.comments |
|
251 | assert_equal "test-#{CHAR_1_UTF8_HEX}", cs2.comments | |
252 | c2 = cs2.filechanges.sort_by(&:path) |
|
252 | c2 = cs2.filechanges.sort_by(&:path) | |
253 | assert_equal 4, c2.size |
|
253 | assert_equal 4, c2.size | |
254 | assert_equal 'A', c2[0].action |
|
254 | assert_equal 'A', c2[0].action | |
255 | assert_equal "/test-#{CHAR_1_UTF8_HEX}-dir/", c2[0].path |
|
255 | assert_equal "/test-#{CHAR_1_UTF8_HEX}-dir/", c2[0].path | |
256 | assert_equal 'A', c2[1].action |
|
256 | assert_equal 'A', c2[1].action | |
257 | assert_equal "/test-#{CHAR_1_UTF8_HEX}-dir/test-#{CHAR_1_UTF8_HEX}-1.txt", c2[1].path |
|
257 | assert_equal "/test-#{CHAR_1_UTF8_HEX}-dir/test-#{CHAR_1_UTF8_HEX}-1.txt", c2[1].path | |
258 | assert_equal 'A', c2[2].action |
|
258 | assert_equal 'A', c2[2].action | |
259 | assert_equal "/test-#{CHAR_1_UTF8_HEX}-dir/test-#{CHAR_1_UTF8_HEX}-2.txt", c2[2].path |
|
259 | assert_equal "/test-#{CHAR_1_UTF8_HEX}-dir/test-#{CHAR_1_UTF8_HEX}-2.txt", c2[2].path | |
260 | assert_equal 'A', c2[3].action |
|
260 | assert_equal 'A', c2[3].action | |
261 | assert_equal "/test-#{CHAR_1_UTF8_HEX}-dir/test-#{CHAR_1_UTF8_HEX}.txt", c2[3].path |
|
261 | assert_equal "/test-#{CHAR_1_UTF8_HEX}-dir/test-#{CHAR_1_UTF8_HEX}.txt", c2[3].path | |
262 |
|
262 | |||
263 | cs3 = latin1_repo.changesets.find_by_revision('3') |
|
263 | cs3 = latin1_repo.changesets.find_by_revision('3') | |
264 | assert_not_nil cs3 |
|
264 | assert_not_nil cs3 | |
265 | assert_equal "modify, move and delete #{CHAR_1_UTF8_HEX} files", cs3.comments |
|
265 | assert_equal "modify, move and delete #{CHAR_1_UTF8_HEX} files", cs3.comments | |
266 | c3 = cs3.filechanges.sort_by(&:path) |
|
266 | c3 = cs3.filechanges.sort_by(&:path) | |
267 | assert_equal 3, c3.size |
|
267 | assert_equal 3, c3.size | |
268 | assert_equal 'M', c3[0].action |
|
268 | assert_equal 'M', c3[0].action | |
269 | assert_equal "/test-#{CHAR_1_UTF8_HEX}-1.txt", c3[0].path |
|
269 | assert_equal "/test-#{CHAR_1_UTF8_HEX}-1.txt", c3[0].path | |
270 | assert_equal 'D', c3[1].action |
|
270 | assert_equal 'D', c3[1].action | |
271 | assert_equal "/test-#{CHAR_1_UTF8_HEX}-dir/test-#{CHAR_1_UTF8_HEX}-2.txt", c3[1].path |
|
271 | assert_equal "/test-#{CHAR_1_UTF8_HEX}-dir/test-#{CHAR_1_UTF8_HEX}-2.txt", c3[1].path | |
272 | assert_equal 'M', c3[2].action |
|
272 | assert_equal 'M', c3[2].action | |
273 | assert_equal "/test-#{CHAR_1_UTF8_HEX}-dir/test-#{CHAR_1_UTF8_HEX}.txt", c3[2].path |
|
273 | assert_equal "/test-#{CHAR_1_UTF8_HEX}-dir/test-#{CHAR_1_UTF8_HEX}.txt", c3[2].path | |
274 | end |
|
274 | end | |
275 | else |
|
275 | else | |
276 | msg = "Bazaar non ASCII output test cannot run this environment.\n" |
|
276 | msg = "Bazaar non ASCII output test cannot run on this environment.\n" | |
277 | msg += "Encoding.locale_charmap: " + Encoding.locale_charmap + "\n" |
|
277 | msg += "Encoding.locale_charmap: " + Encoding.locale_charmap + "\n" | |
278 | puts msg |
|
278 | puts msg | |
279 | end |
|
279 | end | |
280 |
|
280 | |||
281 | private |
|
281 | private | |
282 |
|
282 | |||
283 | def create_latin1_repo |
|
283 | def create_latin1_repo | |
284 | repo = Repository::Bazaar.create( |
|
284 | repo = Repository::Bazaar.create( | |
285 | :project => @project, |
|
285 | :project => @project, | |
286 | :identifier => 'latin1', |
|
286 | :identifier => 'latin1', | |
287 | :url => REPOSITORY_PATH_NON_ASCII, |
|
287 | :url => REPOSITORY_PATH_NON_ASCII, | |
288 | :log_encoding => 'ISO-8859-1' |
|
288 | :log_encoding => 'ISO-8859-1' | |
289 | ) |
|
289 | ) | |
290 | assert repo |
|
290 | assert repo | |
291 | repo |
|
291 | repo | |
292 | end |
|
292 | end | |
293 | else |
|
293 | else | |
294 | puts "Bazaar test repository NOT FOUND. Skipping unit tests !!!" |
|
294 | puts "Bazaar test repository NOT FOUND. Skipping unit tests !!!" | |
295 | def test_fake; assert true end |
|
295 | def test_fake; assert true end | |
296 | end |
|
296 | end | |
297 | end |
|
297 | end |
General Comments 0
You need to be logged in to leave comments.
Login now