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

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: nits Created 6 years, 8 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
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..f3a49328fe3a0c61bf35d0b2cd72f702379fab4c 100644
--- a/pkg/shelf/test/request_test.dart
+++ b/pkg/shelf/test/request_test.dart
@@ -9,6 +9,7 @@ import 'dart:async';
import 'package:shelf/shelf.dart';
import 'package:unittest/unittest.dart';
+import 'test_change.dart';
import 'test_util.dart';
Request _request([Map<String, String> headers, Stream<List<int>> body]) {
@@ -136,46 +137,42 @@ 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();
- controller.add([104, 101, 108, 108, 111, 44]);
+ 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(HELLO_BYTES);
return new Future(() {
controller
- ..add([32, 119, 111, 114, 108, 100])
+ ..add(WORLD_BYTES)
..close();
});
});
+
+ testChange(({headers, context}) {
nweiz 2014/04/29 19:48:48 Why are these named parameters?
kevmoo 2014/04/30 14:27:52 They align exactly with the shared ctor signature.
+ return new Request('GET', LOCALHOST_URI, headers: headers,
+ context: context);
+ });
});
}

Powered by Google App Engine
This is Rietveld 408576698