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 850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
861 /// Keeps track of which package pubspecs have been requested. Ensures that a | 861 /// Keeps track of which package pubspecs have been requested. Ensures that a |
862 /// source is only hit once for a given package and that pub internally | 862 /// source is only hit once for a given package and that pub internally |
863 /// caches the results. | 863 /// caches the results. |
864 final _requestedPubspecs = new Map<String, Set<Version>>(); | 864 final _requestedPubspecs = new Map<String, Set<Version>>(); |
865 | 865 |
866 final String name; | 866 final String name; |
867 bool get shouldCache => true; | 867 bool get shouldCache => true; |
868 | 868 |
869 MockSource(this.name); | 869 MockSource(this.name); |
870 | 870 |
| 871 Future<String> systemCacheDirectory(PackageId id) { |
| 872 return new Future.value('${id.name}-${id.version}'); |
| 873 } |
| 874 |
871 Future<List<Version>> getVersions(String name, String description) { | 875 Future<List<Version>> getVersions(String name, String description) { |
872 return new Future.sync(() { | 876 return new Future.sync(() { |
873 // Make sure the solver doesn't request the same thing twice. | 877 // Make sure the solver doesn't request the same thing twice. |
874 if (_requestedVersions.contains(description)) { | 878 if (_requestedVersions.contains(description)) { |
875 throw new Exception('Version list for $description was already ' | 879 throw new Exception('Version list for $description was already ' |
876 'requested.'); | 880 'requested.'); |
877 } | 881 } |
878 | 882 |
879 _requestedVersions.add(description); | 883 _requestedVersions.add(description); |
880 | 884 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
965 }; | 969 }; |
966 | 970 |
967 var match = new RegExp(r"(.*) from (.*)").firstMatch(description); | 971 var match = new RegExp(r"(.*) from (.*)").firstMatch(description); |
968 if (match != null) { | 972 if (match != null) { |
969 name = match[1]; | 973 name = match[1]; |
970 source = sourceNames[match[2]]; | 974 source = sourceNames[match[2]]; |
971 } | 975 } |
972 | 976 |
973 callback(isDev, name, source); | 977 callback(isDev, name, source); |
974 } | 978 } |
OLD | NEW |