| 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 library pub_tests; | 5 library pub_tests; |
| 6 | 6 |
| 7 import 'package:pub/src/exit_codes.dart' as exit_codes; |
| 8 |
| 7 import '../descriptor.dart' as d; | 9 import '../descriptor.dart' as d; |
| 8 import '../test_pub.dart'; | 10 import '../test_pub.dart'; |
| 9 | 11 |
| 10 main() { | 12 main() { |
| 11 forBothPubGetAndUpgrade((command) { | 13 forBothPubGetAndUpgrade((command) { |
| 12 integration('upgrades a package using the cache', () { | 14 integration('upgrades a package using the cache', () { |
| 13 // Run the server so that we know what URL to use in the system cache. | 15 // Run the server so that we know what URL to use in the system cache. |
| 14 serveNoPackages(); | 16 serveErrors(); |
| 15 | 17 |
| 16 d.cacheDir({ | 18 d.cacheDir({ |
| 17 "foo": ["1.2.2", "1.2.3"], | 19 "foo": ["1.2.2", "1.2.3"], |
| 18 "bar": ["1.2.3"] | 20 "bar": ["1.2.3"] |
| 19 }, includePubspecs: true).create(); | 21 }, includePubspecs: true).create(); |
| 20 | 22 |
| 21 d.appDir({ | 23 d.appDir({ |
| 22 "foo": "any", | 24 "foo": "any", |
| 23 "bar": "any" | 25 "bar": "any" |
| 24 }).create(); | 26 }).create(); |
| 25 | 27 |
| 26 var warning = null; | 28 var warning = null; |
| 27 if (command == RunCommand.upgrade) { | 29 if (command == RunCommand.upgrade) { |
| 28 warning = "Warning: Upgrading when offline may not update you " | 30 warning = "Warning: Upgrading when offline may not update you " |
| 29 "to the latest versions of your dependencies."; | 31 "to the latest versions of your dependencies."; |
| 30 } | 32 } |
| 31 | 33 |
| 32 pubCommand(command, args: ['--offline'], warning: warning); | 34 pubCommand(command, args: ['--offline'], warning: warning); |
| 33 | 35 |
| 34 d.packagesDir({ | 36 d.packagesDir({ |
| 35 "foo": "1.2.3", | 37 "foo": "1.2.3", |
| 36 "bar": "1.2.3" | 38 "bar": "1.2.3" |
| 37 }).validate(); | 39 }).validate(); |
| 38 }); | 40 }); |
| 39 | 41 |
| 40 integration('fails gracefully if a dependency is not cached', () { | 42 integration('fails gracefully if a dependency is not cached', () { |
| 41 // Run the server so that we know what URL to use in the system cache. | 43 // Run the server so that we know what URL to use in the system cache. |
| 42 serveNoPackages(); | 44 serveErrors(); |
| 43 | 45 |
| 44 d.appDir({"foo": "any"}).create(); | 46 d.appDir({"foo": "any"}).create(); |
| 45 | 47 |
| 46 pubCommand(command, args: ['--offline'], | 48 pubCommand(command, args: ['--offline'], |
| 47 error: "Could not find package foo in cache."); | 49 exitCode: exit_codes.UNAVAILABLE, |
| 50 error: "Could not find package foo in cache.\n" |
| 51 "Depended on by:\n" |
| 52 "- myapp"); |
| 48 }); | 53 }); |
| 49 | 54 |
| 50 integration('fails gracefully no cached versions match', () { | 55 integration('fails gracefully if no cached versions match', () { |
| 51 // Run the server so that we know what URL to use in the system cache. | 56 // Run the server so that we know what URL to use in the system cache. |
| 52 serveNoPackages(); | 57 serveErrors(); |
| 53 | 58 |
| 54 d.cacheDir({ | 59 d.cacheDir({ |
| 55 "foo": ["1.2.2", "1.2.3"] | 60 "foo": ["1.2.2", "1.2.3"] |
| 56 }, includePubspecs: true).create(); | 61 }, includePubspecs: true).create(); |
| 57 | 62 |
| 58 d.appDir({"foo": ">2.0.0"}).create(); | 63 d.appDir({"foo": ">2.0.0"}).create(); |
| 59 | 64 |
| 60 pubCommand(command, args: ['--offline'], error: | 65 pubCommand(command, args: ['--offline'], error: |
| 61 "Package foo has no versions that match >2.0.0 derived from:\n" | 66 "Package foo has no versions that match >2.0.0 derived from:\n" |
| 62 "- myapp depends on version >2.0.0"); | 67 "- myapp depends on version >2.0.0"); |
| 63 }); | 68 }); |
| 69 |
| 70 integration('fails gracefully if a dependency is not cached and a lockfile ' |
| 71 'exists', () { |
| 72 // Run the server so that we know what URL to use in the system cache. |
| 73 serveErrors(); |
| 74 |
| 75 d.appDir({"foo": "any"}).create(); |
| 76 |
| 77 createLockFile('myapp', hosted: {'foo': '1.2.4'}); |
| 78 |
| 79 pubCommand(command, args: ['--offline'], |
| 80 exitCode: exit_codes.UNAVAILABLE, |
| 81 error: "Could not find package foo in cache.\n" |
| 82 "Depended on by:\n" |
| 83 "- myapp"); |
| 84 }); |
| 85 |
| 86 integration('downgrades to the version in the cache if necessary', () { |
| 87 // Run the server so that we know what URL to use in the system cache. |
| 88 serveErrors(); |
| 89 |
| 90 d.cacheDir({ |
| 91 "foo": ["1.2.2", "1.2.3"] |
| 92 }, includePubspecs: true).create(); |
| 93 |
| 94 d.appDir({"foo": "any"}).create(); |
| 95 |
| 96 createLockFile('myapp', hosted: {'foo': '1.2.4'}); |
| 97 |
| 98 pubCommand(command, args: ['--offline']); |
| 99 |
| 100 d.packagesDir({"foo": "1.2.3"}).validate(); |
| 101 }); |
| 64 }); | 102 }); |
| 65 } | 103 } |
| OLD | NEW |