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

Unified Diff: utils/tests/pub/validator_test.dart

Issue 11444018: Add a validator that checks package names. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix tests. Created 8 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « utils/pub/validator/name.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils/tests/pub/validator_test.dart
diff --git a/utils/tests/pub/validator_test.dart b/utils/tests/pub/validator_test.dart
index eaada1a0aae22bb1ff092b9e078b024a9ffc5687..f734c230e5c4857a13254e14b1ab4eca135e4765 100644
--- a/utils/tests/pub/validator_test.dart
+++ b/utils/tests/pub/validator_test.dart
@@ -12,6 +12,7 @@ import '../../../pkg/unittest/lib/unittest.dart';
import '../../pub/entrypoint.dart';
import '../../pub/io.dart';
import '../../pub/validator.dart';
+import '../../pub/validator/name.dart';
import '../../pub/validator/pubspec_field.dart';
void expectNoValidationError(ValidatorCreator fn) {
@@ -29,6 +30,8 @@ void expectValidationWarning(ValidatorCreator fn) {
Validator pubspecField(Entrypoint entrypoint) =>
new PubspecFieldValidator(entrypoint);
+Validator name(Entrypoint entrypoint) => new NameValidator(entrypoint);
+
main() {
group('should consider a package valid if it', () {
test('looks normal', () {
@@ -44,6 +47,18 @@ main() {
expectNoValidationError(pubspecField);
run();
});
+
+ test('has a badly-named library in lib/src', () {
+ dir(appPath, [
+ libPubspec("test_pkg", "1.0.0"),
+ dir("lib", [
+ file("test_pkg.dart", "int i = 1;"),
+ dir("src", [file("8ball.dart", "int j = 2;")])
+ ])
+ ]).scheduleCreate();
+ expectNoValidationError(name);
+ run();
Bob Nystrom 2012/12/07 17:07:43 I like this.
+ });
});
group('should consider a package invalid if it', () {
@@ -110,5 +125,71 @@ main() {
expectValidationWarning(pubspecField);
run();
});
+
+ test('has an empty package name', () {
+ dir(appPath, [libPubspec("", "1.0.0")]).scheduleCreate();
+ expectValidationError(name);
+ run();
+ });
+
+ test('has a package name with an invalid character', () {
+ dir(appPath, [libPubspec("test-pkg", "1.0.0")]).scheduleCreate();
+ expectValidationError(name);
+ run();
+ });
+
+ test('has a package name that begins with a number', () {
+ dir(appPath, [libPubspec("8ball", "1.0.0")]).scheduleCreate();
+ expectValidationError(name);
+ run();
+ });
+
+ test('has a package name that contains upper-case letters', () {
+ dir(appPath, [libPubspec("TestPkg", "1.0.0")]).scheduleCreate();
+ expectValidationWarning(name);
+ run();
+ });
+
+ test('has a package name that is a Dart identifier', () {
+ dir(appPath, [libPubspec("operator", "1.0.0")]).scheduleCreate();
+ expectValidationError(name);
+ run();
+ });
+
+ test('has a library name with an invalid character', () {
+ dir(appPath, [
+ libPubspec("test_pkg", "1.0.0"),
+ dir("lib", [file("test-pkg.dart", "int i = 0;")])
+ ]).scheduleCreate();
+ expectValidationError(name);
+ run();
+ });
+
+ test('has a library name that begins with a number', () {
+ dir(appPath, [
+ libPubspec("test_pkg", "1.0.0"),
+ dir("lib", [file("8ball.dart", "int i = 0;")])
+ ]).scheduleCreate();
+ expectValidationError(name);
+ run();
+ });
+
+ test('has a library name that contains upper-case letters', () {
+ dir(appPath, [
+ libPubspec("test_pkg", "1.0.0"),
+ dir("lib", [file("TestPkg.dart", "int i = 0;")])
+ ]).scheduleCreate();
+ expectValidationWarning(name);
+ run();
+ });
+
+ test('has a library name that is a Dart identifier', () {
+ dir(appPath, [
+ libPubspec("test_pkg", "1.0.0"),
+ dir("lib", [file("operator.dart", "int i = 0;")])
+ ]).scheduleCreate();
+ expectValidationError(name);
+ run();
+ });
});
}
« no previous file with comments | « utils/pub/validator/name.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698