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

Unified Diff: sdk/lib/_internal/pub_generated/test/validator/dependency_test.dart

Issue 657673002: Regenerate pub sources. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 2 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
Index: sdk/lib/_internal/pub_generated/test/validator/dependency_test.dart
diff --git a/sdk/lib/_internal/pub_generated/test/validator/dependency_test.dart b/sdk/lib/_internal/pub_generated/test/validator/dependency_test.dart
index 3300aceffd378bebf40fa7721a9a0bc618a15c59..5f05d3d1b65d4455bc4119a4581bd55db2bee1ad 100644
--- a/sdk/lib/_internal/pub_generated/test/validator/dependency_test.dart
+++ b/sdk/lib/_internal/pub_generated/test/validator/dependency_test.dart
@@ -1,31 +1,44 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
import 'dart:async';
import 'dart:convert';
+
import 'package:http/http.dart' as http;
import 'package:http/testing.dart';
import 'package:path/path.dart' as path;
import 'package:scheduled_test/scheduled_test.dart';
+
import '../../lib/src/entrypoint.dart';
import '../../lib/src/validator.dart';
import '../../lib/src/validator/dependency.dart';
import '../descriptor.dart' as d;
import '../test_pub.dart';
import 'utils.dart';
+
Validator dependency(Entrypoint entrypoint) =>
new DependencyValidator(entrypoint);
+
expectDependencyValidationError(String error) {
expect(
schedulePackageValidation(dependency),
completion(pairOf(anyElement(contains(error)), isEmpty)));
}
+
expectDependencyValidationWarning(String warning) {
expect(
schedulePackageValidation(dependency),
completion(pairOf(isEmpty, anyElement(contains(warning)))));
}
+
+/// Sets up a test package with dependency [dep] and mocks a server with
+/// [hostedVersions] of the package available.
setUpDependency(Map dep, {List<String> hostedVersions}) {
useMockClient(new MockClient((request) {
expect(request.method, equals("GET"));
expect(request.url.path, equals("/api/packages/foo"));
+
if (hostedVersions == null) {
return new Future.value(new http.Response("not found", 404));
} else {
@@ -37,18 +50,23 @@ setUpDependency(Map dep, {List<String> hostedVersions}) {
}), 200));
}
}));
+
d.dir(appPath, [d.libPubspec("test_pkg", "1.0.0", deps: {
"foo": dep
})]).create();
}
+
main() {
initConfig();
+
integration('should consider a package valid if it looks normal', () {
d.validPackage.create();
expectNoValidationError(dependency);
});
+
group('should consider a package invalid if it', () {
setUp(d.validPackage.create);
+
group('has a git dependency', () {
group('where a hosted version exists', () {
integration("and should suggest the hosted primary version", () {
@@ -57,6 +75,7 @@ main() {
}, hostedVersions: ["3.0.0-pre", "2.0.0", "1.0.0"]);
expectDependencyValidationWarning(' foo: ">=2.0.0 <3.0.0"');
});
+
integration(
"and should suggest the hosted prerelease version if "
"it's the only version available",
@@ -66,6 +85,7 @@ main() {
}, hostedVersions: ["3.0.0-pre", "2.0.0-pre"]);
expectDependencyValidationWarning(' foo: ">=3.0.0-pre <4.0.0"');
});
+
integration(
"and should suggest a tighter constraint if primary is " "pre-1.0.0",
() {
@@ -75,6 +95,7 @@ main() {
expectDependencyValidationWarning(' foo: ">=0.0.2 <0.1.0"');
});
});
+
group('where no hosted version exists', () {
integration("and should use the other source's version", () {
setUpDependency({
@@ -83,6 +104,7 @@ main() {
});
expectDependencyValidationWarning(' foo: ">=1.0.0 <2.0.0"');
});
+
integration(
"and should use the other source's unquoted version if " "concrete",
() {
@@ -94,6 +116,7 @@ main() {
});
});
});
+
group('has a path dependency', () {
group('where a hosted version exists', () {
integration("and should suggest the hosted primary version", () {
@@ -102,6 +125,7 @@ main() {
}, hostedVersions: ["3.0.0-pre", "2.0.0", "1.0.0"]);
expectDependencyValidationError(' foo: ">=2.0.0 <3.0.0"');
});
+
integration(
"and should suggest the hosted prerelease version if "
"it's the only version available",
@@ -111,6 +135,7 @@ main() {
}, hostedVersions: ["3.0.0-pre", "2.0.0-pre"]);
expectDependencyValidationError(' foo: ">=3.0.0-pre <4.0.0"');
});
+
integration(
"and should suggest a tighter constraint if primary is " "pre-1.0.0",
() {
@@ -120,6 +145,7 @@ main() {
expectDependencyValidationError(' foo: ">=0.0.2 <0.1.0"');
});
});
+
group('where no hosted version exists', () {
integration("and should use the other source's version", () {
setUpDependency({
@@ -128,6 +154,7 @@ main() {
});
expectDependencyValidationError(' foo: ">=1.0.0 <2.0.0"');
});
+
integration(
"and should use the other source's unquoted version if " "concrete",
() {
@@ -139,16 +166,19 @@ main() {
});
});
});
+
group('has an unconstrained dependency', () {
group('and it should not suggest a version', () {
integration("if there's no lockfile", () {
d.dir(appPath, [d.libPubspec("test_pkg", "1.0.0", deps: {
"foo": "any"
})]).create();
+
expect(
schedulePackageValidation(dependency),
completion(pairOf(isEmpty, everyElement(isNot(contains("\n foo:"))))));
});
+
integration(
"if the lockfile doesn't have an entry for the " "dependency",
() {
@@ -166,11 +196,13 @@ main() {
}
}
}))]).create();
+
expect(
schedulePackageValidation(dependency),
completion(pairOf(isEmpty, everyElement(isNot(contains("\n foo:"))))));
});
});
+
group('with a lockfile', () {
integration(
'and it should suggest a constraint based on the locked ' 'version',
@@ -189,8 +221,10 @@ main() {
}
}
}))]).create();
+
expectDependencyValidationWarning(' foo: ">=1.2.3 <2.0.0"');
});
+
integration(
'and it should suggest a concrete constraint if the locked '
'version is pre-1.0.0',
@@ -209,10 +243,12 @@ main() {
}
}
}))]).create();
+
expectDependencyValidationWarning(' foo: ">=0.1.2 <0.2.0"');
});
});
});
+
integration(
'with a single-version dependency and it should suggest a '
'constraint based on the version',
@@ -220,18 +256,22 @@ main() {
d.dir(appPath, [d.libPubspec("test_pkg", "1.0.0", deps: {
"foo": "1.2.3"
})]).create();
+
expectDependencyValidationWarning(' foo: ">=1.2.3 <2.0.0"');
});
+
group('has a dependency without a lower bound', () {
group('and it should not suggest a version', () {
integration("if there's no lockfile", () {
d.dir(appPath, [d.libPubspec("test_pkg", "1.0.0", deps: {
"foo": "<3.0.0"
})]).create();
+
expect(
schedulePackageValidation(dependency),
completion(pairOf(isEmpty, everyElement(isNot(contains("\n foo:"))))));
});
+
integration(
"if the lockfile doesn't have an entry for the " "dependency",
() {
@@ -249,11 +289,13 @@ main() {
}
}
}))]).create();
+
expect(
schedulePackageValidation(dependency),
completion(pairOf(isEmpty, everyElement(isNot(contains("\n foo:"))))));
});
});
+
group('with a lockfile', () {
integration(
'and it should suggest a constraint based on the locked ' 'version',
@@ -272,8 +314,10 @@ main() {
}
}
}))]).create();
+
expectDependencyValidationWarning(' foo: ">=1.2.3 <3.0.0"');
});
+
integration('and it should preserve the upper-bound operator', () {
d.dir(appPath, [d.libPubspec("test_pkg", "1.0.0", deps: {
"foo": "<=3.0.0"
@@ -289,8 +333,10 @@ main() {
}
}
}))]).create();
+
expectDependencyValidationWarning(' foo: ">=1.2.3 <=3.0.0"');
});
+
integration(
'and it should expand the suggested constraint if the '
'locked version matches the upper bound',
@@ -309,10 +355,12 @@ main() {
}
}
}))]).create();
+
expectDependencyValidationWarning(' foo: ">=1.2.3 <2.0.0"');
});
});
});
+
group('with a dependency without an upper bound', () {
integration(
'and it should suggest a constraint based on the lower bound',
@@ -320,12 +368,15 @@ main() {
d.dir(appPath, [d.libPubspec("test_pkg", "1.0.0", deps: {
"foo": ">=1.2.3"
})]).create();
+
expectDependencyValidationWarning(' foo: ">=1.2.3 <2.0.0"');
});
+
integration('and it should preserve the lower-bound operator', () {
d.dir(appPath, [d.libPubspec("test_pkg", "1.0.0", deps: {
"foo": ">1.2.3"
})]).create();
+
expectDependencyValidationWarning(' foo: ">1.2.3 <2.0.0"');
});
});

Powered by Google App Engine
This is Rietveld 408576698