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); |
+ }); |
}); |
} |