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

Side by Side Diff: test/validator/sdk_constraint_test.dart

Issue 2172883002: Add validation for Flutter constraints. (Closed) Base URL: git@github.com:dart-lang/pub.git@master
Patch Set: Created 4 years, 5 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 unified diff | Download patch
« no previous file with comments | « lib/src/validator/sdk_constraint.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 import 'package:pub/src/entrypoint.dart'; 5 import 'package:pub/src/entrypoint.dart';
6 import 'package:pub/src/validator.dart'; 6 import 'package:pub/src/validator.dart';
7 import 'package:pub/src/validator/sdk_constraint.dart'; 7 import 'package:pub/src/validator/sdk_constraint.dart';
8 import 'package:scheduled_test/scheduled_test.dart'; 8 import 'package:scheduled_test/scheduled_test.dart';
9 9
10 import '../descriptor.dart' as d; 10 import '../descriptor.dart' as d;
11 import '../test_pub.dart'; 11 import '../test_pub.dart';
12 import 'utils.dart'; 12 import 'utils.dart';
13 13
14 Validator sdkConstraint(Entrypoint entrypoint) => 14 Validator sdkConstraint(Entrypoint entrypoint) =>
15 new SdkConstraintValidator(entrypoint); 15 new SdkConstraintValidator(entrypoint);
16 16
17 main() { 17 main() {
18 group('should consider a package valid if it', () { 18 group('should consider a package valid if it', () {
19 integration('has no SDK constraint', () { 19 integration('has no SDK constraint', () {
20 d.validPackage.create(); 20 d.validPackage.create();
21 expectNoValidationError(sdkConstraint); 21 expectNoValidationError(sdkConstraint);
22 }); 22 });
23 23
24 integration('has an SDK constraint without ^', () { 24 integration('has an SDK constraint without ^', () {
25 d.dir(appPath, [ 25 d.dir(appPath, [
26 d.libPubspec("test_pkg", "1.0.0", sdk: ">=1.8.0 <2.0.0") 26 d.libPubspec("test_pkg", "1.0.0", sdk: ">=1.8.0 <2.0.0")
27 ]).create(); 27 ]).create();
28 expectNoValidationError(sdkConstraint); 28 expectNoValidationError(sdkConstraint);
29 }); 29 });
30
31 integration('has a Flutter SDK constraint with an appropriate Dart SDK '
32 'constraint', () {
33 d.dir(appPath, [
34 d.pubspec({
35 "name": "test_pkg",
36 "version": "1.0.0",
37 "environment": {
38 "sdk": ">=1.19.0 <2.0.0",
39 "flutter": "^1.2.3"
40 }
41 })
42 ]).create();
43 expectNoValidationError(sdkConstraint);
44 });
30 }); 45 });
31 46
32 test("should consider a package invalid if it has an SDK constraint with " 47 group("should consider a package invalid if it", () {
33 "^", () { 48 integration("has an SDK constraint with ^", () {
34 d.dir(appPath, [ 49 d.dir(appPath, [
35 d.libPubspec("test_pkg", "1.0.0", sdk: "^1.8.0") 50 d.libPubspec("test_pkg", "1.0.0", sdk: "^1.8.0")
36 ]).create(); 51 ]).create();
37 expect(schedulePackageValidation(sdkConstraint), 52 expect(
38 completion(pairOf(anyElement(contains('">=1.8.0 <2.0.0"')), isEmpty))); 53 schedulePackageValidation(sdkConstraint),
54 completion(pairOf(
55 anyElement(contains('">=1.8.0 <2.0.0"')),
56 isEmpty)));
57 });
58
59 integration("has a Flutter SDK constraint with a too-broad SDK "
60 "constraint", () {
61 d.dir(appPath, [
62 d.pubspec({
63 "name": "test_pkg",
64 "version": "1.0.0",
65 "environment": {
66 "sdk": ">=1.18.0 <1.50.0",
67 "flutter": "^1.2.3"
68 }
69 })
70 ]).create();
71 expect(
72 schedulePackageValidation(sdkConstraint),
73 completion(pairOf(
74 anyElement(contains('">=1.19.0 <1.50.0"')),
75 isEmpty)));
76 });
77
78 integration("has a Flutter SDK constraint with no SDK "
79 "constraint", () {
80 d.dir(appPath, [
81 d.pubspec({
82 "name": "test_pkg",
83 "version": "1.0.0",
84 "environment": {"flutter": "^1.2.3"}
85 })
86 ]).create();
87 expect(
88 schedulePackageValidation(sdkConstraint),
89 completion(pairOf(
90 anyElement(contains('">=1.19.0 <2.0.0"')),
91 isEmpty)));
92 });
39 }); 93 });
40 } 94 }
OLDNEW
« no previous file with comments | « lib/src/validator/sdk_constraint.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698