| Index: utils/tests/pub/validator_test.dart
|
| diff --git a/utils/tests/pub/validator_test.dart b/utils/tests/pub/validator_test.dart
|
| index a975c3e85c7c3274cf28c1d4e31bf3bcffbbd949..e5005bfb9627f7dccfef0c127c0cec3cad8b905b 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/license.dart';
|
| import '../../pub/validator/name.dart';
|
| import '../../pub/validator/pubspec_field.dart';
|
|
|
| @@ -30,16 +31,49 @@ void expectValidationWarning(ValidatorCreator fn) {
|
| Validator pubspecField(Entrypoint entrypoint) =>
|
| new PubspecFieldValidator(entrypoint);
|
|
|
| +Validator license(Entrypoint entrypoint) => new LicenseValidator(entrypoint);
|
| +
|
| Validator name(Entrypoint entrypoint) => new NameValidator(entrypoint);
|
|
|
| +void scheduleNormalPackage() {
|
| + dir(appPath, [
|
| + libPubspec("test_pkg", "1.0.0"),
|
| + file("LICENSE", "Eh, do what you want.")
|
| + ]).scheduleCreate();
|
| +}
|
| +
|
| main() {
|
| group('should consider a package valid if it', () {
|
| + setUp(scheduleNormalPackage);
|
| +
|
| test('looks normal', () {
|
| dir(appPath, [libPubspec("test_pkg", "1.0.0")]).scheduleCreate();
|
| + expectNoValidationError(license);
|
| expectNoValidationError(pubspecField);
|
| run();
|
| });
|
|
|
| + test('has a COPYING file', () {
|
| + file(join(appPath, 'LICENSE'), '').scheduleDelete();
|
| + file(join(appPath, 'COPYING'), '').scheduleCreate();
|
| + expectNoValidationError(license);
|
| + run();
|
| + });
|
| +
|
| + test('has a prefixed LICENSE file', () {
|
| + file(join(appPath, 'LICENSE'), '').scheduleDelete();
|
| + file(join(appPath, 'MIT_LICENSE'), '').scheduleCreate();
|
| + expectNoValidationError(license);
|
| + run();
|
| + });
|
| +
|
| + test('has a suffixed LICENSE file', () {
|
| + file(join(appPath, 'LICENSE'), '').scheduleDelete();
|
| + file(join(appPath, 'LICENSE.md'), '').scheduleCreate();
|
| + expectNoValidationError(license);
|
| + run();
|
| + });
|
| +
|
| test('has "authors" instead of "author"', () {
|
| var package = package("test_pkg", "1.0.0");
|
| package["authors"] = [package.remove("author")];
|
| @@ -62,6 +96,8 @@ main() {
|
| });
|
|
|
| group('should consider a package invalid if it', () {
|
| + setUp(scheduleNormalPackage);
|
| +
|
| test('is missing the "homepage" field', () {
|
| var package = package("test_pkg", "1.0.0");
|
| package.remove("homepage");
|
| @@ -135,6 +171,12 @@ main() {
|
| run();
|
| });
|
|
|
| + test('has no LICENSE file', () {
|
| + file(join(appPath, 'LICENSE'), '').scheduleDelete();
|
| + expectValidationError(license);
|
| + run();
|
| + });
|
| +
|
| test('has an empty package name', () {
|
| dir(appPath, [libPubspec("", "1.0.0")]).scheduleCreate();
|
| expectValidationError(name);
|
|
|