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

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

Issue 11474047: Validate that an uploaded package has a LICENSE file. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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
« utils/pub/validator/license.dart ('K') | « utils/tests/pub/pub_lish_test.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 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);
« utils/pub/validator/license.dart ('K') | « utils/tests/pub/pub_lish_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698