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(appPath, [ | |
28 d.libPubspec("test_pkg", "1.0.0"), | |
29 d.dir("lib", [ | |
30 d.file("test_pkg.dart", "int i = 1;"), | |
31 d.dir("src", [d.file("8ball.dart", "int j = 2;")]) | |
32 ]) | |
33 ]).create(); | |
34 expectNoValidationError(name); | |
35 }); | |
36 | |
37 integration('has a name that starts with an underscore', () { | |
38 d.dir(appPath, [ | |
39 d.libPubspec("_test_pkg", "1.0.0"), | |
40 d.dir("lib", [ | |
41 d.file("_test_pkg.dart", "int i = 1;") | |
42 ]) | |
43 ]).create(); | |
44 expectNoValidationError(name); | |
45 }); | |
46 }); | |
47 | |
48 group('should consider a package invalid if it', () { | |
49 setUp(d.validPackage.create); | |
50 | |
51 integration('has an empty package name', () { | |
52 d.dir(appPath, [d.libPubspec("", "1.0.0")]).create(); | |
53 expectValidationError(name); | |
54 }); | |
55 | |
56 integration('has a package name with an invalid character', () { | |
57 d.dir(appPath, [d.libPubspec("test-pkg", "1.0.0")]).create(); | |
58 expectValidationError(name); | |
59 }); | |
60 | |
61 integration('has a package name that begins with a number', () { | |
62 d.dir(appPath, [d.libPubspec("8ball", "1.0.0")]).create(); | |
63 expectValidationError(name); | |
64 }); | |
65 | |
66 integration('has a package name that contains upper-case letters', () { | |
67 d.dir(appPath, [d.libPubspec("TestPkg", "1.0.0")]).create(); | |
68 expectValidationWarning(name); | |
69 }); | |
70 | |
71 integration('has a package name that is a Dart reserved word', () { | |
72 d.dir(appPath, [d.libPubspec("final", "1.0.0")]).create(); | |
73 expectValidationError(name); | |
74 }); | |
75 | |
76 integration('has a library name with an invalid character', () { | |
77 d.dir(appPath, [ | |
78 d.libPubspec("test_pkg", "1.0.0"), | |
79 d.dir("lib", [d.file("test-pkg.dart", "int i = 0;")]) | |
80 ]).create(); | |
81 expectValidationWarning(name); | |
82 }); | |
83 | |
84 integration('has a library name that begins with a number', () { | |
85 d.dir(appPath, [ | |
86 d.libPubspec("test_pkg", "1.0.0"), | |
87 d.dir("lib", [d.file("8ball.dart", "int i = 0;")]) | |
88 ]).create(); | |
89 expectValidationWarning(name); | |
90 }); | |
91 | |
92 integration('has a library name that contains upper-case letters', () { | |
93 d.dir(appPath, [ | |
94 d.libPubspec("test_pkg", "1.0.0"), | |
95 d.dir("lib", [d.file("TestPkg.dart", "int i = 0;")]) | |
96 ]).create(); | |
97 expectValidationWarning(name); | |
98 }); | |
99 | |
100 integration('has a library name that is a Dart reserved word', () { | |
101 d.dir(appPath, [ | |
102 d.libPubspec("test_pkg", "1.0.0"), | |
103 d.dir("lib", [d.file("for.dart", "int i = 0;")]) | |
104 ]).create(); | |
105 expectValidationWarning(name); | |
106 }); | |
107 | |
108 integration('has a single library named differently than the package', () { | |
109 schedule(() => | |
110 deleteEntry(path.join(sandboxDir, appPath, "lib", "test_pkg.dart"))); | |
111 d.dir(appPath, [ | |
112 d.dir("lib", [d.file("best_pkg.dart", "int i = 0;")]) | |
113 ]).create(); | |
114 expectValidationWarning(name); | |
115 }); | |
116 }); | |
117 } | |
OLD | NEW |