Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(741)

Unified Diff: test/hosted/offline_test.dart

Issue 1226133003: Fix several problems with offline mode. (Closed) Base URL: git@github.com:dart-lang/pub.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/src/source/hosted.dart ('k') | test/test_pub.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/hosted/offline_test.dart
diff --git a/test/hosted/offline_test.dart b/test/hosted/offline_test.dart
index 845c16ea184fd8a74d8c85d345db9ae7f776a161..36176fa8a6422b929a7b7f9f3f92cf8cc1ca8669 100644
--- a/test/hosted/offline_test.dart
+++ b/test/hosted/offline_test.dart
@@ -4,6 +4,8 @@
library pub_tests;
+import 'package:pub/src/exit_codes.dart' as exit_codes;
+
import '../descriptor.dart' as d;
import '../test_pub.dart';
@@ -11,7 +13,7 @@ main() {
forBothPubGetAndUpgrade((command) {
integration('upgrades a package using the cache', () {
// Run the server so that we know what URL to use in the system cache.
- serveNoPackages();
+ serveErrors();
d.cacheDir({
"foo": ["1.2.2", "1.2.3"],
@@ -39,17 +41,20 @@ main() {
integration('fails gracefully if a dependency is not cached', () {
// Run the server so that we know what URL to use in the system cache.
- serveNoPackages();
+ serveErrors();
d.appDir({"foo": "any"}).create();
pubCommand(command, args: ['--offline'],
- error: "Could not find package foo in cache.");
+ exitCode: exit_codes.UNAVAILABLE,
+ error: "Could not find package foo in cache.\n"
+ "Depended on by:\n"
+ "- myapp");
});
- integration('fails gracefully no cached versions match', () {
+ integration('fails gracefully if no cached versions match', () {
// Run the server so that we know what URL to use in the system cache.
- serveNoPackages();
+ serveErrors();
d.cacheDir({
"foo": ["1.2.2", "1.2.3"]
@@ -61,5 +66,38 @@ main() {
"Package foo has no versions that match >2.0.0 derived from:\n"
"- myapp depends on version >2.0.0");
});
+
+ integration('fails gracefully if a dependency is not cached and a lockfile '
+ 'exists', () {
+ // Run the server so that we know what URL to use in the system cache.
+ serveErrors();
+
+ d.appDir({"foo": "any"}).create();
+
+ createLockFile('myapp', hosted: {'foo': '1.2.4'});
+
+ pubCommand(command, args: ['--offline'],
+ exitCode: exit_codes.UNAVAILABLE,
+ error: "Could not find package foo in cache.\n"
+ "Depended on by:\n"
+ "- myapp");
+ });
+
+ integration('downgrades to the version in the cache if necessary', () {
+ // Run the server so that we know what URL to use in the system cache.
+ serveErrors();
+
+ d.cacheDir({
+ "foo": ["1.2.2", "1.2.3"]
+ }, includePubspecs: true).create();
+
+ d.appDir({"foo": "any"}).create();
+
+ createLockFile('myapp', hosted: {'foo': '1.2.4'});
+
+ pubCommand(command, args: ['--offline']);
+
+ d.packagesDir({"foo": "1.2.3"}).validate();
+ });
});
}
« no previous file with comments | « lib/src/source/hosted.dart ('k') | test/test_pub.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698