Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Side by Side Diff: test/pubspec_test.dart

Issue 2044253003: Refactor Source and SourceRegistry. (Closed) Base URL: git@github.com:dart-lang/pub.git@master
Patch Set: Rename LiveSource to BoundSource. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/package_list_files_test.dart ('k') | test/test_pub.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 'dart:async';
6
7 import 'package:pub/src/package.dart'; 5 import 'package:pub/src/package.dart';
8 import 'package:pub/src/pubspec.dart'; 6 import 'package:pub/src/pubspec.dart';
9 import 'package:pub/src/source.dart'; 7 import 'package:pub/src/source.dart';
10 import 'package:pub/src/source/path.dart'; 8 import 'package:pub/src/source/path.dart';
11 import 'package:pub/src/source_registry.dart'; 9 import 'package:pub/src/source_registry.dart';
10 import 'package:pub/src/system_cache.dart';
12 import 'package:pub_semver/pub_semver.dart'; 11 import 'package:pub_semver/pub_semver.dart';
13 import 'package:test/test.dart'; 12 import 'package:test/test.dart';
14 13
15 class MockSource extends Source { 14 class MockSource extends Source {
16 final String name = "mock"; 15 final String name = "mock";
17 16
18 Future<List<PackageId>> doGetVersions(PackageRef ref) => 17 BoundSource bind(SystemCache cache) =>
19 throw new UnsupportedError("Cannot get mock package versions."); 18 throw new UnsupportedError("Cannot download mock packages.");
20
21 Future<Pubspec> doDescribe(PackageId id) => throw new UnsupportedError(
22 "Cannot describe mock packages.");
23
24 Future get(PackageId id, String symlink) => throw new UnsupportedError(
25 "Cannot get a mock package.");
26
27 String getDirectory(PackageId id) => throw new UnsupportedError(
28 "Cannot get the directory for mock packages.");
29 19
30 PackageRef parseRef(String name, description, {String containingPath}) { 20 PackageRef parseRef(String name, description, {String containingPath}) {
31 if (description != 'ok') throw new FormatException('Bad'); 21 if (description != 'ok') throw new FormatException('Bad');
32 return new PackageRef(name, this.name, description); 22 return new PackageRef(name, this.name, description);
33 } 23 }
34 24
35 PackageId parseId(String name, Version version, description) => 25 PackageId parseId(String name, Version version, description) =>
36 new PackageId(name, this.name, version, description); 26 new PackageId(name, this.name, version, description);
37 27
38 bool descriptionsEqual(description1, description2) => 28 bool descriptionsEqual(description1, description2) =>
39 description1 == description2; 29 description1 == description2;
40 30
41 String packageName(description) => 'foo'; 31 String packageName(description) => 'foo';
42 } 32 }
43 33
44 main() { 34 main() {
45 group('parse()', () { 35 group('parse()', () {
46 var sources = new SourceRegistry(); 36 var sources = new SourceRegistry();
47 sources.register(new MockSource()); 37 sources.register(new MockSource());
48 sources.register(new PathSource());
49 38
50 var throwsPubspecException = 39 var throwsPubspecException =
51 throwsA(new isInstanceOf<PubspecException>()); 40 throwsA(new isInstanceOf<PubspecException>());
52 41
53 expectPubspecException(String contents, fn(Pubspec pubspec), 42 expectPubspecException(String contents, fn(Pubspec pubspec),
54 [String expectedContains]) { 43 [String expectedContains]) {
55 var expectation = throwsPubspecException; 44 var expectation = throwsPubspecException;
56 if (expectedContains != null) { 45 if (expectedContains != null) {
57 expectation = throwsA(allOf( 46 expectation = throwsA(allOf(
58 new isInstanceOf<PubspecException>(), 47 new isInstanceOf<PubspecException>(),
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 test("uses the key if the value is null", () { 520 test("uses the key if the value is null", () {
532 var pubspec = new Pubspec.parse(''' 521 var pubspec = new Pubspec.parse('''
533 executables: 522 executables:
534 command: 523 command:
535 ''', sources); 524 ''', sources);
536 expect(pubspec.executables['command'], equals('command')); 525 expect(pubspec.executables['command'], equals('command'));
537 }); 526 });
538 }); 527 });
539 }); 528 });
540 } 529 }
OLDNEW
« no previous file with comments | « test/package_list_files_test.dart ('k') | test/test_pub.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698