| 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( | |
| 34 request.headers['accept'], | |
| 35 equals('application/vnd.pub.v2+json')); | |
| 36 return new shelf.Response(200); | |
| 37 }); | |
| 38 | |
| 39 pub.kill(); | |
| 40 }); | |
| 41 | |
| 42 integration('prints a friendly error if the version is out-of-date', () { | |
| 43 var server = new ScheduledServer(); | |
| 44 | |
| 45 d.appDir({ | |
| 46 "foo": { | |
| 47 "hosted": { | |
| 48 "name": "foo", | |
| 49 "url": server.url.then((url) => url.toString()) | |
| 50 } | |
| 51 } | |
| 52 }).create(); | |
| 53 | |
| 54 var pub = startPub(args: [command.name]); | |
| 55 | |
| 56 server.handle( | |
| 57 'GET', | |
| 58 '/api/packages/foo', | |
| 59 (request) => new shelf.Response(406)); | |
| 60 | |
| 61 pub.shouldExit(1); | |
| 62 | |
| 63 pub.stderr.expect( | |
| 64 emitsLines( | |
| 65 "Pub 0.1.2+3 is incompatible with the current version of localhost
.\n" | |
| 66 "Upgrade pub to the latest version and try again.")); | |
| 67 }); | |
| 68 }); | |
| 69 } | |
| OLD | NEW |