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