Chromium Code Reviews| Index: pkg/http/test/client_test.dart |
| diff --git a/pkg/http/test/client_test.dart b/pkg/http/test/client_test.dart |
| index 8286a90271cff639a9471b163420ce588be2bca5..d2f149c6344c8c72e3491f51e5860bf61f495b5a 100644 |
| --- a/pkg/http/test/client_test.dart |
| +++ b/pkg/http/test/client_test.dart |
| @@ -21,26 +21,21 @@ void main() { |
| request.headers[HttpHeaders.CONTENT_TYPE] = |
| 'application/json; charset=utf-8'; |
| - var future = client.send(request).then((response) { |
| + expect(client.send(request).then((response) { |
| expect(response.request, equals(request)); |
| expect(response.statusCode, equals(200)); |
| - return consumeInputStream(response.stream); |
| - }).then(expectAsync1((bytes) => new String.fromCharCodes(bytes))); |
| - future.catchError((_) {}).then((_) => client.close()); |
| - |
| - future.then(expectAsync1((content) { |
| - expect(content, parse(equals({ |
| - 'method': 'POST', |
| - 'path': '/', |
| - 'headers': { |
| - 'content-type': ['application/json; charset=utf-8'], |
| - 'transfer-encoding': ['chunked'] |
| - }, |
| - 'body': '{"hello": "world"}' |
| - }))); |
| - })); |
| - |
| - request.stream.writeString('{"hello": "world"}'); |
| - request.stream.close(); |
| + return response.stream.bytesToString(); |
| + }).whenComplete(client.close), completion(parse(equals({ |
|
Bob Nystrom
2013/01/08 23:50:49
then() has an optional named onError parameter. Us
nweiz
2013/01/09 00:52:11
See previous comment. Also, the semantics of onErr
Bob Nystrom
2013/01/09 03:00:43
Sorry, read this code wrong. You're exactly right.
|
| + 'method': 'POST', |
| + 'path': '/', |
| + 'headers': { |
| + 'content-type': ['application/json; charset=utf-8'], |
| + 'transfer-encoding': ['chunked'] |
| + }, |
| + 'body': '{"hello": "world"}' |
| + })))); |
| + |
| + request.sink.add('{"hello": "world"}'.charCodes); |
| + request.sink.close(); |
| }); |
| } |