OLD | NEW |
| (Empty) |
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 | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
5 library pub_tests; | |
6 | |
7 import 'package:scheduled_test/scheduled_server.dart'; | |
8 import 'package:scheduled_test/scheduled_test.dart'; | |
9 import 'package:shelf/shelf.dart' as shelf; | |
10 | |
11 import '../descriptor.dart' as d; | |
12 import '../test_pub.dart'; | |
13 | |
14 main() { | |
15 initConfig(); | |
16 | |
17 forBothPubGetAndUpgrade((command) { | |
18 integration('sends the correct Accept header', () { | |
19 var server = new ScheduledServer(); | |
20 | |
21 d.appDir({ | |
22 "foo": { | |
23 "hosted": { | |
24 "name": "foo", | |
25 "url": server.url.then((url) => url.toString()) | |
26 } | |
27 } | |
28 }).create(); | |
29 | |
30 var pub = startPub(args: [command.name]); | |
31 | |
32 server.handle('GET', '/api/packages/foo', (request) { | |
33 expect(request.headers['accept'], | |
34 equals('application/vnd.pub.v2+json')); | |
35 return new shelf.Response(200); | |
36 }); | |
37 | |
38 pub.kill(); | |
39 }); | |
40 | |
41 integration('prints a friendly error if the version is out-of-date', () { | |
42 var server = new ScheduledServer(); | |
43 | |
44 d.appDir({ | |
45 "foo": { | |
46 "hosted": { | |
47 "name": "foo", | |
48 "url": server.url.then((url) => url.toString()) | |
49 } | |
50 } | |
51 }).create(); | |
52 | |
53 var pub = startPub(args: [command.name]); | |
54 | |
55 server.handle('GET', '/api/packages/foo', | |
56 (request) => new shelf.Response(406)); | |
57 | |
58 pub.shouldExit(1); | |
59 | |
60 pub.stderr.expect(emitsLines( | |
61 "Pub 0.1.2+3 is incompatible with the current version of localhost.\n" | |
62 "Upgrade pub to the latest version and try again.")); | |
63 }); | |
64 }); | |
65 } | |
OLD | NEW |