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 library pubspec_test; | 5 library pubspec_test; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import 'package:unittest/unittest.dart'; | 9 import 'package:unittest/unittest.dart'; |
10 | 10 |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 (pubspec) => pubspec.environment); | 406 (pubspec) => pubspec.environment); |
407 expectPubspecException('environment: {sdk: 1.0}', | 407 expectPubspecException('environment: {sdk: 1.0}', |
408 (pubspec) => pubspec.environment); | 408 (pubspec) => pubspec.environment); |
409 }); | 409 }); |
410 | 410 |
411 test("throws if the sdk isn't a valid version constraint", () { | 411 test("throws if the sdk isn't a valid version constraint", () { |
412 expectPubspecException('environment: {sdk: "oopies"}', | 412 expectPubspecException('environment: {sdk: "oopies"}', |
413 (pubspec) => pubspec.environment); | 413 (pubspec) => pubspec.environment); |
414 }); | 414 }); |
415 }); | 415 }); |
| 416 |
| 417 group("publishTo", () { |
| 418 test("defaults to null if omitted", () { |
| 419 var pubspec = new Pubspec.parse('', sources); |
| 420 expect(pubspec.publishTo, isNull); |
| 421 }); |
| 422 |
| 423 test("throws if not a string", () { |
| 424 expectPubspecException('publishTo: 123', |
| 425 (pubspec) => pubspec.publishTo); |
| 426 }); |
| 427 |
| 428 test("allows a URL", () { |
| 429 var pubspec = new Pubspec.parse(''' |
| 430 publishTo: http://example.com |
| 431 ''', sources); |
| 432 expect(pubspec.publishTo, equals("http://example.com")); |
| 433 }); |
| 434 |
| 435 test("allows none", () { |
| 436 var pubspec = new Pubspec.parse(''' |
| 437 publishTo: none |
| 438 ''', sources); |
| 439 expect(pubspec.publishTo, equals("none")); |
| 440 }); |
| 441 |
| 442 test("throws on other strings", () { |
| 443 expectPubspecException('publishTo: http://bad.url:not-port', |
| 444 (pubspec) => pubspec.publishTo); |
| 445 }); |
| 446 }); |
416 }); | 447 }); |
417 } | 448 } |
OLD | NEW |