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

Unified Diff: test/get/package_name_test.dart

Issue 1493463002: Disallow invalid package names in Pubspec. (Closed) Base URL: git@github.com:dart-lang/pub.git@master
Patch Set: Code review changes Created 5 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 | « lib/src/validator/name.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/get/package_name_test.dart
diff --git a/test/get/package_name_test.dart b/test/get/package_name_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..85955a2c263ae5e52fc4bf0ad6fe147a57c8d9ac
--- /dev/null
+++ b/test/get/package_name_test.dart
@@ -0,0 +1,70 @@
+// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'package:scheduled_test/scheduled_test.dart';
+
+import 'package:pub/src/exit_codes.dart' as exit_codes;
+
+import '../descriptor.dart' as d;
+import '../test_pub.dart';
+
+main() {
+ integration("pub get fails with a non-identifier name", () {
+ d.dir(appPath, [
+ d.pubspec({
+ "name": "invalid package name",
+ "version": "1.0.0"
+ })
+ ]).create();
+
+ pubGet(
+ error: contains('"name" field must be a valid Dart identifier.'),
+ exitCode: exit_codes.DATA);
+
+ d.dir(appPath, [
+ // The lockfile should not be created.
+ d.nothing("pubspec.lock"),
+ // The "packages" directory should not have been generated.
+ d.nothing("packages"),
+ // The ".packages" file should not have been created.
+ d.nothing(".packages"),
+ ]).validate();
+ });
+
+ integration("pub get fails with a reserved word name", () {
+ d.dir(appPath, [
+ d.pubspec({
+ "name": "return",
+ "version": "1.0.0"
+ })
+ ]).create();
+
+ pubGet(
+ error: contains('"name" field may not be a Dart reserved word.'),
+ exitCode: exit_codes.DATA);
+
+ d.dir(appPath, [
+ // The lockfile should not be created.
+ d.nothing("pubspec.lock"),
+ // The "packages" directory should not have been generated.
+ d.nothing("packages"),
+ // The ".packages" file should not have been created.
+ d.nothing(".packages"),
+ ]).validate();
+ });
+
+ integration("pub get allows a name with dotted identifiers", () {
+ d.dir(appPath, [
+ d.pubspec({
+ "name": "foo.bar.baz",
+ "version": "1.0.0"
+ }),
+ d.libDir("foo.bar.baz", "foo.bar.baz 1.0.0")
+ ]).create();
+
+ pubGet();
+
+ d.packagesDir({"foo.bar.baz": "1.0.0"}).validate();
+ });
+}
« no previous file with comments | « lib/src/validator/name.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698