| OLD | NEW |
| 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 import 'package:scheduled_test/scheduled_test.dart'; | 5 import 'package:scheduled_test/scheduled_test.dart'; |
| 6 | 6 |
| 7 import '../../descriptor.dart' as d; | 7 import '../../descriptor.dart' as d; |
| 8 import '../../test_pub.dart'; | 8 import '../../test_pub.dart'; |
| 9 | 9 |
| 10 main() { | 10 main() { |
| 11 integration('only requests versions that are needed during solving', () { | 11 integration('only requests versions that are needed during solving', () { |
| 12 servePackages((builder) { | 12 servePackages((builder) { |
| 13 builder.serve("foo", "1.0.0"); | 13 builder.serve("foo", "1.0.0"); |
| 14 builder.serve("foo", "1.1.0"); | 14 builder.serve("foo", "1.1.0"); |
| 15 builder.serve("foo", "1.2.0"); | 15 builder.serve("foo", "1.2.0"); |
| 16 builder.serve("bar", "1.0.0"); | 16 builder.serve("bar", "1.0.0"); |
| 17 builder.serve("bar", "1.1.0"); | 17 builder.serve("bar", "1.1.0"); |
| 18 builder.serve("bar", "1.2.0"); | 18 builder.serve("bar", "1.2.0"); |
| 19 }); | 19 }); |
| 20 | 20 |
| 21 d.appDir({ | 21 d.appDir({ |
| 22 "foo": "any" | 22 "foo": "any" |
| 23 }).create(); | 23 }).create(); |
| 24 | 24 |
| 25 // Get once so it gets cached. | 25 // Get once so it gets cached. |
| 26 pubGet(); | 26 pubGet(); |
| 27 | 27 |
| 28 // Clear the cache. We don't care about anything that was served during | 28 // Clear the cache. We don't care about anything that was served during |
| 29 // the initial get. | 29 // the initial get. |
| 30 getRequestedPaths(); | 30 globalServer.clearRequestedPaths(); |
| 31 | 31 |
| 32 // Add "bar" to the dependencies. | 32 // Add "bar" to the dependencies. |
| 33 d.appDir({ | 33 d.appDir({ |
| 34 "foo": "any", | 34 "foo": "any", |
| 35 "bar": "any" | 35 "bar": "any" |
| 36 }).create(); | 36 }).create(); |
| 37 | 37 |
| 38 // Run the solver again. | 38 // Run the solver again. |
| 39 pubGet(); | 39 pubGet(); |
| 40 | 40 |
| 41 d.packagesDir({ | 41 d.packagesDir({ |
| 42 "foo": "1.2.0", | 42 "foo": "1.2.0", |
| 43 "bar": "1.2.0" | 43 "bar": "1.2.0" |
| 44 }).validate(); | 44 }).validate(); |
| 45 | 45 |
| 46 // The get should not have done any network requests since the lock file is | 46 // The get should not have done any network requests since the lock file is |
| 47 // up to date. | 47 // up to date. |
| 48 getRequestedPaths().then((paths) { | 48 globalServer.requestedPaths.then((paths) { |
| 49 expect(paths, unorderedEquals([ | 49 expect(paths, unorderedEquals([ |
| 50 // Bar should be requested because it's new, but not foo. | 50 // Bar should be requested because it's new, but not foo. |
| 51 "api/packages/bar", | 51 "api/packages/bar", |
| 52 // Need to download it. | 52 // Need to download it. |
| 53 "packages/bar/versions/1.2.0.tar.gz" | 53 "packages/bar/versions/1.2.0.tar.gz" |
| 54 ])); | 54 ])); |
| 55 }); | 55 }); |
| 56 }); | 56 }); |
| 57 } | 57 } |
| OLD | NEW |