| 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'; |
| 8 |
| 7 import 'package:unittest/unittest.dart'; | 9 import 'package:unittest/unittest.dart'; |
| 8 | 10 |
| 11 import '../lib/src/package.dart'; |
| 9 import '../lib/src/pubspec.dart'; | 12 import '../lib/src/pubspec.dart'; |
| 10 import '../lib/src/source.dart'; | 13 import '../lib/src/source.dart'; |
| 11 import '../lib/src/source_registry.dart'; | 14 import '../lib/src/source_registry.dart'; |
| 12 import '../lib/src/version.dart'; | 15 import '../lib/src/version.dart'; |
| 13 import 'test_pub.dart'; | 16 import 'test_pub.dart'; |
| 14 | 17 |
| 15 class MockSource extends Source { | 18 class MockSource extends Source { |
| 16 final String name = "mock"; | 19 final String name = "mock"; |
| 17 final bool shouldCache = false; | 20 |
| 21 Future<Pubspec> onDescribe(PackageId id) => throw new UnsupportedError( |
| 22 "Cannot describe mock packages."); |
| 23 |
| 24 Future<bool> get(PackageId id, String path) => throw new UnsupportedError( |
| 25 "Cannot get a mock package."); |
| 26 |
| 27 Future<String> getDirectory(PackageId id) => throw new UnsupportedError( |
| 28 "Cannot get the directory for mock packages."); |
| 29 |
| 18 dynamic parseDescription(String filePath, description, | 30 dynamic parseDescription(String filePath, description, |
| 19 {bool fromLockFile: false}) { | 31 {bool fromLockFile: false}) { |
| 20 if (description != 'ok') throw new FormatException('Bad'); | 32 if (description != 'ok') throw new FormatException('Bad'); |
| 21 return description; | 33 return description; |
| 22 } | 34 } |
| 35 |
| 36 bool descriptionsEqual(description1, description2) => |
| 37 description1 == description2; |
| 38 |
| 23 String packageName(description) => 'foo'; | 39 String packageName(description) => 'foo'; |
| 24 } | 40 } |
| 25 | 41 |
| 26 main() { | 42 main() { |
| 27 initConfig(); | 43 initConfig(); |
| 28 group('parse()', () { | 44 group('parse()', () { |
| 29 var sources = new SourceRegistry(); | 45 var sources = new SourceRegistry(); |
| 30 sources.register(new MockSource()); | 46 sources.register(new MockSource()); |
| 31 | 47 |
| 32 var throwsPubspecException = | 48 var throwsPubspecException = |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 (pubspec) => pubspec.environment); | 411 (pubspec) => pubspec.environment); |
| 396 }); | 412 }); |
| 397 | 413 |
| 398 test("throws if the sdk isn't a valid version constraint", () { | 414 test("throws if the sdk isn't a valid version constraint", () { |
| 399 expectPubspecException('environment: {sdk: "oopies"}', | 415 expectPubspecException('environment: {sdk: "oopies"}', |
| 400 (pubspec) => pubspec.environment); | 416 (pubspec) => pubspec.environment); |
| 401 }); | 417 }); |
| 402 }); | 418 }); |
| 403 }); | 419 }); |
| 404 } | 420 } |
| OLD | NEW |