OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 import 'dart:async'; | 5 import 'dart:async'; |
6 import 'dart:convert'; | 6 import 'dart:convert'; |
7 | 7 |
8 import 'package:http/http.dart' as http; | 8 import 'package:http/http.dart' as http; |
9 import 'package:http/testing.dart'; | 9 import 'package:http/testing.dart'; |
10 import 'package:path/path.dart' as path; | 10 import 'package:path/path.dart' as path; |
11 import 'package:scheduled_test/scheduled_test.dart'; | 11 import 'package:scheduled_test/scheduled_test.dart'; |
12 | 12 |
13 import '../../lib/src/entrypoint.dart'; | 13 import '../../lib/src/entrypoint.dart'; |
14 import '../../lib/src/validator.dart'; | 14 import '../../lib/src/validator.dart'; |
15 import '../../lib/src/validator/dependency.dart'; | 15 import '../../lib/src/validator/dependency.dart'; |
16 import '../descriptor.dart' as d; | 16 import '../descriptor.dart' as d; |
17 import '../test_pub.dart'; | 17 import '../test_pub.dart'; |
18 import 'utils.dart'; | 18 import 'utils.dart'; |
19 | 19 |
20 Validator dependency(Entrypoint entrypoint) => | 20 Validator dependency(Entrypoint entrypoint) => |
21 new DependencyValidator(entrypoint); | 21 new DependencyValidator(entrypoint); |
22 | 22 |
23 expectDependencyValidationError(String error) { | 23 expectDependencyValidationError(String error) { |
24 expect(schedulePackageValidation(dependency), | 24 expect( |
| 25 schedulePackageValidation(dependency), |
25 completion(pairOf(anyElement(contains(error)), isEmpty))); | 26 completion(pairOf(anyElement(contains(error)), isEmpty))); |
26 } | 27 } |
27 | 28 |
28 expectDependencyValidationWarning(String warning) { | 29 expectDependencyValidationWarning(String warning) { |
29 expect(schedulePackageValidation(dependency), | 30 expect( |
| 31 schedulePackageValidation(dependency), |
30 completion(pairOf(isEmpty, anyElement(contains(warning))))); | 32 completion(pairOf(isEmpty, anyElement(contains(warning))))); |
31 } | 33 } |
32 | 34 |
33 /// Sets up a test package with dependency [dep] and mocks a server with | 35 /// Sets up a test package with dependency [dep] and mocks a server with |
34 /// [hostedVersions] of the package available. | 36 /// [hostedVersions] of the package available. |
35 setUpDependency(Map dep, {List<String> hostedVersions}) { | 37 setUpDependency(Map dep, {List<String> hostedVersions}) { |
36 useMockClient(new MockClient((request) { | 38 useMockClient(new MockClient((request) { |
37 expect(request.method, equals("GET")); | 39 expect(request.method, equals("GET")); |
38 expect(request.url.path, equals("/api/packages/foo")); | 40 expect(request.url.path, equals("/api/packages/foo")); |
39 | 41 |
40 if (hostedVersions == null) { | 42 if (hostedVersions == null) { |
41 return new Future.value(new http.Response("not found", 404)); | 43 return new Future.value(new http.Response("not found", 404)); |
42 } else { | 44 } else { |
43 return new Future.value(new http.Response(JSON.encode({ | 45 return new Future.value(new http.Response(JSON.encode({ |
44 "name": "foo", | 46 "name": "foo", |
45 "uploaders": ["nweiz@google.com"], | 47 "uploaders": ["nweiz@google.com"], |
46 "versions": hostedVersions.map((version) => | 48 "versions": hostedVersions.map( |
47 packageVersionApiMap(packageMap('foo', version))).toList() | 49 (version) => packageVersionApiMap(packageMap('foo', version))).toLis
t() |
48 }), 200)); | 50 }), 200)); |
49 } | 51 } |
50 })); | 52 })); |
51 | 53 |
52 d.dir(appPath, [ | 54 d.dir(appPath, [d.libPubspec("test_pkg", "1.0.0", deps: { |
53 d.libPubspec("test_pkg", "1.0.0", deps: {"foo": dep}) | 55 "foo": dep |
54 ]).create(); | 56 })]).create(); |
55 } | 57 } |
56 | 58 |
57 main() { | 59 main() { |
58 initConfig(); | 60 initConfig(); |
59 | 61 |
60 group('should consider a package valid if it', () { | 62 group('should consider a package valid if it', () { |
61 integration('looks normal', () { | 63 integration('looks normal', () { |
62 d.validPackage.create(); | 64 d.validPackage.create(); |
63 expectNoValidationError(dependency); | 65 expectNoValidationError(dependency); |
64 }); | 66 }); |
65 | 67 |
66 integration('has a ^ constraint with an appropriate SDK constraint', () { | 68 integration('has a ^ constraint with an appropriate SDK constraint', () { |
67 d.dir(appPath, [ | 69 d.dir(appPath, [d.libPubspec("test_pkg", "1.0.0", deps: { |
68 d.libPubspec("test_pkg", "1.0.0", deps: { | |
69 "foo": "^1.2.3" | 70 "foo": "^1.2.3" |
70 }, sdk: ">=1.8.0 <2.0.0") | 71 }, sdk: ">=1.8.0 <2.0.0")]).create(); |
71 ]).create(); | |
72 expectNoValidationError(dependency); | 72 expectNoValidationError(dependency); |
73 }); | 73 }); |
74 }); | 74 }); |
75 | 75 |
76 group('should consider a package invalid if it', () { | 76 group('should consider a package invalid if it', () { |
77 setUp(d.validPackage.create); | 77 setUp(d.validPackage.create); |
78 | 78 |
79 group('has a git dependency', () { | 79 group('has a git dependency', () { |
80 group('where a hosted version exists', () { | 80 group('where a hosted version exists', () { |
81 integration("and should suggest the hosted primary version", () { | 81 integration("and should suggest the hosted primary version", () { |
82 setUpDependency({'git': 'git://github.com/dart-lang/foo'}, | 82 setUpDependency({ |
83 hostedVersions: ["3.0.0-pre", "2.0.0", "1.0.0"]); | 83 'git': 'git://github.com/dart-lang/foo' |
| 84 }, hostedVersions: ["3.0.0-pre", "2.0.0", "1.0.0"]); |
84 expectDependencyValidationWarning(' foo: ">=2.0.0 <3.0.0"'); | 85 expectDependencyValidationWarning(' foo: ">=2.0.0 <3.0.0"'); |
85 }); | 86 }); |
86 | 87 |
87 integration("and should suggest the hosted prerelease version if " | 88 integration( |
88 "it's the only version available", () { | 89 "and should suggest the hosted prerelease version if " |
89 setUpDependency({'git': 'git://github.com/dart-lang/foo'}, | 90 "it's the only version available", |
90 hostedVersions: ["3.0.0-pre", "2.0.0-pre"]); | 91 () { |
| 92 setUpDependency({ |
| 93 'git': 'git://github.com/dart-lang/foo' |
| 94 }, hostedVersions: ["3.0.0-pre", "2.0.0-pre"]); |
91 expectDependencyValidationWarning(' foo: ">=3.0.0-pre <4.0.0"'); | 95 expectDependencyValidationWarning(' foo: ">=3.0.0-pre <4.0.0"'); |
92 }); | 96 }); |
93 | 97 |
94 integration("and should suggest a tighter constraint if primary is " | 98 integration( |
95 "pre-1.0.0", () { | 99 "and should suggest a tighter constraint if primary is " "pre-1.0.0"
, |
96 setUpDependency({'git': 'git://github.com/dart-lang/foo'}, | 100 () { |
97 hostedVersions: ["0.0.1", "0.0.2"]); | 101 setUpDependency({ |
| 102 'git': 'git://github.com/dart-lang/foo' |
| 103 }, hostedVersions: ["0.0.1", "0.0.2"]); |
98 expectDependencyValidationWarning(' foo: ">=0.0.2 <0.1.0"'); | 104 expectDependencyValidationWarning(' foo: ">=0.0.2 <0.1.0"'); |
99 }); | 105 }); |
100 }); | 106 }); |
101 | 107 |
102 group('where no hosted version exists', () { | 108 group('where no hosted version exists', () { |
103 integration("and should use the other source's version", () { | 109 integration("and should use the other source's version", () { |
104 setUpDependency({ | 110 setUpDependency({ |
105 'git': 'git://github.com/dart-lang/foo', | 111 'git': 'git://github.com/dart-lang/foo', |
106 'version': '>=1.0.0 <2.0.0' | 112 'version': '>=1.0.0 <2.0.0' |
107 }); | 113 }); |
108 expectDependencyValidationWarning(' foo: ">=1.0.0 <2.0.0"'); | 114 expectDependencyValidationWarning(' foo: ">=1.0.0 <2.0.0"'); |
109 }); | 115 }); |
110 | 116 |
111 integration("and should use the other source's unquoted version if " | 117 integration( |
112 "concrete", () { | 118 "and should use the other source's unquoted version if " "concrete", |
| 119 () { |
113 setUpDependency({ | 120 setUpDependency({ |
114 'git': 'git://github.com/dart-lang/foo', | 121 'git': 'git://github.com/dart-lang/foo', |
115 'version': '0.2.3' | 122 'version': '0.2.3' |
116 }); | 123 }); |
117 expectDependencyValidationWarning(' foo: 0.2.3'); | 124 expectDependencyValidationWarning(' foo: 0.2.3'); |
118 }); | 125 }); |
119 }); | 126 }); |
120 }); | 127 }); |
121 | 128 |
122 group('has a path dependency', () { | 129 group('has a path dependency', () { |
123 group('where a hosted version exists', () { | 130 group('where a hosted version exists', () { |
124 integration("and should suggest the hosted primary version", () { | 131 integration("and should suggest the hosted primary version", () { |
125 setUpDependency({'path': path.join(sandboxDir, 'foo')}, | 132 setUpDependency({ |
126 hostedVersions: ["3.0.0-pre", "2.0.0", "1.0.0"]); | 133 'path': path.join(sandboxDir, 'foo') |
| 134 }, hostedVersions: ["3.0.0-pre", "2.0.0", "1.0.0"]); |
127 expectDependencyValidationError(' foo: ">=2.0.0 <3.0.0"'); | 135 expectDependencyValidationError(' foo: ">=2.0.0 <3.0.0"'); |
128 }); | 136 }); |
129 | 137 |
130 integration("and should suggest the hosted prerelease version if " | 138 integration( |
131 "it's the only version available", () { | 139 "and should suggest the hosted prerelease version if " |
132 setUpDependency({'path': path.join(sandboxDir, 'foo')}, | 140 "it's the only version available", |
133 hostedVersions: ["3.0.0-pre", "2.0.0-pre"]); | 141 () { |
| 142 setUpDependency({ |
| 143 'path': path.join(sandboxDir, 'foo') |
| 144 }, hostedVersions: ["3.0.0-pre", "2.0.0-pre"]); |
134 expectDependencyValidationError(' foo: ">=3.0.0-pre <4.0.0"'); | 145 expectDependencyValidationError(' foo: ">=3.0.0-pre <4.0.0"'); |
135 }); | 146 }); |
136 | 147 |
137 integration("and should suggest a tighter constraint if primary is " | 148 integration( |
138 "pre-1.0.0", () { | 149 "and should suggest a tighter constraint if primary is " "pre-1.0.0"
, |
139 setUpDependency({'path': path.join(sandboxDir, 'foo')}, | 150 () { |
140 hostedVersions: ["0.0.1", "0.0.2"]); | 151 setUpDependency({ |
| 152 'path': path.join(sandboxDir, 'foo') |
| 153 }, hostedVersions: ["0.0.1", "0.0.2"]); |
141 expectDependencyValidationError(' foo: ">=0.0.2 <0.1.0"'); | 154 expectDependencyValidationError(' foo: ">=0.0.2 <0.1.0"'); |
142 }); | 155 }); |
143 }); | 156 }); |
144 | 157 |
145 group('where no hosted version exists', () { | 158 group('where no hosted version exists', () { |
146 integration("and should use the other source's version", () { | 159 integration("and should use the other source's version", () { |
147 setUpDependency({ | 160 setUpDependency({ |
148 'path': path.join(sandboxDir, 'foo'), | 161 'path': path.join(sandboxDir, 'foo'), |
149 'version': '>=1.0.0 <2.0.0' | 162 'version': '>=1.0.0 <2.0.0' |
150 }); | 163 }); |
151 expectDependencyValidationError(' foo: ">=1.0.0 <2.0.0"'); | 164 expectDependencyValidationError(' foo: ">=1.0.0 <2.0.0"'); |
152 }); | 165 }); |
153 | 166 |
154 integration("and should use the other source's unquoted version if " | 167 integration( |
155 "concrete", () { | 168 "and should use the other source's unquoted version if " "concrete", |
| 169 () { |
156 setUpDependency({ | 170 setUpDependency({ |
157 'path': path.join(sandboxDir, 'foo'), | 171 'path': path.join(sandboxDir, 'foo'), |
158 'version': '0.2.3' | 172 'version': '0.2.3' |
159 }); | 173 }); |
160 expectDependencyValidationError(' foo: 0.2.3'); | 174 expectDependencyValidationError(' foo: 0.2.3'); |
161 }); | 175 }); |
162 }); | 176 }); |
163 }); | 177 }); |
164 | 178 |
165 group('has an unconstrained dependency', () { | 179 group('has an unconstrained dependency', () { |
166 group('and it should not suggest a version', () { | 180 group('and it should not suggest a version', () { |
167 integration("if there's no lockfile", () { | 181 integration("if there's no lockfile", () { |
168 d.dir(appPath, [ | 182 d.dir(appPath, [d.libPubspec("test_pkg", "1.0.0", deps: { |
169 d.libPubspec("test_pkg", "1.0.0", deps: { | |
170 "foo": "any" | 183 "foo": "any" |
171 }) | 184 })]).create(); |
172 ]).create(); | |
173 | 185 |
174 expect(schedulePackageValidation(dependency), completion( | 186 expect( |
175 pairOf(isEmpty, everyElement(isNot(contains("\n foo:")))))); | 187 schedulePackageValidation(dependency), |
| 188 completion(pairOf(isEmpty, everyElement(isNot(contains("\n foo:")
))))); |
176 }); | 189 }); |
177 | 190 |
178 integration("if the lockfile doesn't have an entry for the " | 191 integration( |
179 "dependency", () { | 192 "if the lockfile doesn't have an entry for the " "dependency", |
180 d.dir(appPath, [ | 193 () { |
181 d.libPubspec("test_pkg", "1.0.0", deps: { | 194 d.dir(appPath, [d.libPubspec("test_pkg", "1.0.0", deps: { |
182 "foo": "any" | 195 "foo": "any" |
183 }), | 196 }), d.file("pubspec.lock", JSON.encode({ |
184 d.file("pubspec.lock", JSON.encode({ | |
185 'packages': { | 197 'packages': { |
186 'bar': { | 198 'bar': { |
187 'version': '1.2.3', | 199 'version': '1.2.3', |
188 'source': 'hosted', | 200 'source': 'hosted', |
189 'description': { | 201 'description': { |
190 'name': 'bar', | 202 'name': 'bar', |
191 'url': 'http://pub.dartlang.org' | 203 'url': 'http://pub.dartlang.org' |
192 } | 204 } |
193 } | 205 } |
194 } | 206 } |
195 })) | 207 }))]).create(); |
196 ]).create(); | |
197 | 208 |
198 expect(schedulePackageValidation(dependency), completion( | 209 expect( |
199 pairOf(isEmpty, everyElement(isNot(contains("\n foo:")))))); | 210 schedulePackageValidation(dependency), |
| 211 completion(pairOf(isEmpty, everyElement(isNot(contains("\n foo:")
))))); |
200 }); | 212 }); |
201 }); | 213 }); |
202 | 214 |
203 group('with a lockfile', () { | 215 group('with a lockfile', () { |
204 integration('and it should suggest a constraint based on the locked ' | 216 integration( |
205 'version', () { | 217 'and it should suggest a constraint based on the locked ' 'version', |
206 d.dir(appPath, [ | 218 () { |
207 d.libPubspec("test_pkg", "1.0.0", deps: { | 219 d.dir(appPath, [d.libPubspec("test_pkg", "1.0.0", deps: { |
208 "foo": "any" | 220 "foo": "any" |
209 }), | 221 }), d.file("pubspec.lock", JSON.encode({ |
210 d.file("pubspec.lock", JSON.encode({ | |
211 'packages': { | 222 'packages': { |
212 'foo': { | 223 'foo': { |
213 'version': '1.2.3', | 224 'version': '1.2.3', |
214 'source': 'hosted', | 225 'source': 'hosted', |
215 'description': { | 226 'description': { |
216 'name': 'foo', | 227 'name': 'foo', |
217 'url': 'http://pub.dartlang.org' | 228 'url': 'http://pub.dartlang.org' |
218 } | 229 } |
219 } | 230 } |
220 } | 231 } |
221 })) | 232 }))]).create(); |
222 ]).create(); | |
223 | 233 |
224 expectDependencyValidationWarning(' foo: ">=1.2.3 <2.0.0"'); | 234 expectDependencyValidationWarning(' foo: ">=1.2.3 <2.0.0"'); |
225 }); | 235 }); |
226 | 236 |
227 integration('and it should suggest a concrete constraint if the locked ' | 237 integration( |
228 'version is pre-1.0.0', () { | 238 'and it should suggest a concrete constraint if the locked ' |
229 d.dir(appPath, [ | 239 'version is pre-1.0.0', |
230 d.libPubspec("test_pkg", "1.0.0", deps: { | 240 () { |
| 241 d.dir(appPath, [d.libPubspec("test_pkg", "1.0.0", deps: { |
231 "foo": "any" | 242 "foo": "any" |
232 }), | 243 }), d.file("pubspec.lock", JSON.encode({ |
233 d.file("pubspec.lock", JSON.encode({ | |
234 'packages': { | 244 'packages': { |
235 'foo': { | 245 'foo': { |
236 'version': '0.1.2', | 246 'version': '0.1.2', |
237 'source': 'hosted', | 247 'source': 'hosted', |
238 'description': { | 248 'description': { |
239 'name': 'foo', | 249 'name': 'foo', |
240 'url': 'http://pub.dartlang.org' | 250 'url': 'http://pub.dartlang.org' |
241 } | 251 } |
242 } | 252 } |
243 } | 253 } |
244 })) | 254 }))]).create(); |
245 ]).create(); | |
246 | 255 |
247 expectDependencyValidationWarning(' foo: ">=0.1.2 <0.2.0"'); | 256 expectDependencyValidationWarning(' foo: ">=0.1.2 <0.2.0"'); |
248 }); | 257 }); |
249 }); | 258 }); |
250 }); | 259 }); |
251 | 260 |
252 integration('with a single-version dependency and it should suggest a ' | 261 integration( |
253 'constraint based on the version', () { | 262 'with a single-version dependency and it should suggest a ' |
254 d.dir(appPath, [ | 263 'constraint based on the version', |
255 d.libPubspec("test_pkg", "1.0.0", deps: { | 264 () { |
| 265 d.dir(appPath, [d.libPubspec("test_pkg", "1.0.0", deps: { |
256 "foo": "1.2.3" | 266 "foo": "1.2.3" |
257 }) | 267 })]).create(); |
258 ]).create(); | |
259 | 268 |
260 expectDependencyValidationWarning(' foo: ">=1.2.3 <2.0.0"'); | 269 expectDependencyValidationWarning(' foo: ">=1.2.3 <2.0.0"'); |
261 }); | 270 }); |
262 | 271 |
263 group('has a dependency without a lower bound', () { | 272 group('has a dependency without a lower bound', () { |
264 group('and it should not suggest a version', () { | 273 group('and it should not suggest a version', () { |
265 integration("if there's no lockfile", () { | 274 integration("if there's no lockfile", () { |
266 d.dir(appPath, [ | 275 d.dir(appPath, [d.libPubspec("test_pkg", "1.0.0", deps: { |
267 d.libPubspec("test_pkg", "1.0.0", deps: { | |
268 "foo": "<3.0.0" | 276 "foo": "<3.0.0" |
269 }) | 277 })]).create(); |
270 ]).create(); | |
271 | 278 |
272 expect(schedulePackageValidation(dependency), completion( | 279 expect( |
273 pairOf(isEmpty, everyElement(isNot(contains("\n foo:")))))); | 280 schedulePackageValidation(dependency), |
| 281 completion(pairOf(isEmpty, everyElement(isNot(contains("\n foo:")
))))); |
274 }); | 282 }); |
275 | 283 |
276 integration("if the lockfile doesn't have an entry for the " | 284 integration( |
277 "dependency", () { | 285 "if the lockfile doesn't have an entry for the " "dependency", |
278 d.dir(appPath, [ | 286 () { |
279 d.libPubspec("test_pkg", "1.0.0", deps: { | 287 d.dir(appPath, [d.libPubspec("test_pkg", "1.0.0", deps: { |
280 "foo": "<3.0.0" | 288 "foo": "<3.0.0" |
281 }), | 289 }), d.file("pubspec.lock", JSON.encode({ |
282 d.file("pubspec.lock", JSON.encode({ | |
283 'packages': { | 290 'packages': { |
284 'bar': { | 291 'bar': { |
285 'version': '1.2.3', | 292 'version': '1.2.3', |
286 'source': 'hosted', | 293 'source': 'hosted', |
287 'description': { | 294 'description': { |
288 'name': 'bar', | 295 'name': 'bar', |
289 'url': 'http://pub.dartlang.org' | 296 'url': 'http://pub.dartlang.org' |
290 } | 297 } |
291 } | 298 } |
292 } | 299 } |
293 })) | 300 }))]).create(); |
294 ]).create(); | |
295 | 301 |
296 expect(schedulePackageValidation(dependency), completion( | 302 expect( |
297 pairOf(isEmpty, everyElement(isNot(contains("\n foo:")))))); | 303 schedulePackageValidation(dependency), |
| 304 completion(pairOf(isEmpty, everyElement(isNot(contains("\n foo:")
))))); |
298 }); | 305 }); |
299 }); | 306 }); |
300 | 307 |
301 group('with a lockfile', () { | 308 group('with a lockfile', () { |
302 integration('and it should suggest a constraint based on the locked ' | 309 integration( |
303 'version', () { | 310 'and it should suggest a constraint based on the locked ' 'version', |
304 d.dir(appPath, [ | 311 () { |
305 d.libPubspec("test_pkg", "1.0.0", deps: { | 312 d.dir(appPath, [d.libPubspec("test_pkg", "1.0.0", deps: { |
306 "foo": "<3.0.0" | 313 "foo": "<3.0.0" |
307 }), | 314 }), d.file("pubspec.lock", JSON.encode({ |
308 d.file("pubspec.lock", JSON.encode({ | |
309 'packages': { | 315 'packages': { |
310 'foo': { | 316 'foo': { |
311 'version': '1.2.3', | 317 'version': '1.2.3', |
312 'source': 'hosted', | 318 'source': 'hosted', |
313 'description': { | 319 'description': { |
314 'name': 'foo', | 320 'name': 'foo', |
315 'url': 'http://pub.dartlang.org' | 321 'url': 'http://pub.dartlang.org' |
316 } | 322 } |
317 } | 323 } |
318 } | 324 } |
319 })) | 325 }))]).create(); |
320 ]).create(); | |
321 | 326 |
322 expectDependencyValidationWarning(' foo: ">=1.2.3 <3.0.0"'); | 327 expectDependencyValidationWarning(' foo: ">=1.2.3 <3.0.0"'); |
323 }); | 328 }); |
324 | 329 |
325 integration('and it should preserve the upper-bound operator', () { | 330 integration('and it should preserve the upper-bound operator', () { |
326 d.dir(appPath, [ | 331 d.dir(appPath, [d.libPubspec("test_pkg", "1.0.0", deps: { |
327 d.libPubspec("test_pkg", "1.0.0", deps: { | |
328 "foo": "<=3.0.0" | 332 "foo": "<=3.0.0" |
329 }), | 333 }), d.file("pubspec.lock", JSON.encode({ |
330 d.file("pubspec.lock", JSON.encode({ | |
331 'packages': { | 334 'packages': { |
332 'foo': { | 335 'foo': { |
333 'version': '1.2.3', | 336 'version': '1.2.3', |
334 'source': 'hosted', | 337 'source': 'hosted', |
335 'description': { | 338 'description': { |
336 'name': 'foo', | 339 'name': 'foo', |
337 'url': 'http://pub.dartlang.org' | 340 'url': 'http://pub.dartlang.org' |
338 } | 341 } |
339 } | 342 } |
340 } | 343 } |
341 })) | 344 }))]).create(); |
342 ]).create(); | |
343 | 345 |
344 expectDependencyValidationWarning(' foo: ">=1.2.3 <=3.0.0"'); | 346 expectDependencyValidationWarning(' foo: ">=1.2.3 <=3.0.0"'); |
345 }); | 347 }); |
346 | 348 |
347 integration('and it should expand the suggested constraint if the ' | 349 integration( |
348 'locked version matches the upper bound', () { | 350 'and it should expand the suggested constraint if the ' |
349 d.dir(appPath, [ | 351 'locked version matches the upper bound', |
350 d.libPubspec("test_pkg", "1.0.0", deps: { | 352 () { |
| 353 d.dir(appPath, [d.libPubspec("test_pkg", "1.0.0", deps: { |
351 "foo": "<=1.2.3" | 354 "foo": "<=1.2.3" |
352 }), | 355 }), d.file("pubspec.lock", JSON.encode({ |
353 d.file("pubspec.lock", JSON.encode({ | |
354 'packages': { | 356 'packages': { |
355 'foo': { | 357 'foo': { |
356 'version': '1.2.3', | 358 'version': '1.2.3', |
357 'source': 'hosted', | 359 'source': 'hosted', |
358 'description': { | 360 'description': { |
359 'name': 'foo', | 361 'name': 'foo', |
360 'url': 'http://pub.dartlang.org' | 362 'url': 'http://pub.dartlang.org' |
361 } | 363 } |
362 } | 364 } |
363 } | 365 } |
364 })) | 366 }))]).create(); |
365 ]).create(); | |
366 | 367 |
367 expectDependencyValidationWarning(' foo: ">=1.2.3 <2.0.0"'); | 368 expectDependencyValidationWarning(' foo: ">=1.2.3 <2.0.0"'); |
368 }); | 369 }); |
369 }); | 370 }); |
370 }); | 371 }); |
371 | 372 |
372 group('with a dependency without an upper bound', () { | 373 group('with a dependency without an upper bound', () { |
373 integration('and it should suggest a constraint based on the lower bound', | 374 integration( |
| 375 'and it should suggest a constraint based on the lower bound', |
374 () { | 376 () { |
375 d.dir(appPath, [ | 377 d.dir(appPath, [d.libPubspec("test_pkg", "1.0.0", deps: { |
376 d.libPubspec("test_pkg", "1.0.0", deps: { | |
377 "foo": ">=1.2.3" | 378 "foo": ">=1.2.3" |
378 }) | 379 })]).create(); |
379 ]).create(); | |
380 | 380 |
381 expectDependencyValidationWarning(' foo: ">=1.2.3 <2.0.0"'); | 381 expectDependencyValidationWarning(' foo: ">=1.2.3 <2.0.0"'); |
382 }); | 382 }); |
383 | 383 |
384 integration('and it should preserve the lower-bound operator', () { | 384 integration('and it should preserve the lower-bound operator', () { |
385 d.dir(appPath, [ | 385 d.dir(appPath, [d.libPubspec("test_pkg", "1.0.0", deps: { |
386 d.libPubspec("test_pkg", "1.0.0", deps: { | |
387 "foo": ">1.2.3" | 386 "foo": ">1.2.3" |
388 }) | 387 })]).create(); |
389 ]).create(); | |
390 | 388 |
391 expectDependencyValidationWarning(' foo: ">1.2.3 <2.0.0"'); | 389 expectDependencyValidationWarning(' foo: ">1.2.3 <2.0.0"'); |
392 }); | 390 }); |
393 }); | 391 }); |
394 | 392 |
395 group('has a ^ dependency', () { | 393 group('has a ^ dependency', () { |
396 integration("without an SDK constraint", () { | 394 integration("without an SDK constraint", () { |
397 d.dir(appPath, [ | 395 d.dir(appPath, [d.libPubspec("integration_pkg", "1.0.0", deps: { |
398 d.libPubspec("integration_pkg", "1.0.0", deps: { | |
399 "foo": "^1.2.3" | 396 "foo": "^1.2.3" |
400 }) | 397 })]).create(); |
401 ]).create(); | |
402 | 398 |
403 expectDependencyValidationError(' foo: ">=1.2.3 <2.0.0"'); | 399 expectDependencyValidationError(' foo: ">=1.2.3 <2.0.0"'); |
404 }); | 400 }); |
405 | 401 |
406 integration("with a too-broad SDK constraint", () { | 402 integration("with a too-broad SDK constraint", () { |
407 d.dir(appPath, [ | 403 d.dir(appPath, [d.libPubspec("test_pkg", "1.0.0", deps: { |
408 d.libPubspec("test_pkg", "1.0.0", deps: { | |
409 "foo": "^1.2.3" | 404 "foo": "^1.2.3" |
410 }, sdk: ">=1.5.0 <2.0.0") | 405 }, sdk: ">=1.5.0 <2.0.0")]).create(); |
411 ]).create(); | |
412 | 406 |
413 expectDependencyValidationError(' foo: ">=1.2.3 <2.0.0"'); | 407 expectDependencyValidationError(' foo: ">=1.2.3 <2.0.0"'); |
414 }); | 408 }); |
415 }); | 409 }); |
416 }); | 410 }); |
417 } | 411 } |
OLD | NEW |