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