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 pub_update_test; | 5 library pub_update_test; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:io'; | 8 import 'dart:io'; |
9 | 9 |
10 import 'package:unittest/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 class MockSource extends Source { | 474 class MockSource extends Source { |
475 final Map<String, Map<Version, Package>> _packages; | 475 final Map<String, Map<Version, Package>> _packages; |
476 | 476 |
477 final String name; | 477 final String name; |
478 bool get shouldCache => true; | 478 bool get shouldCache => true; |
479 | 479 |
480 MockSource(this.name) | 480 MockSource(this.name) |
481 : _packages = <String, Map<Version, Package>>{}; | 481 : _packages = <String, Map<Version, Package>>{}; |
482 | 482 |
483 Future<List<Version>> getVersions(String name, String description) { | 483 Future<List<Version>> getVersions(String name, String description) { |
484 return new Future.of(() => _packages[description].keys.toList()); | 484 return new Future.sync(() => _packages[description].keys.toList()); |
485 } | 485 } |
486 | 486 |
487 Future<Pubspec> describe(PackageId id) { | 487 Future<Pubspec> describe(PackageId id) { |
488 return new Future.of(() => _packages[id.name][id.version].pubspec); | 488 return new Future.sync(() => _packages[id.name][id.version].pubspec); |
489 } | 489 } |
490 | 490 |
491 Future<bool> install(PackageId id, String path) { | 491 Future<bool> install(PackageId id, String path) { |
492 throw 'no'; | 492 throw 'no'; |
493 } | 493 } |
494 | 494 |
495 Package mockPackage(String description, String version, | 495 Package mockPackage(String description, String version, |
496 Map dependencyStrings) { | 496 Map dependencyStrings) { |
497 // Build the pubspec dependencies. | 497 // Build the pubspec dependencies. |
498 var dependencies = <PackageRef>[]; | 498 var dependencies = <PackageRef>[]; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 }; | 543 }; |
544 | 544 |
545 var match = new RegExp(r"(.*) from (.*)").firstMatch(description); | 545 var match = new RegExp(r"(.*) from (.*)").firstMatch(description); |
546 if (match != null) { | 546 if (match != null) { |
547 name = match[1]; | 547 name = match[1]; |
548 source = sourceNames[match[2]]; | 548 source = sourceNames[match[2]]; |
549 } | 549 } |
550 | 550 |
551 callback(isDev, name, source); | 551 callback(isDev, name, source); |
552 } | 552 } |
OLD | NEW |