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

Side by Side Diff: pkg/http/test/mock_client_test.dart

Issue 11293289: Make the HTTP MockClient work with GET requests. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/http/lib/src/utils.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 mock_client_test; 5 library mock_client_test;
6 6
7 import 'dart:io'; 7 import 'dart:io';
8 import 'dart:json'; 8 import 'dart:json';
9 import 'dart:uri'; 9 import 'dart:uri';
10 10
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 }); 47 });
48 48
49 var uri = new Uri.fromString("http://example.com/foo"); 49 var uri = new Uri.fromString("http://example.com/foo");
50 var request = new http.Request("POST", uri); 50 var request = new http.Request("POST", uri);
51 request.body = "hello, world"; 51 request.body = "hello, world";
52 var future = client.send(request) 52 var future = client.send(request)
53 .chain(http.Response.fromStream) 53 .chain(http.Response.fromStream)
54 .transform((response) => response.body); 54 .transform((response) => response.body);
55 expect(future, completion(equals('Request body was "hello, world"'))); 55 expect(future, completion(equals('Request body was "hello, world"')));
56 }); 56 });
57
58 test('handles a request with no body', () {
59 var client = new MockClient((request) {
60 return new Future.immediate(new http.Response('you did it', 200));
61 });
62
63 expect(client.read("http://example.com/foo"),
64 completion(equals('you did it')));
65 });
57 } 66 }
OLDNEW
« no previous file with comments | « pkg/http/lib/src/utils.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698