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 pub_tests; | 5 library pub_tests; |
6 | 6 |
7 import 'dart:io'; | 7 import 'dart:io'; |
8 | 8 |
9 import 'package:scheduled_test/scheduled_server.dart'; | 9 import 'package:scheduled_test/scheduled_server.dart'; |
10 import 'package:scheduled_test/scheduled_test.dart'; | 10 import 'package:scheduled_test/scheduled_test.dart'; |
11 | 11 |
12 import '../descriptor.dart' as d; | 12 import '../descriptor.dart' as d; |
13 import '../test_pub.dart'; | 13 import '../test_pub.dart'; |
14 | 14 |
15 main() { | 15 main() { |
16 initConfig(); | 16 initConfig(); |
17 | 17 |
18 forBothPubInstallAndUpdate((command) { | 18 forBothPubInstallAndUpdate((command) { |
19 integration('sends the correct Accept header', () { | 19 integration('sends the correct Accept header', () { |
20 var server = new ScheduledServer(); | 20 var server = new ScheduledServer(); |
21 | 21 |
22 d.appDir([{ | 22 d.appDir({ |
23 "hosted": { | 23 "foo": { |
24 "name": "foo", | 24 "hosted": { |
25 "url": server.url.then((url) => url.toString()) | 25 "name": "foo", |
| 26 "url": server.url.then((url) => url.toString()) |
| 27 } |
26 } | 28 } |
27 }]).create(); | 29 }).create(); |
28 | 30 |
29 var pub = startPub(args: [command.name]); | 31 var pub = startPub(args: [command.name]); |
30 | 32 |
31 server.handle('GET', '/api/packages/foo', (request) { | 33 server.handle('GET', '/api/packages/foo', (request) { |
32 expect(request.headers['Accept'], ['application/vnd.pub.v2+json']); | 34 expect(request.headers['Accept'], ['application/vnd.pub.v2+json']); |
33 }); | 35 }); |
34 | 36 |
35 pub.kill(); | 37 pub.kill(); |
36 }); | 38 }); |
37 | 39 |
38 integration('prints a friendly error if the version is out-of-date', () { | 40 integration('prints a friendly error if the version is out-of-date', () { |
39 var server = new ScheduledServer(); | 41 var server = new ScheduledServer(); |
40 | 42 |
41 d.appDir([{ | 43 d.appDir({ |
42 "hosted": { | 44 "foo": { |
43 "name": "foo", | 45 "hosted": { |
44 "url": server.url.then((url) => url.toString()) | 46 "name": "foo", |
| 47 "url": server.url.then((url) => url.toString()) |
| 48 } |
45 } | 49 } |
46 }]).create(); | 50 }).create(); |
47 | 51 |
48 var pub = startPub(args: [command.name]); | 52 var pub = startPub(args: [command.name]); |
49 | 53 |
50 server.handle('GET', '/api/packages/foo', (request) { | 54 server.handle('GET', '/api/packages/foo', (request) { |
51 request.response.statusCode = 406; | 55 request.response.statusCode = 406; |
52 request.response.close(); | 56 request.response.close(); |
53 }); | 57 }); |
54 | 58 |
55 // TODO(nweiz): this shouldn't request the versions twice (issue 11077). | 59 // TODO(nweiz): this shouldn't request the versions twice (issue 11077). |
56 server.handle('GET', '/api/packages/foo', (request) { | 60 server.handle('GET', '/api/packages/foo', (request) { |
57 request.response.statusCode = 406; | 61 request.response.statusCode = 406; |
58 request.response.close(); | 62 request.response.close(); |
59 }); | 63 }); |
60 | 64 |
61 pub.shouldExit(1); | 65 pub.shouldExit(1); |
62 | 66 |
63 expect(pub.remainingStderr(), completion(equals( | 67 expect(pub.remainingStderr(), completion(equals( |
64 "Pub 0.1.2+3 is incompatible with the current version of localhost.\n" | 68 "Pub 0.1.2+3 is incompatible with the current version of localhost.\n" |
65 "Upgrade pub to the latest version and try again."))); | 69 "Upgrade pub to the latest version and try again."))); |
66 }); | 70 }); |
67 }); | 71 }); |
68 } | 72 } |
OLD | NEW |