OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library pubspec_test; | 5 library pubspec_test; |
6 | 6 |
7 import 'package:unittest/unittest.dart'; | 7 import 'package:unittest/unittest.dart'; |
8 | 8 |
9 import '../lib/src/pubspec.dart'; | 9 import '../lib/src/pubspec.dart'; |
10 import '../lib/src/source.dart'; | 10 import '../lib/src/source.dart'; |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 }); | 93 }); |
94 | 94 |
95 test("allows an empty dev dependencies map", () { | 95 test("allows an empty dev dependencies map", () { |
96 var pubspec = new Pubspec.parse(''' | 96 var pubspec = new Pubspec.parse(''' |
97 dev_dependencies: | 97 dev_dependencies: |
98 ''', sources); | 98 ''', sources); |
99 | 99 |
100 expect(pubspec.devDependencies, isEmpty); | 100 expect(pubspec.devDependencies, isEmpty); |
101 }); | 101 }); |
102 | 102 |
| 103 test("allows a version constraint for dependency overrides", () { |
| 104 var pubspec = new Pubspec.parse(''' |
| 105 dependency_overrides: |
| 106 foo: |
| 107 mock: ok |
| 108 version: ">=1.2.3 <3.4.5" |
| 109 ''', sources); |
| 110 |
| 111 var foo = pubspec.dependencyOverrides[0]; |
| 112 expect(foo.name, equals('foo')); |
| 113 expect(foo.constraint.allows(new Version(1, 2, 3)), isTrue); |
| 114 expect(foo.constraint.allows(new Version(1, 2, 5)), isTrue); |
| 115 expect(foo.constraint.allows(new Version(3, 4, 5)), isFalse); |
| 116 }); |
| 117 |
| 118 test("allows an empty dependency overrides map", () { |
| 119 var pubspec = new Pubspec.parse(''' |
| 120 dependency_overrides: |
| 121 ''', sources); |
| 122 |
| 123 expect(pubspec.dependencyOverrides, isEmpty); |
| 124 }); |
| 125 |
103 test("allows an unknown source", () { | 126 test("allows an unknown source", () { |
104 var pubspec = new Pubspec.parse(''' | 127 var pubspec = new Pubspec.parse(''' |
105 dependencies: | 128 dependencies: |
106 foo: | 129 foo: |
107 unknown: blah | 130 unknown: blah |
108 ''', sources); | 131 ''', sources); |
109 | 132 |
110 var foo = pubspec.dependencies[0]; | 133 var foo = pubspec.dependencies[0]; |
111 expect(foo.name, equals('foo')); | 134 expect(foo.name, equals('foo')); |
112 expect(foo.source, equals('unknown')); | 135 expect(foo.source, equals('unknown')); |
(...skipping 23 matching lines...) Expand all Loading... |
136 | 159 |
137 test("throws if it has a dev dependency on itself", () { | 160 test("throws if it has a dev dependency on itself", () { |
138 expectPubspecException(''' | 161 expectPubspecException(''' |
139 name: myapp | 162 name: myapp |
140 dev_dependencies: | 163 dev_dependencies: |
141 myapp: | 164 myapp: |
142 mock: ok | 165 mock: ok |
143 ''', (pubspec) => pubspec.devDependencies); | 166 ''', (pubspec) => pubspec.devDependencies); |
144 }); | 167 }); |
145 | 168 |
| 169 test("throws if it has an override on itself", () { |
| 170 expectPubspecException(''' |
| 171 name: myapp |
| 172 dependency_overrides: |
| 173 myapp: |
| 174 mock: ok |
| 175 ''', (pubspec) => pubspec.dependencyOverrides); |
| 176 }); |
| 177 |
146 test("throws if the description isn't valid", () { | 178 test("throws if the description isn't valid", () { |
147 expectPubspecException(''' | 179 expectPubspecException(''' |
148 dependencies: | 180 dependencies: |
149 foo: | 181 foo: |
150 mock: bad | 182 mock: bad |
151 ''', (pubspec) => pubspec.dependencies); | 183 ''', (pubspec) => pubspec.dependencies); |
152 }); | 184 }); |
153 | 185 |
154 test("throws if dependency version is not a string", () { | 186 test("throws if dependency version is not a string", () { |
155 expectPubspecException(''' | 187 expectPubspecException(''' |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 (pubspec) => pubspec.environment); | 284 (pubspec) => pubspec.environment); |
253 }); | 285 }); |
254 | 286 |
255 test("throws if the sdk isn't a valid version constraint", () { | 287 test("throws if the sdk isn't a valid version constraint", () { |
256 expectPubspecException('environment: {sdk: "oopies"}', | 288 expectPubspecException('environment: {sdk: "oopies"}', |
257 (pubspec) => pubspec.environment); | 289 (pubspec) => pubspec.environment); |
258 }); | 290 }); |
259 }); | 291 }); |
260 }); | 292 }); |
261 } | 293 } |
OLD | NEW |