| 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:io'); | 7 #import('dart:io'); |
| 8 #import('dart:isolate'); | 8 #import('dart:isolate'); |
| 9 | 9 |
| 10 #import('../../pub/lock_file.dart'); | 10 #import('../../pub/lock_file.dart'); |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 * descriptions, a package's name is calculated by taking the description string | 374 * descriptions, a package's name is calculated by taking the description string |
| 375 * and stripping off any trailing hyphen followed by non-hyphen characters. | 375 * and stripping off any trailing hyphen followed by non-hyphen characters. |
| 376 */ | 376 */ |
| 377 class MockSource extends Source { | 377 class MockSource extends Source { |
| 378 final Map<String, Map<Version, Package>> _packages; | 378 final Map<String, Map<Version, Package>> _packages; |
| 379 | 379 |
| 380 final String name; | 380 final String name; |
| 381 bool get shouldCache() => true; | 381 bool get shouldCache() => true; |
| 382 | 382 |
| 383 MockSource(this.name) | 383 MockSource(this.name) |
| 384 : _packages = <Map<Version, Package>>{}; | 384 : _packages = <String, Map<Version, Package>>{}; |
| 385 | 385 |
| 386 Future<List<Version>> getVersions(String name) { | 386 Future<List<Version>> getVersions(String name) { |
| 387 return fakeAsync(() => _packages[name].getKeys()); | 387 return fakeAsync(() => _packages[name].getKeys()); |
| 388 } | 388 } |
| 389 | 389 |
| 390 Future<Pubspec> describe(PackageId id) { | 390 Future<Pubspec> describe(PackageId id) { |
| 391 return fakeAsync(() { | 391 return fakeAsync(() { |
| 392 return _packages[id.name][id.version].pubspec; | 392 return _packages[id.name][id.version].pubspec; |
| 393 }); | 393 }); |
| 394 } | 394 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 424 * A source used for testing that doesn't natively understand versioning, | 424 * A source used for testing that doesn't natively understand versioning, |
| 425 * similar to how the Git and SDK sources work. | 425 * similar to how the Git and SDK sources work. |
| 426 */ | 426 */ |
| 427 class MockVersionlessSource extends Source { | 427 class MockVersionlessSource extends Source { |
| 428 final Map<String, Package> _packages; | 428 final Map<String, Package> _packages; |
| 429 | 429 |
| 430 final String name = 'versionless'; | 430 final String name = 'versionless'; |
| 431 final bool shouldCache = false; | 431 final bool shouldCache = false; |
| 432 | 432 |
| 433 MockVersionlessSource() | 433 MockVersionlessSource() |
| 434 : _packages = <Package>{}; | 434 : _packages = <String, Package>{}; |
| 435 | 435 |
| 436 Future<bool> install(PackageId id, String path) { | 436 Future<bool> install(PackageId id, String path) { |
| 437 throw 'no'; | 437 throw 'no'; |
| 438 } | 438 } |
| 439 | 439 |
| 440 Future<Pubspec> describe(PackageId id) { | 440 Future<Pubspec> describe(PackageId id) { |
| 441 return new Future<Pubspec>.immediate(_packages[id.description].pubspec); | 441 return new Future<Pubspec>.immediate(_packages[id.description].pubspec); |
| 442 } | 442 } |
| 443 | 443 |
| 444 void addPackage(Package package) { | 444 void addPackage(Package package) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 458 Pair<String, Source> parseSource(String name) { | 458 Pair<String, Source> parseSource(String name) { |
| 459 var match = new RegExp(@"(.*) from (.*)").firstMatch(name); | 459 var match = new RegExp(@"(.*) from (.*)").firstMatch(name); |
| 460 if (match == null) return new Pair<String, Source>(name, source1); | 460 if (match == null) return new Pair<String, Source>(name, source1); |
| 461 switch (match[2]) { | 461 switch (match[2]) { |
| 462 case 'mock1': return new Pair<String, Source>(match[1], source1); | 462 case 'mock1': return new Pair<String, Source>(match[1], source1); |
| 463 case 'mock2': return new Pair<String, Source>(match[1], source2); | 463 case 'mock2': return new Pair<String, Source>(match[1], source2); |
| 464 case 'versionless': | 464 case 'versionless': |
| 465 return new Pair<String, Source>(match[1], versionlessSource); | 465 return new Pair<String, Source>(match[1], versionlessSource); |
| 466 } | 466 } |
| 467 } | 467 } |
| OLD | NEW |