| Index: sdk/lib/_internal/pub_generated/test/lock_file_test.dart
|
| diff --git a/sdk/lib/_internal/pub/test/lock_file_test.dart b/sdk/lib/_internal/pub_generated/test/lock_file_test.dart
|
| similarity index 84%
|
| copy from sdk/lib/_internal/pub/test/lock_file_test.dart
|
| copy to sdk/lib/_internal/pub_generated/test/lock_file_test.dart
|
| index 68d04ce07fba3adeb56306dfb701fabdba616466..ed931941d1cc465dbcdb0e7f3e5b7ad27ccb994f 100644
|
| --- a/sdk/lib/_internal/pub/test/lock_file_test.dart
|
| +++ b/sdk/lib/_internal/pub_generated/test/lock_file_test.dart
|
| @@ -1,14 +1,7 @@
|
| -// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
| -// for details. All rights reserved. Use of this source code is governed by a
|
| -// BSD-style license that can be found in the LICENSE file.
|
| -
|
| library lock_file_test;
|
| -
|
| import 'dart:async';
|
| -
|
| import 'package:unittest/unittest.dart';
|
| import 'package:yaml/yaml.dart';
|
| -
|
| import '../lib/src/lock_file.dart';
|
| import '../lib/src/package.dart';
|
| import '../lib/src/pubspec.dart';
|
| @@ -16,53 +9,40 @@ import '../lib/src/source.dart';
|
| import '../lib/src/source_registry.dart';
|
| import '../lib/src/version.dart';
|
| import 'test_pub.dart';
|
| -
|
| class MockSource extends Source {
|
| final String name = 'mock';
|
| -
|
| - Future<Pubspec> doDescribe(PackageId id) => throw new UnsupportedError(
|
| - "Cannot describe mock packages.");
|
| -
|
| - Future get(PackageId id, String symlink) => throw new UnsupportedError(
|
| - "Cannot get a mock package.");
|
| -
|
| - Future<String> getDirectory(PackageId id) => throw new UnsupportedError(
|
| - "Cannot get the directory for mock packages.");
|
| -
|
| + Future<Pubspec> doDescribe(PackageId id) =>
|
| + throw new UnsupportedError("Cannot describe mock packages.");
|
| + Future get(PackageId id, String symlink) =>
|
| + throw new UnsupportedError("Cannot get a mock package.");
|
| + Future<String> getDirectory(PackageId id) =>
|
| + throw new UnsupportedError("Cannot get the directory for mock packages.");
|
| dynamic parseDescription(String filePath, String description,
|
| - {bool fromLockFile: false}) {
|
| + {bool fromLockFile: false}) {
|
| if (!description.endsWith(' desc')) throw new FormatException();
|
| return description;
|
| }
|
| -
|
| bool descriptionsEqual(description1, description2) =>
|
| description1 == description2;
|
| -
|
| String packageName(String description) {
|
| - // Strip off ' desc'.
|
| return description.substring(0, description.length - 5);
|
| }
|
| }
|
| -
|
| main() {
|
| initConfig();
|
| -
|
| var sources = new SourceRegistry();
|
| var mockSource = new MockSource();
|
| sources.register(mockSource);
|
| -
|
| group('LockFile', () {
|
| group('parse()', () {
|
| test('returns an empty lockfile if the contents are empty', () {
|
| var lockFile = new LockFile.parse('', sources);
|
| expect(lockFile.packages.length, equals(0));
|
| });
|
| -
|
| test('returns an empty lockfile if the contents are whitespace', () {
|
| var lockFile = new LockFile.parse(' \t\n ', sources);
|
| expect(lockFile.packages.length, equals(0));
|
| });
|
| -
|
| test('parses a series of package descriptions', () {
|
| var lockFile = new LockFile.parse('''
|
| packages:
|
| @@ -75,22 +55,18 @@ packages:
|
| source: mock
|
| description: foo desc
|
| ''', sources);
|
| -
|
| expect(lockFile.packages.length, equals(2));
|
| -
|
| var bar = lockFile.packages['bar'];
|
| expect(bar.name, equals('bar'));
|
| expect(bar.version, equals(new Version(1, 2, 3)));
|
| 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.name));
|
| expect(foo.description, equals('foo desc'));
|
| });
|
| -
|
| test("allows an unknown source", () {
|
| var lockFile = new LockFile.parse('''
|
| packages:
|
| @@ -102,14 +78,12 @@ packages:
|
| var foo = lockFile.packages['foo'];
|
| expect(foo.source, equals('bad'));
|
| });
|
| -
|
| test("allows an empty dependency map", () {
|
| var lockFile = new LockFile.parse('''
|
| packages:
|
| ''', sources);
|
| expect(lockFile.packages, isEmpty);
|
| });
|
| -
|
| test("throws if the top level is not a map", () {
|
| expect(() {
|
| new LockFile.parse('''
|
| @@ -117,7 +91,6 @@ not a map
|
| ''', sources);
|
| }, throwsFormatException);
|
| });
|
| -
|
| test("throws if the contents of 'packages' is not a map", () {
|
| expect(() {
|
| new LockFile.parse('''
|
| @@ -125,7 +98,6 @@ packages: not a map
|
| ''', sources);
|
| }, throwsFormatException);
|
| });
|
| -
|
| test("throws if the version is missing", () {
|
| expect(() {
|
| new LockFile.parse('''
|
| @@ -136,7 +108,6 @@ packages:
|
| ''', sources);
|
| }, throwsFormatException);
|
| });
|
| -
|
| test("throws if the version is invalid", () {
|
| expect(() {
|
| new LockFile.parse('''
|
| @@ -148,7 +119,6 @@ packages:
|
| ''', sources);
|
| }, throwsFormatException);
|
| });
|
| -
|
| test("throws if the source is missing", () {
|
| expect(() {
|
| new LockFile.parse('''
|
| @@ -159,7 +129,6 @@ packages:
|
| ''', sources);
|
| }, throwsFormatException);
|
| });
|
| -
|
| test("throws if the description is missing", () {
|
| expect(() {
|
| new LockFile.parse('''
|
| @@ -170,7 +139,6 @@ packages:
|
| ''', sources);
|
| }, throwsFormatException);
|
| });
|
| -
|
| test("throws if the description is invalid", () {
|
| expect(() {
|
| new LockFile.parse('''
|
| @@ -182,7 +150,6 @@ packages:
|
| ''', sources);
|
| }, throwsFormatException);
|
| });
|
| -
|
| test("ignores extra stuff in file", () {
|
| var lockFile = new LockFile.parse('''
|
| extra:
|
| @@ -196,19 +163,16 @@ packages:
|
| ''', sources);
|
| });
|
| });
|
| -
|
| group('serialize()', () {
|
| var lockfile;
|
| setUp(() {
|
| lockfile = new LockFile.empty();
|
| });
|
| -
|
| test('dumps the lockfile to YAML', () {
|
| - lockfile.packages['foo'] = new PackageId(
|
| - 'foo', mockSource.name, new Version.parse('1.2.3'), 'foo desc');
|
| - lockfile.packages['bar'] = new PackageId(
|
| - 'bar', mockSource.name, new Version.parse('3.2.1'), 'bar desc');
|
| -
|
| + lockfile.packages['foo'] =
|
| + new PackageId('foo', mockSource.name, new Version.parse('1.2.3'), 'foo desc');
|
| + lockfile.packages['bar'] =
|
| + new PackageId('bar', mockSource.name, new Version.parse('3.2.1'), 'bar desc');
|
| expect(loadYaml(lockfile.serialize(null, sources)), equals({
|
| 'packages': {
|
| 'foo': {
|
|
|