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:pathos/path.dart' as path; | 10 import 'package:pathos/path.dart' as path; |
(...skipping 20 matching lines...) Expand all Loading... |
31 } | 31 } |
32 | 32 |
33 /// Sets up a test package with dependency [dep] and mocks a server with | 33 /// Sets up a test package with dependency [dep] and mocks a server with |
34 /// [hostedVersions] of the package available. | 34 /// [hostedVersions] of the package available. |
35 setUpDependency(Map dep, {List<String> hostedVersions}) { | 35 setUpDependency(Map dep, {List<String> hostedVersions}) { |
36 useMockClient(new MockClient((request) { | 36 useMockClient(new MockClient((request) { |
37 expect(request.method, equals("GET")); | 37 expect(request.method, equals("GET")); |
38 expect(request.url.path, equals("/packages/foo.json")); | 38 expect(request.url.path, equals("/packages/foo.json")); |
39 | 39 |
40 if (hostedVersions == null) { | 40 if (hostedVersions == null) { |
41 return new Future.immediate(new http.Response("not found", 404)); | 41 return new Future.value(new http.Response("not found", 404)); |
42 } else { | 42 } else { |
43 return new Future.immediate(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 | 46 "versions": hostedVersions |
47 }), 200)); | 47 }), 200)); |
48 } | 48 } |
49 })); | 49 })); |
50 | 50 |
51 d.dir(appPath, [ | 51 d.dir(appPath, [ |
52 d.libPubspec("test_pkg", "1.0.0", deps: [dep]) | 52 d.libPubspec("test_pkg", "1.0.0", deps: [dep]) |
53 ]).create(); | 53 ]).create(); |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 d.dir(appPath, [ | 241 d.dir(appPath, [ |
242 d.libPubspec("test_pkg", "1.0.0", deps: [ | 242 d.libPubspec("test_pkg", "1.0.0", deps: [ |
243 {'hosted': {'name': 'test_pkg', 'version': '>=1.0.0'}} | 243 {'hosted': {'name': 'test_pkg', 'version': '>=1.0.0'}} |
244 ]) | 244 ]) |
245 ]).create(); | 245 ]).create(); |
246 | 246 |
247 expectValidationWarning(dependency); | 247 expectValidationWarning(dependency); |
248 }); | 248 }); |
249 }); | 249 }); |
250 } | 250 } |
OLD | NEW |