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