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_uploader_test; | 5 library pub_uploader_test; |
6 | 6 |
7 import 'dart:io'; | 7 import 'dart:io'; |
8 import 'dart:json' as json; | 8 import 'dart:json' as json; |
9 | 9 |
10 import 'test_pub.dart'; | 10 import 'test_pub.dart'; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 output: USAGE_STRING, exitCode: 64); | 47 output: USAGE_STRING, exitCode: 64); |
48 }); | 48 }); |
49 }); | 49 }); |
50 | 50 |
51 integration('adds an uploader', () { | 51 integration('adds an uploader', () { |
52 var server = new ScheduledServer(); | 52 var server = new ScheduledServer(); |
53 credentialsFile(server, 'access token').scheduleCreate(); | 53 credentialsFile(server, 'access token').scheduleCreate(); |
54 var pub = startPubUploader(server, ['--package', 'pkg', 'add', 'email']); | 54 var pub = startPubUploader(server, ['--package', 'pkg', 'add', 'email']); |
55 | 55 |
56 server.handle('POST', '/packages/pkg/uploaders.json', (request, response) { | 56 server.handle('POST', '/packages/pkg/uploaders.json', (request, response) { |
57 expect(wrapInputStream(request.inputStream).toBytes().then((bodyBytes) { | 57 expect(consumeInputStream(request.inputStream).then((bodyBytes) { |
58 expect(new String.fromCharCodes(bodyBytes), equals('email=email')); | 58 expect(new String.fromCharCodes(bodyBytes), equals('email=email')); |
59 | 59 |
60 response.headers.contentType = new ContentType("application", "json"); | 60 response.headers.contentType = new ContentType("application", "json"); |
61 response.outputStream.writeString(json.stringify({ | 61 response.outputStream.writeString(json.stringify({ |
62 'success': {'message': 'Good job!'} | 62 'success': {'message': 'Good job!'} |
63 })); | 63 })); |
64 response.outputStream.close(); | 64 response.outputStream.close(); |
65 }), completes); | 65 }), completes); |
66 }); | 66 }); |
67 | 67 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 (request, response) { | 169 (request, response) { |
170 response.outputStream.writeString("{not json"); | 170 response.outputStream.writeString("{not json"); |
171 response.outputStream.close(); | 171 response.outputStream.close(); |
172 }); | 172 }); |
173 | 173 |
174 expectLater(pub.nextErrLine(), equals('Invalid server response:')); | 174 expectLater(pub.nextErrLine(), equals('Invalid server response:')); |
175 expectLater(pub.nextErrLine(), equals('{not json')); | 175 expectLater(pub.nextErrLine(), equals('{not json')); |
176 pub.shouldExit(1); | 176 pub.shouldExit(1); |
177 }); | 177 }); |
178 } | 178 } |
OLD | NEW |