Index: utils/tests/pub/pubspec_test.dart |
diff --git a/utils/tests/pub/pubspec_test.dart b/utils/tests/pub/pubspec_test.dart |
index 9813cf52c8bafcd76fe45ed7a357f68caf30da50..8b40664e2cceae798febfba511b0c73ee3ee7a35 100644 |
--- a/utils/tests/pub/pubspec_test.dart |
+++ b/utils/tests/pub/pubspec_test.dart |
@@ -25,154 +25,186 @@ class MockSource extends Source { |
main() { |
initConfig(); |
- group('Pubspec', () { |
- group('parse()', () { |
- var sources = new SourceRegistry(); |
- sources.register(new MockSource()); |
+ group('parse()', () { |
+ var sources = new SourceRegistry(); |
+ sources.register(new MockSource()); |
- expectFormatError(String pubspec) { |
- expect(() => new Pubspec.parse(null, pubspec, sources), |
- throwsFormatException); |
- } |
+ expectFormatError(String pubspec) { |
+ expect(() => new Pubspec.parse(null, pubspec, sources), |
+ throwsFormatException); |
+ } |
- test("allows a version constraint for dependencies", () { |
- var pubspec = new Pubspec.parse(null, ''' |
+ test("allows a version constraint for dependencies", () { |
+ var pubspec = new Pubspec.parse(null, ''' |
dependencies: |
foo: |
mock: ok |
version: ">=1.2.3 <3.4.5" |
''', sources); |
- var foo = pubspec.dependencies[0]; |
- expect(foo.name, equals('foo')); |
- expect(foo.constraint.allows(new Version(1, 2, 3)), isTrue); |
- expect(foo.constraint.allows(new Version(1, 2, 5)), isTrue); |
- expect(foo.constraint.allows(new Version(3, 4, 5)), isFalse); |
- }); |
+ var foo = pubspec.dependencies[0]; |
+ expect(foo.name, equals('foo')); |
+ expect(foo.constraint.allows(new Version(1, 2, 3)), isTrue); |
+ expect(foo.constraint.allows(new Version(1, 2, 5)), isTrue); |
+ expect(foo.constraint.allows(new Version(3, 4, 5)), isFalse); |
+ }); |
- test("allows an empty dependencies map", () { |
- var pubspec = new Pubspec.parse(null, ''' |
+ test("allows an empty dependencies map", () { |
+ var pubspec = new Pubspec.parse(null, ''' |
dependencies: |
''', sources); |
- expect(pubspec.dependencies, isEmpty); |
- }); |
+ expect(pubspec.dependencies, isEmpty); |
+ }); |
- test("throws if the description isn't valid", () { |
- expectFormatError(''' |
+ test("allows a version constraint for dev dependencies", () { |
+ var pubspec = new Pubspec.parse(null, ''' |
+dev_dependencies: |
+ foo: |
+ mock: ok |
+ version: ">=1.2.3 <3.4.5" |
+''', sources); |
+ |
+ var foo = pubspec.devDependencies[0]; |
+ expect(foo.name, equals('foo')); |
+ expect(foo.constraint.allows(new Version(1, 2, 3)), isTrue); |
+ expect(foo.constraint.allows(new Version(1, 2, 5)), isTrue); |
+ expect(foo.constraint.allows(new Version(3, 4, 5)), isFalse); |
+ }); |
+ |
+ test("allows an empty dev dependencies map", () { |
+ var pubspec = new Pubspec.parse(null, ''' |
+dev_dependencies: |
+''', sources); |
+ |
+ expect(pubspec.devDependencies, isEmpty); |
+ }); |
+ |
+ test("throws if a package is in dependencies and dev_dependencies", () { |
+ expectFormatError(''' |
+dependencies: |
+ foo: |
+ mock: ok |
+dev_dependencies: |
+ foo: |
+ mock: ok |
+'''); |
+ }); |
+ |
+ test("throws if the description isn't valid", () { |
+ expectFormatError(''' |
dependencies: |
foo: |
mock: bad |
'''); |
- }); |
+ }); |
- test("throws if 'name' is not a string", () { |
- expectFormatError('name: [not, a, string]'); |
- }); |
+ test("throws if 'name' is not a string", () { |
+ expectFormatError('name: [not, a, string]'); |
+ }); |
- test("throws if 'homepage' is not a string", () { |
- expectFormatError('homepage:'); |
- expectFormatError('homepage: [not, a, string]'); |
- }); |
+ test("throws if 'homepage' is not a string", () { |
+ expectFormatError('homepage:'); |
+ expectFormatError('homepage: [not, a, string]'); |
+ }); |
- test("throws if 'homepage' doesn't have an HTTP scheme", () { |
- new Pubspec.parse(null, 'homepage: http://ok.com', sources); |
- new Pubspec.parse(null, 'homepage: https://also-ok.com', sources); |
+ test("throws if 'homepage' doesn't have an HTTP scheme", () { |
+ new Pubspec.parse(null, 'homepage: http://ok.com', sources); |
+ new Pubspec.parse(null, 'homepage: https://also-ok.com', sources); |
- expectFormatError('homepage: ftp://badscheme.com'); |
- expectFormatError('homepage: javascript:alert("!!!")'); |
- expectFormatError('homepage: data:image/png;base64,somedata'); |
- expectFormatError('homepage: no-scheme.com'); |
- }); |
+ expectFormatError('homepage: ftp://badscheme.com'); |
+ expectFormatError('homepage: javascript:alert("!!!")'); |
+ expectFormatError('homepage: data:image/png;base64,somedata'); |
+ expectFormatError('homepage: no-scheme.com'); |
+ }); |
- test("throws if 'documentation' is not a string", () { |
- expectFormatError('documentation:'); |
- expectFormatError('documentation: [not, a, string]'); |
- }); |
+ test("throws if 'documentation' is not a string", () { |
+ expectFormatError('documentation:'); |
+ expectFormatError('documentation: [not, a, string]'); |
+ }); |
- test("throws if 'documentation' doesn't have an HTTP scheme", () { |
- new Pubspec.parse(null, 'documentation: http://ok.com', sources); |
- new Pubspec.parse(null, 'documentation: https://also-ok.com', sources); |
+ test("throws if 'documentation' doesn't have an HTTP scheme", () { |
+ new Pubspec.parse(null, 'documentation: http://ok.com', sources); |
+ new Pubspec.parse(null, 'documentation: https://also-ok.com', sources); |
- expectFormatError('documentation: ftp://badscheme.com'); |
- expectFormatError('documentation: javascript:alert("!!!")'); |
- expectFormatError('documentation: data:image/png;base64,somedata'); |
- expectFormatError('documentation: no-scheme.com'); |
- }); |
+ expectFormatError('documentation: ftp://badscheme.com'); |
+ expectFormatError('documentation: javascript:alert("!!!")'); |
+ expectFormatError('documentation: data:image/png;base64,somedata'); |
+ expectFormatError('documentation: no-scheme.com'); |
+ }); |
- test("throws if 'authors' is not a string or a list of strings", () { |
- new Pubspec.parse(null, 'authors: ok fine', sources); |
- new Pubspec.parse(null, 'authors: [also, ok, fine]', sources); |
+ test("throws if 'authors' is not a string or a list of strings", () { |
+ new Pubspec.parse(null, 'authors: ok fine', sources); |
+ new Pubspec.parse(null, 'authors: [also, ok, fine]', sources); |
- expectFormatError('authors: 123'); |
- expectFormatError('authors: {not: {a: string}}'); |
- expectFormatError('authors: [ok, {not: ok}]'); |
- }); |
+ expectFormatError('authors: 123'); |
+ expectFormatError('authors: {not: {a: string}}'); |
+ expectFormatError('authors: [ok, {not: ok}]'); |
+ }); |
- test("throws if 'author' is not a string", () { |
- new Pubspec.parse(null, 'author: ok fine', sources); |
+ test("throws if 'author' is not a string", () { |
+ new Pubspec.parse(null, 'author: ok fine', sources); |
- expectFormatError('author: 123'); |
- expectFormatError('author: {not: {a: string}}'); |
- expectFormatError('author: [not, ok]'); |
- }); |
+ expectFormatError('author: 123'); |
+ expectFormatError('author: {not: {a: string}}'); |
+ expectFormatError('author: [not, ok]'); |
+ }); |
- test("throws if both 'author' and 'authors' are present", () { |
- expectFormatError('{author: abe, authors: ted}'); |
- }); |
+ test("throws if both 'author' and 'authors' are present", () { |
+ expectFormatError('{author: abe, authors: ted}'); |
+ }); |
- test("allows comment-only files", () { |
- var pubspec = new Pubspec.parse(null, ''' |
+ test("allows comment-only files", () { |
+ var pubspec = new Pubspec.parse(null, ''' |
# No external dependencies yet |
# Including for completeness |
# ...and hoping the spec expands to include details about author, version, etc |
# See http://www.dartlang.org/docs/pub-package-manager/ for details |
''', sources); |
- expect(pubspec.version, equals(Version.none)); |
- expect(pubspec.dependencies, isEmpty); |
- }); |
+ expect(pubspec.version, equals(Version.none)); |
+ expect(pubspec.dependencies, isEmpty); |
+ }); |
- group("environment", () { |
- test("defaults to any SDK constraint if environment is omitted", () { |
- var pubspec = new Pubspec.parse(null, '', sources); |
- expect(pubspec.environment.sdkVersion, equals(VersionConstraint.any)); |
- }); |
+ group("environment", () { |
+ test("defaults to any SDK constraint if environment is omitted", () { |
+ var pubspec = new Pubspec.parse(null, '', sources); |
+ expect(pubspec.environment.sdkVersion, equals(VersionConstraint.any)); |
+ }); |
- test("allows an empty environment map", () { |
- var pubspec = new Pubspec.parse(null, ''' |
+ test("allows an empty environment map", () { |
+ var pubspec = new Pubspec.parse(null, ''' |
environment: |
''', sources); |
- expect(pubspec.environment.sdkVersion, equals(VersionConstraint.any)); |
- }); |
+ expect(pubspec.environment.sdkVersion, equals(VersionConstraint.any)); |
+ }); |
- test("throws if the environment value isn't a map", () { |
- expectFormatError(''' |
+ test("throws if the environment value isn't a map", () { |
+ expectFormatError(''' |
environment: [] |
'''); |
- }); |
+ }); |
- test("allows a version constraint for the sdk", () { |
- var pubspec = new Pubspec.parse(null, ''' |
+ test("allows a version constraint for the sdk", () { |
+ var pubspec = new Pubspec.parse(null, ''' |
environment: |
sdk: ">=1.2.3 <2.3.4" |
''', sources); |
- expect(pubspec.environment.sdkVersion, |
- equals(new VersionConstraint.parse(">=1.2.3 <2.3.4"))); |
- }); |
+ expect(pubspec.environment.sdkVersion, |
+ equals(new VersionConstraint.parse(">=1.2.3 <2.3.4"))); |
+ }); |
- test("throws if the sdk isn't a string", () { |
- expectFormatError(''' |
+ test("throws if the sdk isn't a string", () { |
+ expectFormatError(''' |
environment: |
sdk: [] |
'''); |
- }); |
+ }); |
- test("throws if the sdk isn't a valid version constraint", () { |
- expectFormatError(''' |
+ test("throws if the sdk isn't a valid version constraint", () { |
+ expectFormatError(''' |
environment: |
sdk: "oopies" |
'''); |
- }); |
}); |
}); |
}); |