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

Side by Side Diff: sdk/lib/_internal/pub/test/validator/pubspec_field_test.dart

Issue 1165473002: Start pulling pub from its own repo. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Code review changes Created 5 years, 6 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
OLDNEW
(Empty)
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
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.
4
5 import 'package:scheduled_test/scheduled_test.dart';
6
7 import '../../lib/src/entrypoint.dart';
8 import '../../lib/src/validator.dart';
9 import '../../lib/src/validator/pubspec_field.dart';
10 import '../descriptor.dart' as d;
11 import '../test_pub.dart';
12 import 'utils.dart';
13
14 Validator pubspecField(Entrypoint entrypoint) =>
15 new PubspecFieldValidator(entrypoint);
16
17 main() {
18 initConfig();
19
20 group('should consider a package valid if it', () {
21 setUp(d.validPackage.create);
22
23 integration('looks normal', () => expectNoValidationError(pubspecField));
24
25 integration('has "authors" instead of "author"', () {
26 var pkg = packageMap("test_pkg", "1.0.0");
27 pkg["authors"] = [pkg.remove("author")];
28 d.dir(appPath, [d.pubspec(pkg)]).create();
29 expectNoValidationError(pubspecField);
30 });
31
32 integration('has an HTTPS homepage URL', () {
33 var pkg = packageMap("test_pkg", "1.0.0");
34 pkg["homepage"] = "https://pub.dartlang.org";
35 d.dir(appPath, [d.pubspec(pkg)]).create();
36
37 expectNoValidationError(pubspecField);
38 });
39
40 integration('has an HTTPS documentation URL', () {
41 var pkg = packageMap("test_pkg", "1.0.0");
42 pkg["documentation"] = "https://pub.dartlang.org";
43 d.dir(appPath, [d.pubspec(pkg)]).create();
44
45 expectNoValidationError(pubspecField);
46 });
47 });
48
49 group('should consider a package invalid if it', () {
50 setUp(d.validPackage.create);
51
52 integration('is missing the "homepage" field', () {
53 var pkg = packageMap("test_pkg", "1.0.0");
54 pkg.remove("homepage");
55 d.dir(appPath, [d.pubspec(pkg)]).create();
56
57 expectValidationError(pubspecField);
58 });
59
60 integration('is missing the "description" field', () {
61 var pkg = packageMap("test_pkg", "1.0.0");
62 pkg.remove("description");
63 d.dir(appPath, [d.pubspec(pkg)]).create();
64
65 expectValidationError(pubspecField);
66 });
67
68 integration('is missing the "author" field', () {
69 var pkg = packageMap("test_pkg", "1.0.0");
70 pkg.remove("author");
71 d.dir(appPath, [d.pubspec(pkg)]).create();
72
73 expectValidationError(pubspecField);
74 });
75
76 integration('has a non-string "homepage" field', () {
77 var pkg = packageMap("test_pkg", "1.0.0");
78 pkg["homepage"] = 12;
79 d.dir(appPath, [d.pubspec(pkg)]).create();
80
81 expectValidationError(pubspecField);
82 });
83
84 integration('has a non-string "description" field', () {
85 var pkg = packageMap("test_pkg", "1.0.0");
86 pkg["description"] = 12;
87 d.dir(appPath, [d.pubspec(pkg)]).create();
88
89 expectValidationError(pubspecField);
90 });
91
92 integration('has a non-string "author" field', () {
93 var pkg = packageMap("test_pkg", "1.0.0");
94 pkg["author"] = 12;
95 d.dir(appPath, [d.pubspec(pkg)]).create();
96
97 expectValidationError(pubspecField);
98 });
99
100 integration('has a non-list "authors" field', () {
101 var pkg = packageMap("test_pkg", "1.0.0");
102 pkg["authors"] = 12;
103 d.dir(appPath, [d.pubspec(pkg)]).create();
104
105 expectValidationError(pubspecField);
106 });
107
108 integration('has a non-string member of the "authors" field', () {
109 var pkg = packageMap("test_pkg", "1.0.0");
110 pkg["authors"] = [12];
111 d.dir(appPath, [d.pubspec(pkg)]).create();
112
113 expectValidationError(pubspecField);
114 });
115
116 integration('has a single author without an email', () {
117 var pkg = packageMap("test_pkg", "1.0.0");
118 pkg["author"] = "Natalie Weizenbaum";
119 d.dir(appPath, [d.pubspec(pkg)]).create();
120
121 expectValidationWarning(pubspecField);
122 });
123
124 integration('has one of several authors without an email', () {
125 var pkg = packageMap("test_pkg", "1.0.0");
126 pkg.remove("author");
127 pkg["authors"] = [
128 "Bob Nystrom <rnystrom@google.com>",
129 "Natalie Weizenbaum",
130 "John Messerly <jmesserly@google.com>"
131 ];
132 d.dir(appPath, [d.pubspec(pkg)]).create();
133
134 expectValidationWarning(pubspecField);
135 });
136
137 integration('has a single author without a name', () {
138 var pkg = packageMap("test_pkg", "1.0.0");
139 pkg["author"] = "<nweiz@google.com>";
140 d.dir(appPath, [d.pubspec(pkg)]).create();
141
142 expectValidationWarning(pubspecField);
143 });
144
145 integration('has one of several authors without a name', () {
146 var pkg = packageMap("test_pkg", "1.0.0");
147 pkg.remove("author");
148 pkg["authors"] = [
149 "Bob Nystrom <rnystrom@google.com>",
150 "<nweiz@google.com>",
151 "John Messerly <jmesserly@google.com>"
152 ];
153 d.dir(appPath, [d.pubspec(pkg)]).create();
154
155 expectValidationWarning(pubspecField);
156 });
157
158 integration('has a non-HTTP homepage URL', () {
159 var pkg = packageMap("test_pkg", "1.0.0");
160 pkg["homepage"] = "file:///foo/bar";
161 d.dir(appPath, [d.pubspec(pkg)]).create();
162
163 expectValidationError(pubspecField);
164 });
165
166 integration('has a non-HTTP documentation URL', () {
167 var pkg = packageMap("test_pkg", "1.0.0");
168 pkg["documentation"] = "file:///foo/bar";
169 d.dir(appPath, [d.pubspec(pkg)]).create();
170
171 expectValidationError(pubspecField);
172 });
173 });
174 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/pub/test/validator/name_test.dart ('k') | sdk/lib/_internal/pub/test/validator/sdk_constraint_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698