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:json' as json; | 6 import 'dart:json' as json; |
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; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 return new Future.value(new http.Response(json.stringify({ | 43 return new Future.value(new http.Response(json.stringify({ |
44 "name": "foo", | 44 "name": "foo", |
45 "uploaders": ["nweiz@google.com"], | 45 "uploaders": ["nweiz@google.com"], |
46 "versions": hostedVersions.map((version) => | 46 "versions": hostedVersions.map((version) => |
47 packageVersionApiMap(packageMap('foo', version))).toList() | 47 packageVersionApiMap(packageMap('foo', version))).toList() |
48 }), 200)); | 48 }), 200)); |
49 } | 49 } |
50 })); | 50 })); |
51 | 51 |
52 d.dir(appPath, [ | 52 d.dir(appPath, [ |
53 d.libPubspec("test_pkg", "1.0.0", deps: [dep]) | 53 d.libPubspec("test_pkg", "1.0.0", deps: {"foo": dep}) |
54 ]).create(); | 54 ]).create(); |
55 } | 55 } |
56 | 56 |
57 main() { | 57 main() { |
58 initConfig(); | 58 initConfig(); |
59 | 59 |
60 integration('should consider a package valid if it looks normal', () { | 60 integration('should consider a package valid if it looks normal', () { |
61 d.validPackage.create(); | 61 d.validPackage.create(); |
62 expectNoValidationError(dependency); | 62 expectNoValidationError(dependency); |
63 }); | 63 }); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 }); | 148 }); |
149 expectDependencyValidationError(' foo: 0.2.3'); | 149 expectDependencyValidationError(' foo: 0.2.3'); |
150 }); | 150 }); |
151 }); | 151 }); |
152 }); | 152 }); |
153 | 153 |
154 group('has an unconstrained dependency', () { | 154 group('has an unconstrained dependency', () { |
155 group('and it should not suggest a version', () { | 155 group('and it should not suggest a version', () { |
156 integration("if there's no lockfile", () { | 156 integration("if there's no lockfile", () { |
157 d.dir(appPath, [ | 157 d.dir(appPath, [ |
158 d.libPubspec("test_pkg", "1.0.0", deps: [ | 158 d.libPubspec("test_pkg", "1.0.0", deps: { |
159 {'hosted': 'foo'} | 159 "foo": "any" |
160 ]) | 160 }) |
161 ]).create(); | 161 ]).create(); |
162 | 162 |
163 expect(schedulePackageValidation(dependency), completion( | 163 expect(schedulePackageValidation(dependency), completion( |
164 pairOf(isEmpty, everyElement(isNot(contains("\n foo:")))))); | 164 pairOf(isEmpty, everyElement(isNot(contains("\n foo:")))))); |
165 }); | 165 }); |
166 | 166 |
167 integration("if the lockfile doesn't have an entry for the " | 167 integration("if the lockfile doesn't have an entry for the " |
168 "dependency", () { | 168 "dependency", () { |
169 d.dir(appPath, [ | 169 d.dir(appPath, [ |
170 d.libPubspec("test_pkg", "1.0.0", deps: [ | 170 d.libPubspec("test_pkg", "1.0.0", deps: { |
171 {'hosted': 'foo'} | 171 "foo": "any" |
172 ]), | 172 }), |
173 d.file("pubspec.lock", json.stringify({ | 173 d.file("pubspec.lock", json.stringify({ |
174 'packages': { | 174 'packages': { |
175 'bar': { | 175 'bar': { |
176 'version': '1.2.3', | 176 'version': '1.2.3', |
177 'source': 'hosted', | 177 'source': 'hosted', |
178 'description': { | 178 'description': { |
179 'name': 'bar', | 179 'name': 'bar', |
180 'url': 'http://pub.dartlang.org' | 180 'url': 'http://pub.dartlang.org' |
181 } | 181 } |
182 } | 182 } |
183 } | 183 } |
184 })) | 184 })) |
185 ]).create(); | 185 ]).create(); |
186 | 186 |
187 expect(schedulePackageValidation(dependency), completion( | 187 expect(schedulePackageValidation(dependency), completion( |
188 pairOf(isEmpty, everyElement(isNot(contains("\n foo:")))))); | 188 pairOf(isEmpty, everyElement(isNot(contains("\n foo:")))))); |
189 }); | 189 }); |
190 }); | 190 }); |
191 | 191 |
192 group('with a lockfile', () { | 192 group('with a lockfile', () { |
193 integration('and it should suggest a constraint based on the locked ' | 193 integration('and it should suggest a constraint based on the locked ' |
194 'version', () { | 194 'version', () { |
195 d.dir(appPath, [ | 195 d.dir(appPath, [ |
196 d.libPubspec("test_pkg", "1.0.0", deps: [ | 196 d.libPubspec("test_pkg", "1.0.0", deps: { |
197 {'hosted': 'foo'} | 197 "foo": "any" |
198 ]), | 198 }), |
199 d.file("pubspec.lock", json.stringify({ | 199 d.file("pubspec.lock", json.stringify({ |
200 'packages': { | 200 'packages': { |
201 'foo': { | 201 'foo': { |
202 'version': '1.2.3', | 202 'version': '1.2.3', |
203 'source': 'hosted', | 203 'source': 'hosted', |
204 'description': { | 204 'description': { |
205 'name': 'foo', | 205 'name': 'foo', |
206 'url': 'http://pub.dartlang.org' | 206 'url': 'http://pub.dartlang.org' |
207 } | 207 } |
208 } | 208 } |
209 } | 209 } |
210 })) | 210 })) |
211 ]).create(); | 211 ]).create(); |
212 | 212 |
213 expectDependencyValidationWarning(' foo: ">=1.2.3 <2.0.0"'); | 213 expectDependencyValidationWarning(' foo: ">=1.2.3 <2.0.0"'); |
214 }); | 214 }); |
215 | 215 |
216 integration('and it should suggest a concrete constraint if the locked ' | 216 integration('and it should suggest a concrete constraint if the locked ' |
217 'version is pre-1.0.0', () { | 217 'version is pre-1.0.0', () { |
218 d.dir(appPath, [ | 218 d.dir(appPath, [ |
219 d.libPubspec("test_pkg", "1.0.0", deps: [ | 219 d.libPubspec("test_pkg", "1.0.0", deps: { |
220 {'hosted': 'foo'} | 220 "foo": "any" |
221 ]), | 221 }), |
222 d.file("pubspec.lock", json.stringify({ | 222 d.file("pubspec.lock", json.stringify({ |
223 'packages': { | 223 'packages': { |
224 'foo': { | 224 'foo': { |
225 'version': '0.1.2', | 225 'version': '0.1.2', |
226 'source': 'hosted', | 226 'source': 'hosted', |
227 'description': { | 227 'description': { |
228 'name': 'foo', | 228 'name': 'foo', |
229 'url': 'http://pub.dartlang.org' | 229 'url': 'http://pub.dartlang.org' |
230 } | 230 } |
231 } | 231 } |
232 } | 232 } |
233 })) | 233 })) |
234 ]).create(); | 234 ]).create(); |
235 | 235 |
236 expectDependencyValidationWarning(' foo: ">=0.1.2 <0.1.3"'); | 236 expectDependencyValidationWarning(' foo: ">=0.1.2 <0.1.3"'); |
237 }); | 237 }); |
238 }); | 238 }); |
239 }); | 239 }); |
240 | 240 |
241 integration('has a hosted dependency on itself', () { | 241 integration('has a hosted dependency on itself', () { |
242 d.dir(appPath, [ | 242 d.dir(appPath, [ |
243 d.libPubspec("test_pkg", "1.0.0", deps: [ | 243 d.libPubspec("test_pkg", "1.0.0", deps: { |
244 {'hosted': {'name': 'test_pkg', 'version': '>=1.0.0'}} | 244 "test_pkg": ">=1.0.0" |
245 ]) | 245 }) |
246 ]).create(); | 246 ]).create(); |
247 | 247 |
248 expectValidationWarning(dependency); | 248 expectValidationWarning(dependency); |
249 }); | 249 }); |
250 }); | 250 }); |
251 } | 251 } |
OLD | NEW |