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

Unified Diff: pkg/shelf/test/request_test.dart

Issue 256753004: pkg/shelf: change helper method on Request and Response (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: nevermind Created 6 years, 7 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/shelf/test/message_test.dart ('k') | pkg/shelf/test/response_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/shelf/test/request_test.dart
diff --git a/pkg/shelf/test/request_test.dart b/pkg/shelf/test/request_test.dart
index 72a87a6b32675f02ea1ae0b32923792a95691bf1..c48a4f73a767810f92fa5924cb46080d990d7a10 100644
--- a/pkg/shelf/test/request_test.dart
+++ b/pkg/shelf/test/request_test.dart
@@ -136,44 +136,35 @@ void main() {
});
});
- group("readAsString", () {
- test("supports a null body", () {
- var request = _request();
- expect(request.readAsString(), completion(equals("")));
- });
-
- test("supports a Stream<List<int>> body", () {
+ group('change', () {
+ test('with no arguments returns instance with equal values', () {
var controller = new StreamController();
- var request = _request({}, controller.stream);
- expect(request.readAsString(), completion(equals("hello, world")));
- controller.add([104, 101, 108, 108, 111, 44]);
- return new Future(() {
- controller
- ..add([32, 119, 111, 114, 108, 100])
- ..close();
- });
- });
- });
+ var uri = Uri.parse('https://test.example.com/static/file.html');
- group("read", () {
- test("supports a null body", () {
- var request = _request();
- expect(request.read().toList(), completion(isEmpty));
- });
+ var request = new Request('GET', uri,
+ protocolVersion: '2.0',
+ headers: {'header1': 'header value 1'},
+ url: Uri.parse('/file.html'),
+ scriptName: '/static',
+ body: controller.stream,
+ context: {'context1': 'context value 1'});
- test("supports a Stream<List<int>> body", () {
- var controller = new StreamController();
- var request = _request({}, controller.stream);
- expect(request.read().toList(), completion(equals([
- [104, 101, 108, 108, 111, 44],
- [32, 119, 111, 114, 108, 100]
- ])));
+ var copy = request.change();
+
+ expect(copy.method, request.method);
+ expect(copy.requestedUri, request.requestedUri);
+ expect(copy.protocolVersion, request.protocolVersion);
+ expect(copy.headers, same(request.headers));
+ expect(copy.url, request.url);
+ expect(copy.scriptName, request.scriptName);
+ expect(copy.context, same(request.context));
+ expect(copy.readAsString(), completion('hello, world'));
- controller.add([104, 101, 108, 108, 111, 44]);
+ controller.add(HELLO_BYTES);
return new Future(() {
controller
- ..add([32, 119, 111, 114, 108, 100])
+ ..add(WORLD_BYTES)
..close();
});
});
« no previous file with comments | « pkg/shelf/test/message_test.dart ('k') | pkg/shelf/test/response_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698