Chromium Code Reviews| 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_lish_test; | 5 library pub_lish_test; |
| 6 | 6 |
| 7 import 'dart:io'; | 7 import 'dart:io'; |
| 8 import 'dart:json'; | 8 import 'dart:json'; |
| 9 | 9 |
| 10 import 'test_pub.dart'; | 10 import 'test_pub.dart'; |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 197 run(); | 197 run(); |
| 198 }); | 198 }); |
| 199 | 199 |
| 200 test('cloud storage upload provides an error', () { | 200 test('cloud storage upload provides an error', () { |
| 201 var server = new ScheduledServer(); | 201 var server = new ScheduledServer(); |
| 202 credentialsFile(server, 'access token').scheduleCreate(); | 202 credentialsFile(server, 'access token').scheduleCreate(); |
| 203 var pub = startPubLish(server); | 203 var pub = startPubLish(server); |
| 204 handleUploadForm(server); | 204 handleUploadForm(server); |
| 205 | 205 |
| 206 server.handle('POST', '/upload', (request, response) { | 206 server.handle('POST', '/upload', (request, response) { |
| 207 response.statusCode = 400; | 207 // TODO(rnystrom): HTTP requires that you don't start sending a response |
|
nweiz
2012/11/30 01:19:45
It's probably worth mentioning that curl will actu
Bob Nystrom
2012/11/30 01:42:45
Done.
| |
| 208 response.headers.contentType = new ContentType('application', 'xml'); | 208 // until the request has been completely sent, but dart:io doesn't |
| 209 response.outputStream.writeString('<Error><Message>Your request sucked.' | 209 // ensure that (#7044). Workaround it by manually consuming the entire |
| 210 '</Message></Error>'); | 210 // input stream before we start responding. |
| 211 return closeHttpResponse(request, response); | 211 return consumeInputStream(request.inputStream).transform((_) { |
| 212 response.statusCode = 400; | |
| 213 response.headers.contentType = new ContentType('application', 'xml'); | |
| 214 response.outputStream.writeString('<Error><Message>Your request sucked.' | |
| 215 '</Message></Error>'); | |
| 216 response.outputStream.close(); | |
| 217 }); | |
| 212 }); | 218 }); |
| 213 | 219 |
| 214 // TODO(nweiz): This should use the server's error message once the client | 220 // TODO(nweiz): This should use the server's error message once the client |
| 215 // can parse the XML. | 221 // can parse the XML. |
| 216 expectLater(pub.nextErrLine(), equals('Failed to upload the package.')); | 222 expectLater(pub.nextErrLine(), equals('Failed to upload the package.')); |
| 217 pub.shouldExit(1); | 223 pub.shouldExit(1); |
| 218 | 224 |
| 219 run(); | 225 run(); |
| 220 }); | 226 }); |
| 221 | 227 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 309 return closeHttpResponse(request, response); | 315 return closeHttpResponse(request, response); |
| 310 }); | 316 }); |
| 311 | 317 |
| 312 expectLater(pub.nextErrLine(), equals('Invalid server response:')); | 318 expectLater(pub.nextErrLine(), equals('Invalid server response:')); |
| 313 expectLater(pub.nextErrLine(), equals(JSON.stringify(body))); | 319 expectLater(pub.nextErrLine(), equals(JSON.stringify(body))); |
| 314 pub.shouldExit(1); | 320 pub.shouldExit(1); |
| 315 | 321 |
| 316 run(); | 322 run(); |
| 317 }); | 323 }); |
| 318 } | 324 } |
| OLD | NEW |