Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: utils/tests/pub/validator_test.dart

Issue 11943005: Make integration tests a bit cleaner. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « utils/tests/pub/update/pub_update_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library validator_test; 5 library validator_test;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:io'; 8 import 'dart:io';
9 import 'dart:json' as json; 9 import 'dart:json' as json;
10 10
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 48
49 Validator pubspecField(Entrypoint entrypoint) => 49 Validator pubspecField(Entrypoint entrypoint) =>
50 new PubspecFieldValidator(entrypoint); 50 new PubspecFieldValidator(entrypoint);
51 51
52 void scheduleNormalPackage() => normalPackage.scheduleCreate(); 52 void scheduleNormalPackage() => normalPackage.scheduleCreate();
53 53
54 main() { 54 main() {
55 group('should consider a package valid if it', () { 55 group('should consider a package valid if it', () {
56 setUp(scheduleNormalPackage); 56 setUp(scheduleNormalPackage);
57 57
58 test('looks normal', () { 58 integration('looks normal', () {
59 dir(appPath, [libPubspec("test_pkg", "1.0.0")]).scheduleCreate(); 59 dir(appPath, [libPubspec("test_pkg", "1.0.0")]).scheduleCreate();
60 expectNoValidationError(dependency); 60 expectNoValidationError(dependency);
61 expectNoValidationError(lib); 61 expectNoValidationError(lib);
62 expectNoValidationError(license); 62 expectNoValidationError(license);
63 expectNoValidationError(name); 63 expectNoValidationError(name);
64 expectNoValidationError(pubspecField); 64 expectNoValidationError(pubspecField);
65 run();
66 }); 65 });
67 66
68 test('has a COPYING file', () { 67 integration('has a COPYING file', () {
69 file(join(appPath, 'LICENSE'), '').scheduleDelete(); 68 file(join(appPath, 'LICENSE'), '').scheduleDelete();
70 file(join(appPath, 'COPYING'), '').scheduleCreate(); 69 file(join(appPath, 'COPYING'), '').scheduleCreate();
71 expectNoValidationError(license); 70 expectNoValidationError(license);
72 run();
73 }); 71 });
74 72
75 test('has a prefixed LICENSE file', () { 73 integration('has a prefixed LICENSE file', () {
76 file(join(appPath, 'LICENSE'), '').scheduleDelete(); 74 file(join(appPath, 'LICENSE'), '').scheduleDelete();
77 file(join(appPath, 'MIT_LICENSE'), '').scheduleCreate(); 75 file(join(appPath, 'MIT_LICENSE'), '').scheduleCreate();
78 expectNoValidationError(license); 76 expectNoValidationError(license);
79 run();
80 }); 77 });
81 78
82 test('has a suffixed LICENSE file', () { 79 integration('has a suffixed LICENSE file', () {
83 file(join(appPath, 'LICENSE'), '').scheduleDelete(); 80 file(join(appPath, 'LICENSE'), '').scheduleDelete();
84 file(join(appPath, 'LICENSE.md'), '').scheduleCreate(); 81 file(join(appPath, 'LICENSE.md'), '').scheduleCreate();
85 expectNoValidationError(license); 82 expectNoValidationError(license);
86 run();
87 }); 83 });
88 84
89 test('has "authors" instead of "author"', () { 85 integration('has "authors" instead of "author"', () {
90 var package = package("test_pkg", "1.0.0"); 86 var package = package("test_pkg", "1.0.0");
91 package["authors"] = [package.remove("author")]; 87 package["authors"] = [package.remove("author")];
92 dir(appPath, [pubspec(package)]).scheduleCreate(); 88 dir(appPath, [pubspec(package)]).scheduleCreate();
93 expectNoValidationError(pubspecField); 89 expectNoValidationError(pubspecField);
94 run();
95 }); 90 });
96 91
97 test('has a badly-named library in lib/src', () { 92 integration('has a badly-named library in lib/src', () {
98 dir(appPath, [ 93 dir(appPath, [
99 libPubspec("test_pkg", "1.0.0"), 94 libPubspec("test_pkg", "1.0.0"),
100 dir("lib", [ 95 dir("lib", [
101 file("test_pkg.dart", "int i = 1;"), 96 file("test_pkg.dart", "int i = 1;"),
102 dir("src", [file("8ball.dart", "int j = 2;")]) 97 dir("src", [file("8ball.dart", "int j = 2;")])
103 ]) 98 ])
104 ]).scheduleCreate(); 99 ]).scheduleCreate();
105 expectNoValidationError(name); 100 expectNoValidationError(name);
106 run();
107 }); 101 });
108 102
109 test('has a non-Dart file in lib', () { 103 integration('has a non-Dart file in lib', () {
110 dir(appPath, [ 104 dir(appPath, [
111 libPubspec("test_pkg", "1.0.0"), 105 libPubspec("test_pkg", "1.0.0"),
112 dir("lib", [ 106 dir("lib", [
113 file("thing.txt", "woo hoo") 107 file("thing.txt", "woo hoo")
114 ]) 108 ])
115 ]).scheduleCreate(); 109 ]).scheduleCreate();
116 expectNoValidationError(lib); 110 expectNoValidationError(lib);
117 run();
118 }); 111 });
119 112
120 test('has an unconstrained dependency on "unittest"', () { 113 integration('has an unconstrained dependency on "unittest"', () {
121 dir(appPath, [ 114 dir(appPath, [
122 libPubspec("test_pkg", "1.0.0", [ 115 libPubspec("test_pkg", "1.0.0", [
123 {'hosted': 'unittest'} 116 {'hosted': 'unittest'}
124 ]) 117 ])
125 ]).scheduleCreate(); 118 ]).scheduleCreate();
126 expectNoValidationError(dependency); 119 expectNoValidationError(dependency);
127 run();
128 }); 120 });
129 121
130 test('has a nested directory named "tools"', () { 122 integration('has a nested directory named "tools"', () {
131 dir(appPath, [ 123 dir(appPath, [
132 dir("foo", [dir("tools")]) 124 dir("foo", [dir("tools")])
133 ]).scheduleCreate(); 125 ]).scheduleCreate();
134 expectNoValidationError(directory); 126 expectNoValidationError(directory);
135 run();
136 }); 127 });
137 }); 128 });
138 129
139 group('should consider a package invalid if it', () { 130 group('should consider a package invalid if it', () {
140 setUp(scheduleNormalPackage); 131 setUp(scheduleNormalPackage);
141 132
142 test('is missing the "homepage" field', () { 133 integration('is missing the "homepage" field', () {
143 var package = package("test_pkg", "1.0.0"); 134 var package = package("test_pkg", "1.0.0");
144 package.remove("homepage"); 135 package.remove("homepage");
145 dir(appPath, [pubspec(package)]).scheduleCreate(); 136 dir(appPath, [pubspec(package)]).scheduleCreate();
146 137
147 expectValidationError(pubspecField); 138 expectValidationError(pubspecField);
148 run();
149 }); 139 });
150 140
151 test('is missing the "description" field', () { 141 integration('is missing the "description" field', () {
152 var package = package("test_pkg", "1.0.0"); 142 var package = package("test_pkg", "1.0.0");
153 package.remove("description"); 143 package.remove("description");
154 dir(appPath, [pubspec(package)]).scheduleCreate(); 144 dir(appPath, [pubspec(package)]).scheduleCreate();
155 145
156 expectValidationError(pubspecField); 146 expectValidationError(pubspecField);
157 run();
158 }); 147 });
159 148
160 test('is missing the "author" field', () { 149 integration('is missing the "author" field', () {
161 var package = package("test_pkg", "1.0.0"); 150 var package = package("test_pkg", "1.0.0");
162 package.remove("author"); 151 package.remove("author");
163 dir(appPath, [pubspec(package)]).scheduleCreate(); 152 dir(appPath, [pubspec(package)]).scheduleCreate();
164 153
165 expectValidationError(pubspecField); 154 expectValidationError(pubspecField);
166 run();
167 }); 155 });
168 156
169 test('has a single author without an email', () { 157 integration('has a single author without an email', () {
170 var package = package("test_pkg", "1.0.0"); 158 var package = package("test_pkg", "1.0.0");
171 package["author"] = "Nathan Weizenbaum"; 159 package["author"] = "Nathan Weizenbaum";
172 dir(appPath, [pubspec(package)]).scheduleCreate(); 160 dir(appPath, [pubspec(package)]).scheduleCreate();
173 161
174 expectValidationWarning(pubspecField); 162 expectValidationWarning(pubspecField);
175 run();
176 }); 163 });
177 164
178 test('has one of several authors without an email', () { 165 integration('has one of several authors without an email', () {
179 var package = package("test_pkg", "1.0.0"); 166 var package = package("test_pkg", "1.0.0");
180 package.remove("author"); 167 package.remove("author");
181 package["authors"] = [ 168 package["authors"] = [
182 "Bob Nystrom <rnystrom@google.com>", 169 "Bob Nystrom <rnystrom@google.com>",
183 "Nathan Weizenbaum", 170 "Nathan Weizenbaum",
184 "John Messerly <jmesserly@google.com>" 171 "John Messerly <jmesserly@google.com>"
185 ]; 172 ];
186 dir(appPath, [pubspec(package)]).scheduleCreate(); 173 dir(appPath, [pubspec(package)]).scheduleCreate();
187 174
188 expectValidationWarning(pubspecField); 175 expectValidationWarning(pubspecField);
189 run();
190 }); 176 });
191 177
192 test('has a single author without a name', () { 178 integration('has a single author without a name', () {
193 var package = package("test_pkg", "1.0.0"); 179 var package = package("test_pkg", "1.0.0");
194 package["author"] = "<nweiz@google.com>"; 180 package["author"] = "<nweiz@google.com>";
195 dir(appPath, [pubspec(package)]).scheduleCreate(); 181 dir(appPath, [pubspec(package)]).scheduleCreate();
196 182
197 expectValidationWarning(pubspecField); 183 expectValidationWarning(pubspecField);
198 run();
199 }); 184 });
200 185
201 test('has one of several authors without a name', () { 186 integration('has one of several authors without a name', () {
202 var package = package("test_pkg", "1.0.0"); 187 var package = package("test_pkg", "1.0.0");
203 package.remove("author"); 188 package.remove("author");
204 package["authors"] = [ 189 package["authors"] = [
205 "Bob Nystrom <rnystrom@google.com>", 190 "Bob Nystrom <rnystrom@google.com>",
206 "<nweiz@google.com>", 191 "<nweiz@google.com>",
207 "John Messerly <jmesserly@google.com>" 192 "John Messerly <jmesserly@google.com>"
208 ]; 193 ];
209 dir(appPath, [pubspec(package)]).scheduleCreate(); 194 dir(appPath, [pubspec(package)]).scheduleCreate();
210 195
211 expectValidationWarning(pubspecField); 196 expectValidationWarning(pubspecField);
212 run();
213 }); 197 });
214 198
215 test('has no LICENSE file', () { 199 integration('has no LICENSE file', () {
216 file(join(appPath, 'LICENSE'), '').scheduleDelete(); 200 file(join(appPath, 'LICENSE'), '').scheduleDelete();
217 expectValidationError(license); 201 expectValidationError(license);
218 run();
219 }); 202 });
220 203
221 test('has an empty package name', () { 204 integration('has an empty package name', () {
222 dir(appPath, [libPubspec("", "1.0.0")]).scheduleCreate(); 205 dir(appPath, [libPubspec("", "1.0.0")]).scheduleCreate();
223 expectValidationError(name); 206 expectValidationError(name);
224 run();
225 }); 207 });
226 208
227 test('has a package name with an invalid character', () { 209 integration('has a package name with an invalid character', () {
228 dir(appPath, [libPubspec("test-pkg", "1.0.0")]).scheduleCreate(); 210 dir(appPath, [libPubspec("test-pkg", "1.0.0")]).scheduleCreate();
229 expectValidationError(name); 211 expectValidationError(name);
230 run();
231 }); 212 });
232 213
233 test('has a package name that begins with a number', () { 214 integration('has a package name that begins with a number', () {
234 dir(appPath, [libPubspec("8ball", "1.0.0")]).scheduleCreate(); 215 dir(appPath, [libPubspec("8ball", "1.0.0")]).scheduleCreate();
235 expectValidationError(name); 216 expectValidationError(name);
236 run();
237 }); 217 });
238 218
239 test('has a package name that contains upper-case letters', () { 219 integration('has a package name that contains upper-case letters', () {
240 dir(appPath, [libPubspec("TestPkg", "1.0.0")]).scheduleCreate(); 220 dir(appPath, [libPubspec("TestPkg", "1.0.0")]).scheduleCreate();
241 expectValidationWarning(name); 221 expectValidationWarning(name);
242 run();
243 }); 222 });
244 223
245 test('has a package name that is a Dart reserved word', () { 224 integration('has a package name that is a Dart reserved word', () {
246 dir(appPath, [libPubspec("operator", "1.0.0")]).scheduleCreate(); 225 dir(appPath, [libPubspec("operator", "1.0.0")]).scheduleCreate();
247 expectValidationError(name); 226 expectValidationError(name);
248 run();
249 }); 227 });
250 228
251 test('has a library name with an invalid character', () { 229 integration('has a library name with an invalid character', () {
252 dir(appPath, [ 230 dir(appPath, [
253 libPubspec("test_pkg", "1.0.0"), 231 libPubspec("test_pkg", "1.0.0"),
254 dir("lib", [file("test-pkg.dart", "int i = 0;")]) 232 dir("lib", [file("test-pkg.dart", "int i = 0;")])
255 ]).scheduleCreate(); 233 ]).scheduleCreate();
256 expectValidationError(name); 234 expectValidationError(name);
257 run();
258 }); 235 });
259 236
260 test('has a library name that begins with a number', () { 237 integration('has a library name that begins with a number', () {
261 dir(appPath, [ 238 dir(appPath, [
262 libPubspec("test_pkg", "1.0.0"), 239 libPubspec("test_pkg", "1.0.0"),
263 dir("lib", [file("8ball.dart", "int i = 0;")]) 240 dir("lib", [file("8ball.dart", "int i = 0;")])
264 ]).scheduleCreate(); 241 ]).scheduleCreate();
265 expectValidationError(name); 242 expectValidationError(name);
266 run();
267 }); 243 });
268 244
269 test('has a library name that contains upper-case letters', () { 245 integration('has a library name that contains upper-case letters', () {
270 dir(appPath, [ 246 dir(appPath, [
271 libPubspec("test_pkg", "1.0.0"), 247 libPubspec("test_pkg", "1.0.0"),
272 dir("lib", [file("TestPkg.dart", "int i = 0;")]) 248 dir("lib", [file("TestPkg.dart", "int i = 0;")])
273 ]).scheduleCreate(); 249 ]).scheduleCreate();
274 expectValidationWarning(name); 250 expectValidationWarning(name);
275 run();
276 }); 251 });
277 252
278 test('has a library name that is a Dart reserved word', () { 253 integration('has a library name that is a Dart reserved word', () {
279 dir(appPath, [ 254 dir(appPath, [
280 libPubspec("test_pkg", "1.0.0"), 255 libPubspec("test_pkg", "1.0.0"),
281 dir("lib", [file("operator.dart", "int i = 0;")]) 256 dir("lib", [file("operator.dart", "int i = 0;")])
282 ]).scheduleCreate(); 257 ]).scheduleCreate();
283 expectValidationError(name); 258 expectValidationError(name);
284 run();
285 }); 259 });
286 260
287 test('has a single library named differently than the package', () { 261 integration('has a single library named differently than the package', () {
288 file(join(appPath, "lib", "test_pkg.dart"), '').scheduleDelete(); 262 file(join(appPath, "lib", "test_pkg.dart"), '').scheduleDelete();
289 dir(appPath, [ 263 dir(appPath, [
290 dir("lib", [file("best_pkg.dart", "int i = 0;")]) 264 dir("lib", [file("best_pkg.dart", "int i = 0;")])
291 ]).scheduleCreate(); 265 ]).scheduleCreate();
292 expectValidationWarning(name); 266 expectValidationWarning(name);
293 run();
294 }); 267 });
295 268
296 test('has no lib directory', () { 269 integration('has no lib directory', () {
297 dir(join(appPath, "lib")).scheduleDelete(); 270 dir(join(appPath, "lib")).scheduleDelete();
298 expectValidationError(lib); 271 expectValidationError(lib);
299 run();
300 }); 272 });
301 273
302 test('has an empty lib directory', () { 274 integration('has an empty lib directory', () {
303 file(join(appPath, "lib", "test_pkg.dart"), '').scheduleDelete(); 275 file(join(appPath, "lib", "test_pkg.dart"), '').scheduleDelete();
304 expectValidationError(lib); 276 expectValidationError(lib);
305 run();
306 }); 277 });
307 278
308 test('has a lib directory containing only src', () { 279 integration('has a lib directory containing only src', () {
309 file(join(appPath, "lib", "test_pkg.dart"), '').scheduleDelete(); 280 file(join(appPath, "lib", "test_pkg.dart"), '').scheduleDelete();
310 dir(appPath, [ 281 dir(appPath, [
311 dir("lib", [ 282 dir("lib", [
312 dir("src", [file("test_pkg.dart", "int i = 0;")]) 283 dir("src", [file("test_pkg.dart", "int i = 0;")])
313 ]) 284 ])
314 ]).scheduleCreate(); 285 ]).scheduleCreate();
315 expectValidationError(lib); 286 expectValidationError(lib);
316 run();
317 }); 287 });
318 288
319 group('has a dependency with a non-hosted source', () { 289 group('has a dependency with a non-hosted source', () {
320 group('where a hosted version of that dependency exists', () { 290 group('where a hosted version of that dependency exists', () {
321 test("and should suggest the hosted package's primary version", () { 291 integration("and should suggest the hosted package's primary "
292 "version", () {
322 useMockClient(new MockClient((request) { 293 useMockClient(new MockClient((request) {
323 expect(request.method, equals("GET")); 294 expect(request.method, equals("GET"));
324 expect(request.url.path, equals("/packages/foo.json")); 295 expect(request.url.path, equals("/packages/foo.json"));
325 296
326 return new Future.immediate(new http.Response(json.stringify({ 297 return new Future.immediate(new http.Response(json.stringify({
327 "name": "foo", 298 "name": "foo",
328 "uploaders": ["nweiz@google.com"], 299 "uploaders": ["nweiz@google.com"],
329 "versions": ["3.0.0-pre", "2.0.0", "1.0.0"] 300 "versions": ["3.0.0-pre", "2.0.0", "1.0.0"]
330 }), 200)); 301 }), 200));
331 })); 302 }));
332 303
333 dir(appPath, [ 304 dir(appPath, [
334 libPubspec("test_pkg", "1.0.0", [ 305 libPubspec("test_pkg", "1.0.0", [
335 {'git': 'git://github.com/dart-lang/foo'} 306 {'git': 'git://github.com/dart-lang/foo'}
336 ]) 307 ])
337 ]).scheduleCreate(); 308 ]).scheduleCreate();
338 309
339 expectLater(schedulePackageValidation(dependency), 310 expectLater(schedulePackageValidation(dependency),
340 pairOf(isEmpty, someElement(contains( 311 pairOf(isEmpty, someElement(contains(
341 ' foo: ">=2.0.0 <3.0.0"')))); 312 ' foo: ">=2.0.0 <3.0.0"'))));
342
343 run();
344 }); 313 });
345 314
346 test("and should suggest the hosted package's prerelease version if " 315 integration("and should suggest the hosted package's prerelease "
347 "it's the only version available", () { 316 "version if it's the only version available", () {
348 useMockClient(new MockClient((request) { 317 useMockClient(new MockClient((request) {
349 expect(request.method, equals("GET")); 318 expect(request.method, equals("GET"));
350 expect(request.url.path, equals("/packages/foo.json")); 319 expect(request.url.path, equals("/packages/foo.json"));
351 320
352 return new Future.immediate(new http.Response(json.stringify({ 321 return new Future.immediate(new http.Response(json.stringify({
353 "name": "foo", 322 "name": "foo",
354 "uploaders": ["nweiz@google.com"], 323 "uploaders": ["nweiz@google.com"],
355 "versions": ["3.0.0-pre", "2.0.0-pre"] 324 "versions": ["3.0.0-pre", "2.0.0-pre"]
356 }), 200)); 325 }), 200));
357 })); 326 }));
358 327
359 dir(appPath, [ 328 dir(appPath, [
360 libPubspec("test_pkg", "1.0.0", [ 329 libPubspec("test_pkg", "1.0.0", [
361 {'git': 'git://github.com/dart-lang/foo'} 330 {'git': 'git://github.com/dart-lang/foo'}
362 ]) 331 ])
363 ]).scheduleCreate(); 332 ]).scheduleCreate();
364 333
365 expectLater(schedulePackageValidation(dependency), 334 expectLater(schedulePackageValidation(dependency),
366 pairOf(isEmpty, someElement(contains( 335 pairOf(isEmpty, someElement(contains(
367 ' foo: ">=3.0.0-pre <4.0.0"')))); 336 ' foo: ">=3.0.0-pre <4.0.0"'))));
368
369 run();
370 }); 337 });
371 338
372 test("and should suggest a tighter constraint if the primary version " 339 integration("and should suggest a tighter constraint if the primary "
373 "is pre-1.0.0", () { 340 "version is pre-1.0.0", () {
374 useMockClient(new MockClient((request) { 341 useMockClient(new MockClient((request) {
375 expect(request.method, equals("GET")); 342 expect(request.method, equals("GET"));
376 expect(request.url.path, equals("/packages/foo.json")); 343 expect(request.url.path, equals("/packages/foo.json"));
377 344
378 return new Future.immediate(new http.Response(json.stringify({ 345 return new Future.immediate(new http.Response(json.stringify({
379 "name": "foo", 346 "name": "foo",
380 "uploaders": ["nweiz@google.com"], 347 "uploaders": ["nweiz@google.com"],
381 "versions": ["0.0.1", "0.0.2"] 348 "versions": ["0.0.1", "0.0.2"]
382 }), 200)); 349 }), 200));
383 })); 350 }));
384 351
385 dir(appPath, [ 352 dir(appPath, [
386 libPubspec("test_pkg", "1.0.0", [ 353 libPubspec("test_pkg", "1.0.0", [
387 {'git': 'git://github.com/dart-lang/foo'} 354 {'git': 'git://github.com/dart-lang/foo'}
388 ]) 355 ])
389 ]).scheduleCreate(); 356 ]).scheduleCreate();
390 357
391 expectLater(schedulePackageValidation(dependency), 358 expectLater(schedulePackageValidation(dependency),
392 pairOf(isEmpty, someElement(contains( 359 pairOf(isEmpty, someElement(contains(
393 ' foo: ">=0.0.2 <0.0.3"')))); 360 ' foo: ">=0.0.2 <0.0.3"'))));
394
395 run();
396 }); 361 });
397 }); 362 });
398 363
399 group('where no hosted version of that dependency exists', () { 364 group('where no hosted version of that dependency exists', () {
400 test("and should use the other source's version", () { 365 integration("and should use the other source's version", () {
401 useMockClient(new MockClient((request) { 366 useMockClient(new MockClient((request) {
402 expect(request.method, equals("GET")); 367 expect(request.method, equals("GET"));
403 expect(request.url.path, equals("/packages/foo.json")); 368 expect(request.url.path, equals("/packages/foo.json"));
404 369
405 return new Future.immediate(new http.Response("not found", 404)); 370 return new Future.immediate(new http.Response("not found", 404));
406 })); 371 }));
407 372
408 dir(appPath, [ 373 dir(appPath, [
409 libPubspec("test_pkg", "1.0.0", [ 374 libPubspec("test_pkg", "1.0.0", [
410 { 375 {
411 'git': {'url': 'git://github.com/dart-lang/foo'}, 376 'git': {'url': 'git://github.com/dart-lang/foo'},
412 'version': '>=1.0.0 <2.0.0' 377 'version': '>=1.0.0 <2.0.0'
413 } 378 }
414 ]) 379 ])
415 ]).scheduleCreate(); 380 ]).scheduleCreate();
416 381
417 expectLater(schedulePackageValidation(dependency), 382 expectLater(schedulePackageValidation(dependency),
418 pairOf(isEmpty, someElement(contains( 383 pairOf(isEmpty, someElement(contains(
419 ' foo: ">=1.0.0 <2.0.0"')))); 384 ' foo: ">=1.0.0 <2.0.0"'))));
420
421 run();
422 }); 385 });
423 386
424 test("and should use the other source's unquoted version if it's " 387 integration("and should use the other source's unquoted version if "
425 "concrete", () { 388 "it's concrete", () {
426 useMockClient(new MockClient((request) { 389 useMockClient(new MockClient((request) {
427 expect(request.method, equals("GET")); 390 expect(request.method, equals("GET"));
428 expect(request.url.path, equals("/packages/foo.json")); 391 expect(request.url.path, equals("/packages/foo.json"));
429 392
430 return new Future.immediate(new http.Response("not found", 404)); 393 return new Future.immediate(new http.Response("not found", 404));
431 })); 394 }));
432 395
433 dir(appPath, [ 396 dir(appPath, [
434 libPubspec("test_pkg", "1.0.0", [ 397 libPubspec("test_pkg", "1.0.0", [
435 { 398 {
436 'git': {'url': 'git://github.com/dart-lang/foo'}, 399 'git': {'url': 'git://github.com/dart-lang/foo'},
437 'version': '0.2.3' 400 'version': '0.2.3'
438 } 401 }
439 ]) 402 ])
440 ]).scheduleCreate(); 403 ]).scheduleCreate();
441 404
442 expectLater(schedulePackageValidation(dependency), 405 expectLater(schedulePackageValidation(dependency),
443 pairOf(isEmpty, someElement(contains(' foo: 0.2.3')))); 406 pairOf(isEmpty, someElement(contains(' foo: 0.2.3'))));
444
445 run();
446 }); 407 });
447 }); 408 });
448 }); 409 });
449 410
450 group('has an unconstrained dependency', () { 411 group('has an unconstrained dependency', () {
451 group('and it should not suggest a version', () { 412 group('and it should not suggest a version', () {
452 test("if there's no lockfile", () { 413 integration("if there's no lockfile", () {
453 dir(appPath, [ 414 dir(appPath, [
454 libPubspec("test_pkg", "1.0.0", [ 415 libPubspec("test_pkg", "1.0.0", [
455 {'hosted': 'foo'} 416 {'hosted': 'foo'}
456 ]) 417 ])
457 ]).scheduleCreate(); 418 ]).scheduleCreate();
458 419
459 expectLater(schedulePackageValidation(dependency), 420 expectLater(schedulePackageValidation(dependency),
460 pairOf(isEmpty, everyElement(isNot(contains("\n foo:"))))); 421 pairOf(isEmpty, everyElement(isNot(contains("\n foo:")))));
461
462 run();
463 }); 422 });
464 423
465 test("if the lockfile doesn't have an entry for the dependency", () { 424 integration("if the lockfile doesn't have an entry for the "
425 "dependency", () {
466 dir(appPath, [ 426 dir(appPath, [
467 libPubspec("test_pkg", "1.0.0", [ 427 libPubspec("test_pkg", "1.0.0", [
468 {'hosted': 'foo'} 428 {'hosted': 'foo'}
469 ]), 429 ]),
470 file("pubspec.lock", json.stringify({ 430 file("pubspec.lock", json.stringify({
471 'packages': { 431 'packages': {
472 'bar': { 432 'bar': {
473 'version': '1.2.3', 433 'version': '1.2.3',
474 'source': 'hosted', 434 'source': 'hosted',
475 'description': { 435 'description': {
476 'name': 'bar', 436 'name': 'bar',
477 'url': 'http://pub.dartlang.org' 437 'url': 'http://pub.dartlang.org'
478 } 438 }
479 } 439 }
480 } 440 }
481 })) 441 }))
482 ]).scheduleCreate(); 442 ]).scheduleCreate();
483 443
484 expectLater(schedulePackageValidation(dependency), 444 expectLater(schedulePackageValidation(dependency),
485 pairOf(isEmpty, everyElement(isNot(contains("\n foo:"))))); 445 pairOf(isEmpty, everyElement(isNot(contains("\n foo:")))));
486
487 run();
488 }); 446 });
489 }); 447 });
490 448
491 group('with a lockfile', () { 449 group('with a lockfile', () {
492 test('and it should suggest a constraint based on the locked ' 450 integration('and it should suggest a constraint based on the locked '
493 'version', () { 451 'version', () {
494 dir(appPath, [ 452 dir(appPath, [
495 libPubspec("test_pkg", "1.0.0", [ 453 libPubspec("test_pkg", "1.0.0", [
496 {'hosted': 'foo'} 454 {'hosted': 'foo'}
497 ]), 455 ]),
498 file("pubspec.lock", json.stringify({ 456 file("pubspec.lock", json.stringify({
499 'packages': { 457 'packages': {
500 'foo': { 458 'foo': {
501 'version': '1.2.3', 459 'version': '1.2.3',
502 'source': 'hosted', 460 'source': 'hosted',
503 'description': { 461 'description': {
504 'name': 'foo', 462 'name': 'foo',
505 'url': 'http://pub.dartlang.org' 463 'url': 'http://pub.dartlang.org'
506 } 464 }
507 } 465 }
508 } 466 }
509 })) 467 }))
510 ]).scheduleCreate(); 468 ]).scheduleCreate();
511 469
512 expectLater(schedulePackageValidation(dependency), 470 expectLater(schedulePackageValidation(dependency),
513 pairOf(isEmpty, someElement(contains( 471 pairOf(isEmpty, someElement(contains(
514 ' foo: ">=1.2.3 <2.0.0"')))); 472 ' foo: ">=1.2.3 <2.0.0"'))));
515
516 run();
517 }); 473 });
518 474
519 test('and it should suggest a concrete constraint if the locked ' 475 integration('and it should suggest a concrete constraint if the locked '
520 'version is pre-1.0.0', () { 476 'version is pre-1.0.0', () {
521 dir(appPath, [ 477 dir(appPath, [
522 libPubspec("test_pkg", "1.0.0", [ 478 libPubspec("test_pkg", "1.0.0", [
523 {'hosted': 'foo'} 479 {'hosted': 'foo'}
524 ]), 480 ]),
525 file("pubspec.lock", json.stringify({ 481 file("pubspec.lock", json.stringify({
526 'packages': { 482 'packages': {
527 'foo': { 483 'foo': {
528 'version': '0.1.2', 484 'version': '0.1.2',
529 'source': 'hosted', 485 'source': 'hosted',
530 'description': { 486 'description': {
531 'name': 'foo', 487 'name': 'foo',
532 'url': 'http://pub.dartlang.org' 488 'url': 'http://pub.dartlang.org'
533 } 489 }
534 } 490 }
535 } 491 }
536 })) 492 }))
537 ]).scheduleCreate(); 493 ]).scheduleCreate();
538 494
539 expectLater(schedulePackageValidation(dependency), 495 expectLater(schedulePackageValidation(dependency),
540 pairOf(isEmpty, someElement(contains( 496 pairOf(isEmpty, someElement(contains(
541 ' foo: ">=0.1.2 <0.1.3"')))); 497 ' foo: ">=0.1.2 <0.1.3"'))));
542
543 run();
544 }); 498 });
545 }); 499 });
546 }); 500 });
547 501
548 test('has a hosted dependency on itself', () { 502 integration('has a hosted dependency on itself', () {
549 dir(appPath, [ 503 dir(appPath, [
550 libPubspec("test_pkg", "1.0.0", [ 504 libPubspec("test_pkg", "1.0.0", [
551 {'hosted': {'name': 'test_pkg', 'version': '>=1.0.0'}} 505 {'hosted': {'name': 'test_pkg', 'version': '>=1.0.0'}}
552 ]) 506 ])
553 ]).scheduleCreate(); 507 ]).scheduleCreate();
554 508
555 expectValidationWarning(dependency); 509 expectValidationWarning(dependency);
556
557 run();
558 }); 510 });
559 511
560 group('has a top-level directory named', () { 512 group('has a top-level directory named', () {
561 setUp(scheduleNormalPackage); 513 setUp(scheduleNormalPackage);
562 514
563 var names = ["tools", "tests", "docs", "examples", "sample", "samples"]; 515 var names = ["tools", "tests", "docs", "examples", "sample", "samples"];
564 for (var name in names) { 516 for (var name in names) {
565 test('"$name"', () { 517 integration('"$name"', () {
566 dir(appPath, [dir(name)]).scheduleCreate(); 518 dir(appPath, [dir(name)]).scheduleCreate();
567 expectValidationWarning(directory); 519 expectValidationWarning(directory);
568 run();
569 }); 520 });
570 } 521 }
571 }); 522 });
572 }); 523 });
573 } 524 }
OLDNEW
« no previous file with comments | « utils/tests/pub/update/pub_update_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698