| Index: utils/tests/pub/pubspec_test.dart
|
| diff --git a/utils/tests/pub/pubspec_test.dart b/utils/tests/pub/pubspec_test.dart
|
| index dabb7dd44508643b00b6acb5dbc36e55e1592009..cb0402da9b276ed01ed3fd40154e3c0dbcbacb26 100644
|
| --- a/utils/tests/pub/pubspec_test.dart
|
| +++ b/utils/tests/pub/pubspec_test.dart
|
| @@ -5,6 +5,7 @@
|
| library pubspec_test;
|
|
|
| import '../../../pkg/unittest/lib/unittest.dart';
|
| +import 'test_pub.dart';
|
| import '../../pub/pubspec.dart';
|
| import '../../pub/source.dart';
|
| import '../../pub/source_registry.dart';
|
| @@ -112,6 +113,49 @@ dependencies:
|
| expect(pubspec.version, equals(Version.none));
|
| expect(pubspec.dependencies, isEmpty);
|
| });
|
| +
|
| + group("environment", () {
|
| + test("defaults to any SDK constraint if environment is omitted", () {
|
| + var pubspec = new Pubspec.parse('', sources);
|
| + expect(pubspec.environment.sdkVersion, equals(VersionConstraint.any));
|
| + });
|
| +
|
| + test("allows an empty environment map", () {
|
| + var pubspec = new Pubspec.parse('''
|
| +environment:
|
| +''', sources);
|
| + expect(pubspec.environment.sdkVersion, equals(VersionConstraint.any));
|
| + });
|
| +
|
| + test("throws if the environment value isn't a map", () {
|
| + expectFormatError('''
|
| +environment: []
|
| +''');
|
| + });
|
| +
|
| + test("allows a version constraint for the sdk", () {
|
| + var pubspec = new Pubspec.parse('''
|
| +environment:
|
| + sdk: ">=1.2.3 <2.3.4"
|
| +''', sources);
|
| + expect(pubspec.environment.sdkVersion,
|
| + equals(new VersionConstraint.parse(">=1.2.3 <2.3.4")));
|
| + });
|
| +
|
| + test("throws if the sdk isn't a string", () {
|
| + expectFormatError('''
|
| +environment:
|
| + sdk: []
|
| +''');
|
| + });
|
| +
|
| + test("throws if the sdk isn't a valid version constraint", () {
|
| + expectFormatError('''
|
| +environment:
|
| + sdk: "oopies"
|
| +''');
|
| + });
|
| + });
|
| });
|
| });
|
| }
|
|
|