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

Unified Diff: sdk/lib/_internal/pub/test/lock_file_test.dart

Issue 15347004: Gracefully handle pubspecs with dependencies using unknown sources. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add tests for unknown sources in lockfiles. Created 7 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: sdk/lib/_internal/pub/test/lock_file_test.dart
diff --git a/sdk/lib/_internal/pub/test/lock_file_test.dart b/sdk/lib/_internal/pub/test/lock_file_test.dart
index 0f7fe53875149a9ec29380ea88bb1e654c9ee19b..8b05d9d06b6006ff489a53d512958f0f3d52958d 100644
--- a/sdk/lib/_internal/pub/test/lock_file_test.dart
+++ b/sdk/lib/_internal/pub/test/lock_file_test.dart
@@ -13,6 +13,7 @@ import '../lib/src/source.dart';
import '../lib/src/source_registry.dart';
import '../lib/src/utils.dart';
import '../lib/src/version.dart';
+import 'test_pub.dart';
class MockSource extends Source {
final String name = 'mock';
@@ -31,6 +32,8 @@ class MockSource extends Source {
}
main() {
+ initConfig();
+
var sources = new SourceRegistry();
var mockSource = new MockSource();
sources.register(mockSource);
@@ -65,57 +68,57 @@ packages:
var bar = lockFile.packages['bar'];
expect(bar.name, equals('bar'));
expect(bar.version, equals(new Version(1, 2, 3)));
- expect(bar.source, equals(mockSource));
+ expect(bar.source, equals(mockSource.name));
expect(bar.description, equals('bar desc'));
var foo = lockFile.packages['foo'];
expect(foo.name, equals('foo'));
expect(foo.version, equals(new Version(2, 3, 4)));
- expect(foo.source, equals(mockSource));
+ expect(foo.source, equals(mockSource.name));
expect(foo.description, equals('foo desc'));
});
- test("throws if the version is missing", () {
- expect(() {
- new LockFile.parse('''
+ test("allows an unknown source", () {
+ var lockFile = new LockFile.parse('''
packages:
foo:
- source: mock
+ source: bad
+ version: 1.2.3
description: foo desc
''', sources);
- }, throwsFormatException);
+ var foo = lockFile.packages['foo'];
+ expect(foo.source, equals('bad'));
});
- test("throws if the version is invalid", () {
+ test("throws if the version is missing", () {
expect(() {
new LockFile.parse('''
packages:
foo:
- version: vorpal
source: mock
description: foo desc
''', sources);
}, throwsFormatException);
});
- test("throws if the source is missing", () {
+ test("throws if the version is invalid", () {
expect(() {
new LockFile.parse('''
packages:
foo:
- version: 1.2.3
+ version: vorpal
+ source: mock
description: foo desc
''', sources);
}, throwsFormatException);
});
- test("throws if the source is unknown", () {
+ test("throws if the source is missing", () {
expect(() {
new LockFile.parse('''
packages:
foo:
version: 1.2.3
- source: notreal
description: foo desc
''', sources);
}, throwsFormatException);
@@ -166,9 +169,9 @@ packages:
test('dumps the lockfile to YAML', () {
lockfile.packages['foo'] = new PackageId(
- 'foo', mockSource, new Version.parse('1.2.3'), 'foo desc');
+ 'foo', mockSource.name, new Version.parse('1.2.3'), 'foo desc');
lockfile.packages['bar'] = new PackageId(
- 'bar', mockSource, new Version.parse('3.2.1'), 'bar desc');
+ 'bar', mockSource.name, new Version.parse('3.2.1'), 'bar desc');
expect(loadYaml(lockfile.serialize()), equals({
'packages': {
@@ -189,7 +192,7 @@ packages:
test('lockfile is alphabetized by package name', () {
var testNames = ['baz', 'Qwe', 'Q', 'B', 'Bar', 'bar', 'foo'];
testNames.forEach((name) {
- lockfile.packages[name] = new PackageId(name, mockSource,
+ lockfile.packages[name] = new PackageId(name, mockSource.name,
new Version.parse('5.5.5'), '$name desc');
});
« no previous file with comments | « sdk/lib/_internal/pub/test/install/unknown_source_test.dart ('k') | sdk/lib/_internal/pub/test/pub_cache_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698