| 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 import 'package:pub/src/package.dart'; | 5 import 'package:pub/src/package.dart'; |
| 6 import 'package:pub/src/pubspec.dart'; | 6 import 'package:pub/src/pubspec.dart'; |
| 7 import 'package:pub/src/source.dart'; | 7 import 'package:pub/src/source.dart'; |
| 8 import 'package:pub/src/source/path.dart'; | 8 import 'package:pub/src/source/path.dart'; |
| 9 import 'package:pub/src/source_registry.dart'; | 9 import 'package:pub/src/source_registry.dart'; |
| 10 import 'package:pub/src/system_cache.dart'; | 10 import 'package:pub/src/system_cache.dart'; |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 expectPubspecException(''' | 398 expectPubspecException(''' |
| 399 name: pkg | 399 name: pkg |
| 400 dependencies: | 400 dependencies: |
| 401 from_path: {path: non_local_path} | 401 from_path: {path: non_local_path} |
| 402 ''', (pubspec) => pubspec.dependencies, | 402 ''', (pubspec) => pubspec.dependencies, |
| 403 '"non_local_path" is a relative path, but this isn\'t a local ' | 403 '"non_local_path" is a relative path, but this isn\'t a local ' |
| 404 'pubspec.'); | 404 'pubspec.'); |
| 405 }); | 405 }); |
| 406 | 406 |
| 407 group("environment", () { | 407 group("environment", () { |
| 408 test("defaults to any SDK constraint if environment is omitted", () { | 408 test("allows an omitted environment", () { |
| 409 var pubspec = new Pubspec.parse('', sources); | 409 var pubspec = new Pubspec.parse('', sources); |
| 410 expect(pubspec.environment.sdkVersion, equals(VersionConstraint.any)); | 410 expect(pubspec.dartSdkConstraint, equals(VersionConstraint.any)); |
| 411 }); | 411 expect(pubspec.flutterSdkConstraint, isNull); |
| 412 | |
| 413 test("allows an empty environment map", () { | |
| 414 var pubspec = new Pubspec.parse(''' | |
| 415 environment: | |
| 416 ''', sources); | |
| 417 expect(pubspec.environment.sdkVersion, equals(VersionConstraint.any)); | |
| 418 }); | 412 }); |
| 419 | 413 |
| 420 test("throws if the environment value isn't a map", () { | 414 test("throws if the environment value isn't a map", () { |
| 421 expectPubspecException('environment: []', | 415 expectPubspecException('environment: []', |
| 422 (pubspec) => pubspec.environment); | 416 (pubspec) => pubspec.dartSdkConstraint); |
| 423 }); | 417 }); |
| 424 | 418 |
| 425 test("allows a version constraint for the sdk", () { | 419 test("allows a version constraint for the SDKs", () { |
| 426 var pubspec = new Pubspec.parse(''' | 420 var pubspec = new Pubspec.parse(''' |
| 427 environment: | 421 environment: |
| 428 sdk: ">=1.2.3 <2.3.4" | 422 sdk: ">=1.2.3 <2.3.4" |
| 423 flutter: ^0.1.2 |
| 429 ''', sources); | 424 ''', sources); |
| 430 expect(pubspec.environment.sdkVersion, | 425 expect(pubspec.dartSdkConstraint, |
| 431 equals(new VersionConstraint.parse(">=1.2.3 <2.3.4"))); | 426 equals(new VersionConstraint.parse(">=1.2.3 <2.3.4"))); |
| 427 expect(pubspec.flutterSdkConstraint, |
| 428 equals(new VersionConstraint.parse("^0.1.2"))); |
| 432 }); | 429 }); |
| 433 | 430 |
| 434 test("throws if the sdk isn't a string", () { | 431 test("throws if the sdk isn't a string", () { |
| 435 expectPubspecException('environment: {sdk: []}', | 432 expectPubspecException('environment: {sdk: []}', |
| 436 (pubspec) => pubspec.environment); | 433 (pubspec) => pubspec.dartSdkConstraint); |
| 437 expectPubspecException('environment: {sdk: 1.0}', | 434 expectPubspecException('environment: {sdk: 1.0}', |
| 438 (pubspec) => pubspec.environment); | 435 (pubspec) => pubspec.dartSdkConstraint); |
| 436 expectPubspecException('environment: {sdk: 1.2.3, flutter: []}', |
| 437 (pubspec) => pubspec.dartSdkConstraint); |
| 438 expectPubspecException('environment: {sdk: 1.2.3, flutter: 1.0}', |
| 439 (pubspec) => pubspec.dartSdkConstraint); |
| 439 }); | 440 }); |
| 440 | 441 |
| 441 test("throws if the sdk isn't a valid version constraint", () { | 442 test("throws if the sdk isn't a valid version constraint", () { |
| 442 expectPubspecException('environment: {sdk: "oopies"}', | 443 expectPubspecException('environment: {sdk: "oopies"}', |
| 443 (pubspec) => pubspec.environment); | 444 (pubspec) => pubspec.dartSdkConstraint); |
| 445 expectPubspecException('environment: {sdk: 1.2.3, flutter: "oopies"}', |
| 446 (pubspec) => pubspec.dartSdkConstraint); |
| 444 }); | 447 }); |
| 445 }); | 448 }); |
| 446 | 449 |
| 447 group("publishTo", () { | 450 group("publishTo", () { |
| 448 test("defaults to null if omitted", () { | 451 test("defaults to null if omitted", () { |
| 449 var pubspec = new Pubspec.parse('', sources); | 452 var pubspec = new Pubspec.parse('', sources); |
| 450 expect(pubspec.publishTo, isNull); | 453 expect(pubspec.publishTo, isNull); |
| 451 }); | 454 }); |
| 452 | 455 |
| 453 test("throws if not a string", () { | 456 test("throws if not a string", () { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 test("uses the key if the value is null", () { | 525 test("uses the key if the value is null", () { |
| 523 var pubspec = new Pubspec.parse(''' | 526 var pubspec = new Pubspec.parse(''' |
| 524 executables: | 527 executables: |
| 525 command: | 528 command: |
| 526 ''', sources); | 529 ''', sources); |
| 527 expect(pubspec.executables['command'], equals('command')); | 530 expect(pubspec.executables['command'], equals('command')); |
| 528 }); | 531 }); |
| 529 }); | 532 }); |
| 530 }); | 533 }); |
| 531 } | 534 } |
| OLD | NEW |