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

Side by Side Diff: sdk/lib/_internal/pub/test/validator/dependency_test.dart

Issue 23596007: Remove usage of dart:json. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebase. Created 7 years, 3 months 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 import 'dart:async'; 5 import 'dart:async';
6 import 'dart:json' as json; 6 import 'dart:convert';
7 7
8 import 'package:http/http.dart' as http; 8 import 'package:http/http.dart' as http;
9 import 'package:http/testing.dart'; 9 import 'package:http/testing.dart';
10 import 'package:path/path.dart' as path; 10 import 'package:path/path.dart' as path;
11 import 'package:scheduled_test/scheduled_test.dart'; 11 import 'package:scheduled_test/scheduled_test.dart';
12 12
13 import '../../lib/src/entrypoint.dart'; 13 import '../../lib/src/entrypoint.dart';
14 import '../../lib/src/validator.dart'; 14 import '../../lib/src/validator.dart';
15 import '../../lib/src/validator/dependency.dart'; 15 import '../../lib/src/validator/dependency.dart';
16 import '../descriptor.dart' as d; 16 import '../descriptor.dart' as d;
(...skipping 16 matching lines...) Expand all
33 /// Sets up a test package with dependency [dep] and mocks a server with 33 /// Sets up a test package with dependency [dep] and mocks a server with
34 /// [hostedVersions] of the package available. 34 /// [hostedVersions] of the package available.
35 setUpDependency(Map dep, {List<String> hostedVersions}) { 35 setUpDependency(Map dep, {List<String> hostedVersions}) {
36 useMockClient(new MockClient((request) { 36 useMockClient(new MockClient((request) {
37 expect(request.method, equals("GET")); 37 expect(request.method, equals("GET"));
38 expect(request.url.path, equals("/api/packages/foo")); 38 expect(request.url.path, equals("/api/packages/foo"));
39 39
40 if (hostedVersions == null) { 40 if (hostedVersions == null) {
41 return new Future.value(new http.Response("not found", 404)); 41 return new Future.value(new http.Response("not found", 404));
42 } else { 42 } else {
43 return new Future.value(new http.Response(json.stringify({ 43 return new Future.value(new http.Response(JSON.encode({
44 "name": "foo", 44 "name": "foo",
45 "uploaders": ["nweiz@google.com"], 45 "uploaders": ["nweiz@google.com"],
46 "versions": hostedVersions.map((version) => 46 "versions": hostedVersions.map((version) =>
47 packageVersionApiMap(packageMap('foo', version))).toList() 47 packageVersionApiMap(packageMap('foo', version))).toList()
48 }), 200)); 48 }), 200));
49 } 49 }
50 })); 50 }));
51 51
52 d.dir(appPath, [ 52 d.dir(appPath, [
53 d.libPubspec("test_pkg", "1.0.0", deps: {"foo": dep}) 53 d.libPubspec("test_pkg", "1.0.0", deps: {"foo": dep})
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 expect(schedulePackageValidation(dependency), completion( 163 expect(schedulePackageValidation(dependency), completion(
164 pairOf(isEmpty, everyElement(isNot(contains("\n foo:")))))); 164 pairOf(isEmpty, everyElement(isNot(contains("\n foo:"))))));
165 }); 165 });
166 166
167 integration("if the lockfile doesn't have an entry for the " 167 integration("if the lockfile doesn't have an entry for the "
168 "dependency", () { 168 "dependency", () {
169 d.dir(appPath, [ 169 d.dir(appPath, [
170 d.libPubspec("test_pkg", "1.0.0", deps: { 170 d.libPubspec("test_pkg", "1.0.0", deps: {
171 "foo": "any" 171 "foo": "any"
172 }), 172 }),
173 d.file("pubspec.lock", json.stringify({ 173 d.file("pubspec.lock", JSON.encode({
174 'packages': { 174 'packages': {
175 'bar': { 175 'bar': {
176 'version': '1.2.3', 176 'version': '1.2.3',
177 'source': 'hosted', 177 'source': 'hosted',
178 'description': { 178 'description': {
179 'name': 'bar', 179 'name': 'bar',
180 'url': 'http://pub.dartlang.org' 180 'url': 'http://pub.dartlang.org'
181 } 181 }
182 } 182 }
183 } 183 }
184 })) 184 }))
185 ]).create(); 185 ]).create();
186 186
187 expect(schedulePackageValidation(dependency), completion( 187 expect(schedulePackageValidation(dependency), completion(
188 pairOf(isEmpty, everyElement(isNot(contains("\n foo:")))))); 188 pairOf(isEmpty, everyElement(isNot(contains("\n foo:"))))));
189 }); 189 });
190 }); 190 });
191 191
192 group('with a lockfile', () { 192 group('with a lockfile', () {
193 integration('and it should suggest a constraint based on the locked ' 193 integration('and it should suggest a constraint based on the locked '
194 'version', () { 194 'version', () {
195 d.dir(appPath, [ 195 d.dir(appPath, [
196 d.libPubspec("test_pkg", "1.0.0", deps: { 196 d.libPubspec("test_pkg", "1.0.0", deps: {
197 "foo": "any" 197 "foo": "any"
198 }), 198 }),
199 d.file("pubspec.lock", json.stringify({ 199 d.file("pubspec.lock", JSON.encode({
200 'packages': { 200 'packages': {
201 'foo': { 201 'foo': {
202 'version': '1.2.3', 202 'version': '1.2.3',
203 'source': 'hosted', 203 'source': 'hosted',
204 'description': { 204 'description': {
205 'name': 'foo', 205 'name': 'foo',
206 'url': 'http://pub.dartlang.org' 206 'url': 'http://pub.dartlang.org'
207 } 207 }
208 } 208 }
209 } 209 }
210 })) 210 }))
211 ]).create(); 211 ]).create();
212 212
213 expectDependencyValidationWarning(' foo: ">=1.2.3 <2.0.0"'); 213 expectDependencyValidationWarning(' foo: ">=1.2.3 <2.0.0"');
214 }); 214 });
215 215
216 integration('and it should suggest a concrete constraint if the locked ' 216 integration('and it should suggest a concrete constraint if the locked '
217 'version is pre-1.0.0', () { 217 'version is pre-1.0.0', () {
218 d.dir(appPath, [ 218 d.dir(appPath, [
219 d.libPubspec("test_pkg", "1.0.0", deps: { 219 d.libPubspec("test_pkg", "1.0.0", deps: {
220 "foo": "any" 220 "foo": "any"
221 }), 221 }),
222 d.file("pubspec.lock", json.stringify({ 222 d.file("pubspec.lock", JSON.encode({
223 'packages': { 223 'packages': {
224 'foo': { 224 'foo': {
225 'version': '0.1.2', 225 'version': '0.1.2',
226 'source': 'hosted', 226 'source': 'hosted',
227 'description': { 227 'description': {
228 'name': 'foo', 228 'name': 'foo',
229 'url': 'http://pub.dartlang.org' 229 'url': 'http://pub.dartlang.org'
230 } 230 }
231 } 231 }
232 } 232 }
233 })) 233 }))
234 ]).create(); 234 ]).create();
235 235
236 expectDependencyValidationWarning(' foo: ">=0.1.2 <0.1.3"'); 236 expectDependencyValidationWarning(' foo: ">=0.1.2 <0.1.3"');
237 }); 237 });
238 }); 238 });
239 }); 239 });
240 }); 240 });
241 } 241 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698