Skip to content

Commit

Permalink
Add integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sigurdm committed Dec 3, 2024
1 parent edc5cc4 commit 5a953bb
Showing 1 changed file with 104 additions and 0 deletions.
104 changes: 104 additions & 0 deletions test/unknown_properties_in_description_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
// Copyright (c) 2024, 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.

import 'package:pub/src/exit_codes.dart';
import 'package:test/test.dart';

import 'descriptor.dart' as d;
import 'test_pub.dart';

void main() {
test('Ignores additional properties in descriptions before 3.7', () async {
final server = await servePackages();
server.serve(
'foo',
'1.0.0',
sdk: '^3.6.0',
deps: {
'bar': {
'hosted': {'url': server.url, 'unknown': 11},
},
},
);
server.serve('bar', '1.0.0');
await d.appDir(
pubspec: {
'environment': {'sdk': '^3.6.0'},
},
dependencies: {
'foo': {
'hosted': {'url': server.url, 'unknown': 11},
'version': '^1.0.0',
},
},
).create();
await pubGet(environment: {'_PUB_TEST_SDK_VERSION': '3.7.0'});
});

test('Detects unknown attributes in descriptions in root project after 3.7',
() async {
final server = await servePackages();
server.serve(
'foo',
'1.0.0',
sdk: '^3.6.0',
deps: {
'bar': {
'hosted': {'url': server.url, 'unknown': 11},
},
},
);
server.serve('bar', '1.0.0');
await d.appDir(
pubspec: {
'environment': {'sdk': '^3.7.0'},
},
dependencies: {
'foo': {
'hosted': {'url': server.url, 'unknown': 11},
'version': '^1.0.0',
},
},
).create();
await pubGet(
environment: {'_PUB_TEST_SDK_VERSION': '3.7.0'},
error: contains('Invalid description in the "myapp" pubspec '
'on the "foo" dependency: Unknown key "unknown" in description.'),
exitCode: DATA,
);
});

test('Detects unknown attributes in descriptions in dependency after 3.7',
() async {
final server = await servePackages();
server.serve(
'foo',
'1.0.0',
sdk: '^3.7.0',
deps: {
'bar': {
'hosted': {'url': server.url, 'unknown': 11},
},
},
);
server.serve('bar', '1.0.0');
await d.appDir(
pubspec: {
'environment': {'sdk': '^3.6.0'},
},
dependencies: {
'foo': {
'hosted': {'url': server.url, 'unknown': 11},
'version': '^1.0.0',
},
},
).create();
await pubGet(
environment: {'_PUB_TEST_SDK_VERSION': '3.7.0'},
error: contains('Invalid description in the "foo" pubspec '
'on the "bar" dependency: Unknown key "unknown" in description.'),
exitCode: DATA,
);
});
}

0 comments on commit 5a953bb

Please sign in to comment.