Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Unified Diff: pkg/http/test/client_test.dart

Issue 11825010: Update pkg/http to use the new async APIs. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/http/lib/src/utils.dart ('k') | pkg/http/test/http_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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({
+ '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();
});
}
« no previous file with comments | « pkg/http/lib/src/utils.dart ('k') | pkg/http/test/http_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698