OLD | NEW |
| (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:path/path.dart' as path; | |
6 import 'package:scheduled_test/scheduled_test.dart'; | |
7 | |
8 import '../../lib/src/entrypoint.dart'; | |
9 import '../../lib/src/io.dart'; | |
10 import '../../lib/src/validator.dart'; | |
11 import '../../lib/src/validator/name.dart'; | |
12 import '../descriptor.dart' as d; | |
13 import '../test_pub.dart'; | |
14 import 'utils.dart'; | |
15 | |
16 Validator name(Entrypoint entrypoint) => new NameValidator(entrypoint); | |
17 | |
18 main() { | |
19 initConfig(); | |
20 | |
21 group('should consider a package valid if it', () { | |
22 setUp(d.validPackage.create); | |
23 | |
24 integration('looks normal', () => expectNoValidationError(name)); | |
25 | |
26 integration('has a badly-named library in lib/src', () { | |
27 d.dir( | |
28 appPath, | |
29 [ | |
30 d.libPubspec("test_pkg", "1.0.0"), | |
31 d.dir( | |
32 "lib", | |
33 [ | |
34 d.file("test_pkg.dart", "int i = 1;"), | |
35 d.dir("src", [d.file("8ball.dart", "int j = 2;")])])]).cre
ate(); | |
36 expectNoValidationError(name); | |
37 }); | |
38 | |
39 integration('has a name that starts with an underscore', () { | |
40 d.dir( | |
41 appPath, | |
42 [ | |
43 d.libPubspec("_test_pkg", "1.0.0"), | |
44 d.dir("lib", [d.file("_test_pkg.dart", "int i = 1;")])]).create(); | |
45 expectNoValidationError(name); | |
46 }); | |
47 }); | |
48 | |
49 group('should consider a package invalid if it', () { | |
50 setUp(d.validPackage.create); | |
51 | |
52 integration('has an empty package name', () { | |
53 d.dir(appPath, [d.libPubspec("", "1.0.0")]).create(); | |
54 expectValidationError(name); | |
55 }); | |
56 | |
57 integration('has a package name with an invalid character', () { | |
58 d.dir(appPath, [d.libPubspec("test-pkg", "1.0.0")]).create(); | |
59 expectValidationError(name); | |
60 }); | |
61 | |
62 integration('has a package name that begins with a number', () { | |
63 d.dir(appPath, [d.libPubspec("8ball", "1.0.0")]).create(); | |
64 expectValidationError(name); | |
65 }); | |
66 | |
67 integration('has a package name that contains upper-case letters', () { | |
68 d.dir(appPath, [d.libPubspec("TestPkg", "1.0.0")]).create(); | |
69 expectValidationWarning(name); | |
70 }); | |
71 | |
72 integration('has a package name that is a Dart reserved word', () { | |
73 d.dir(appPath, [d.libPubspec("final", "1.0.0")]).create(); | |
74 expectValidationError(name); | |
75 }); | |
76 | |
77 integration('has a library name with an invalid character', () { | |
78 d.dir( | |
79 appPath, | |
80 [ | |
81 d.libPubspec("test_pkg", "1.0.0"), | |
82 d.dir("lib", [d.file("test-pkg.dart", "int i = 0;")])]).create(); | |
83 expectValidationWarning(name); | |
84 }); | |
85 | |
86 integration('has a library name that begins with a number', () { | |
87 d.dir( | |
88 appPath, | |
89 [ | |
90 d.libPubspec("test_pkg", "1.0.0"), | |
91 d.dir("lib", [d.file("8ball.dart", "int i = 0;")])]).create(); | |
92 expectValidationWarning(name); | |
93 }); | |
94 | |
95 integration('has a library name that contains upper-case letters', () { | |
96 d.dir( | |
97 appPath, | |
98 [ | |
99 d.libPubspec("test_pkg", "1.0.0"), | |
100 d.dir("lib", [d.file("TestPkg.dart", "int i = 0;")])]).create(); | |
101 expectValidationWarning(name); | |
102 }); | |
103 | |
104 integration('has a library name that is a Dart reserved word', () { | |
105 d.dir( | |
106 appPath, | |
107 [ | |
108 d.libPubspec("test_pkg", "1.0.0"), | |
109 d.dir("lib", [d.file("for.dart", "int i = 0;")])]).create(); | |
110 expectValidationWarning(name); | |
111 }); | |
112 | |
113 integration('has a single library named differently than the package', () { | |
114 schedule( | |
115 () => deleteEntry(path.join(sandboxDir, appPath, "lib", "test_pkg.dart
"))); | |
116 d.dir( | |
117 appPath, | |
118 [d.dir("lib", [d.file("best_pkg.dart", "int i = 0;")])]).create(); | |
119 expectValidationWarning(name); | |
120 }); | |
121 }); | |
122 } | |
OLD | NEW |