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

Unified Diff: test/lock_file_test.dart

Issue 2165423002: Add support for Flutter SDK constraints. (Closed) Base URL: git@github.com:dart-lang/pub.git@master
Patch Set: Code review changes Created 4 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/validator/sdk_constraint.dart ('k') | test/must_pub_get_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/lock_file_test.dart
diff --git a/test/lock_file_test.dart b/test/lock_file_test.dart
index ca6e0836156129bd064c675ad6e026b0349ff753..211d6207156b0ca5ce00cefd3d5b81bdc1c50ebc 100644
--- a/test/lock_file_test.dart
+++ b/test/lock_file_test.dart
@@ -102,6 +102,25 @@ packages:
expect(lockFile.packages, isEmpty);
});
+ test("allows an old-style SDK constraint", () {
+ var lockFile = new LockFile.parse('sdk: ">=1.2.3 <4.0.0"', sources);
+ expect(lockFile.dartSdkConstraint,
+ equals(new VersionConstraint.parse('>=1.2.3 <4.0.0')));
+ expect(lockFile.flutterSdkConstraint, isNull);
+ });
+
+ test("allows new-style SDK constraints", () {
+ var lockFile = new LockFile.parse('''
+sdks:
+ dart: ">=1.2.3 <4.0.0"
+ flutter: ^0.1.2
+''', sources);
+ expect(lockFile.dartSdkConstraint,
+ equals(new VersionConstraint.parse('>=1.2.3 <4.0.0')));
+ expect(lockFile.flutterSdkConstraint,
+ equals(new VersionConstraint.parse('^0.1.2')));
+ });
+
test("throws if the top level is not a map", () {
expect(() {
new LockFile.parse('''
@@ -175,6 +194,37 @@ packages:
}, throwsFormatException);
});
+ test("throws if the old-style SDK constraint isn't a string", () {
+ expect(() => new LockFile.parse('sdk: 1.0', sources),
+ throwsFormatException);
+ });
+
+ test("throws if the old-style SDK constraint is invalid", () {
+ expect(() => new LockFile.parse('sdk: oops', sources),
+ throwsFormatException);
+ });
+
+ test("throws if the sdks field isn't a map", () {
+ expect(() => new LockFile.parse('sdks: oops', sources),
+ throwsFormatException);
+ });
+
+ test("throws if an sdk constraint isn't a string", () {
+ expect(() => new LockFile.parse('sdks: {dart: 1.0}', sources),
+ throwsFormatException);
+ expect(() {
+ new LockFile.parse('sdks: {dart: 1.0.0, flutter: 1.0}', sources);
+ }, throwsFormatException);
+ });
+
+ test("throws if an sdk constraint is invalid", () {
+ expect(() => new LockFile.parse('sdks: {dart: oops}', sources),
+ throwsFormatException);
+ expect(() {
+ new LockFile.parse('sdks: {dart: 1.0.0, flutter: oops}', sources);
+ }, throwsFormatException);
+ });
+
test("ignores extra stuff in file", () {
new LockFile.parse('''
extra:
@@ -197,7 +247,7 @@ packages:
]);
expect(loadYaml(lockfile.serialize(null)), equals({
- 'sdk': 'any',
+ 'sdks': {'dart': 'any'},
'packages': {
'foo': {
'version': '1.2.3',
« no previous file with comments | « lib/src/validator/sdk_constraint.dart ('k') | test/must_pub_get_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698