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:pub/src/package.dart'; | 9 import 'package:pub/src/package.dart'; |
10 import 'package:pub/src/pubspec.dart'; | 10 import 'package:pub/src/pubspec.dart'; |
11 import 'package:pub/src/source.dart'; | 11 import 'package:pub/src/source.dart'; |
12 import 'package:pub/src/source/path.dart'; | 12 import 'package:pub/src/source/path.dart'; |
13 import 'package:pub/src/source_registry.dart'; | 13 import 'package:pub/src/source_registry.dart'; |
14 import 'package:pub_semver/pub_semver.dart'; | 14 import 'package:pub_semver/pub_semver.dart'; |
15 import 'package:test/test.dart'; | 15 import 'package:test/test.dart'; |
16 | 16 |
17 import 'test_pub.dart'; | 17 import 'test_pub.dart'; |
18 | 18 |
19 class MockSource extends Source { | 19 class MockSource extends Source { |
20 final String name = "mock"; | 20 final String name = "mock"; |
21 | 21 |
| 22 Future<List<PackageId>> doGetVersions(PackageRef ref) => |
| 23 throw new UnsupportedError("Cannot get mock package versions."); |
| 24 |
22 Future<Pubspec> doDescribe(PackageId id) => throw new UnsupportedError( | 25 Future<Pubspec> doDescribe(PackageId id) => throw new UnsupportedError( |
23 "Cannot describe mock packages."); | 26 "Cannot describe mock packages."); |
24 | 27 |
25 Future get(PackageId id, String symlink) => throw new UnsupportedError( | 28 Future get(PackageId id, String symlink) => throw new UnsupportedError( |
26 "Cannot get a mock package."); | 29 "Cannot get a mock package."); |
27 | 30 |
28 String getDirectory(PackageId id) => throw new UnsupportedError( | 31 String getDirectory(PackageId id) => throw new UnsupportedError( |
29 "Cannot get the directory for mock packages."); | 32 "Cannot get the directory for mock packages."); |
30 | 33 |
31 dynamic parseDescription(String filePath, description, | 34 PackageRef parseRef(String name, description, {String containingPath}) { |
32 {bool fromLockFile: false}) { | |
33 if (description != 'ok') throw new FormatException('Bad'); | 35 if (description != 'ok') throw new FormatException('Bad'); |
34 return description; | 36 return new PackageRef(name, this.name, description); |
35 } | 37 } |
36 | 38 |
| 39 PackageId parseId(String name, Version version, description) => |
| 40 new PackageId(name, this.name, version, description); |
| 41 |
37 bool descriptionsEqual(description1, description2) => | 42 bool descriptionsEqual(description1, description2) => |
38 description1 == description2; | 43 description1 == description2; |
39 | 44 |
40 String packageName(description) => 'foo'; | 45 String packageName(description) => 'foo'; |
41 } | 46 } |
42 | 47 |
43 main() { | 48 main() { |
44 group('parse()', () { | 49 group('parse()', () { |
45 var sources = new SourceRegistry(); | 50 var sources = new SourceRegistry(); |
46 sources.register(new MockSource()); | 51 sources.register(new MockSource()); |
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
530 test("uses the key if the value is null", () { | 535 test("uses the key if the value is null", () { |
531 var pubspec = new Pubspec.parse(''' | 536 var pubspec = new Pubspec.parse(''' |
532 executables: | 537 executables: |
533 command: | 538 command: |
534 ''', sources); | 539 ''', sources); |
535 expect(pubspec.executables['command'], equals('command')); | 540 expect(pubspec.executables['command'], equals('command')); |
536 }); | 541 }); |
537 }); | 542 }); |
538 }); | 543 }); |
539 } | 544 } |
OLD | NEW |