Updated tests to use AngelHttp API

This commit is contained in:
Tobe O 2018-02-06 23:34:08 -05:00
parent 116824e7c5
commit b07e2f0e8a
10 changed files with 76 additions and 47 deletions

View file

@ -8,6 +8,7 @@ export 'package:angel_model/angel_model.dart';
export 'package:angel_route/angel_route.dart'; export 'package:angel_route/angel_route.dart';
export 'package:body_parser/body_parser.dart' show FileUploadInfo; export 'package:body_parser/body_parser.dart' show FileUploadInfo;
export 'angel_base.dart'; export 'angel_base.dart';
export 'angel_http.dart';
export 'anonymous_service.dart'; export 'anonymous_service.dart';
export 'controller.dart'; export 'controller.dart';
export 'hooked_service.dart'; export 'hooked_service.dart';

View file

@ -90,7 +90,8 @@ class Angel extends AngelBase {
/// Use the serving methods in [AngelHttp] instead. /// Use the serving methods in [AngelHttp] instead.
@deprecated @deprecated
ServerGenerator get serverGenerator => _http.serverGenerator; ServerGenerator get serverGenerator =>
(_http ??= new AngelHttp(this)).serverGenerator;
/// Returns the parent instance of this application, if any. /// Returns the parent instance of this application, if any.
Angel get parent => _parent; Angel get parent => _parent;
@ -157,7 +158,7 @@ class Angel extends AngelBase {
/// Use the serving methods in [AngelHttp] instead. /// Use the serving methods in [AngelHttp] instead.
@deprecated @deprecated
HttpServer httpServer; HttpServer get httpServer => _http?.httpServer;
/// Use the serving methods in [AngelHttp] instead. /// Use the serving methods in [AngelHttp] instead.
@deprecated @deprecated
@ -221,8 +222,8 @@ class Angel extends AngelBase {
shutdownHooks.clear(); shutdownHooks.clear();
responseFinalizers.clear(); responseFinalizers.clear();
_flattened = null; _flattened = null;
await _http.close(); await _http?.close();
return _http.httpServer; return _http?.httpServer;
} }
@override @override
@ -321,14 +322,18 @@ class Angel extends AngelBase {
/// Use the serving methods in [AngelHttp] instead. /// Use the serving methods in [AngelHttp] instead.
@deprecated @deprecated
Future<RequestContext> createRequestContext(HttpRequest request) { Future<RequestContext> createRequestContext(HttpRequest request) {
_http ??= new AngelHttp(this);
return _http.createRequestContext(request); return _http.createRequestContext(request);
} }
/// Use the serving methods in [AngelHttp] instead. /// Use the serving methods in [AngelHttp] instead.
@deprecated @deprecated
Future<ResponseContext> createResponseContext(HttpResponse response, Future<ResponseContext> createResponseContext(HttpResponse response,
[RequestContext correspondingRequest]) => [RequestContext correspondingRequest]) {
_http.createResponseContext(response, correspondingRequest); _http ??= new AngelHttp(this);
return _http.createResponseContext(response, correspondingRequest);
}
/// Attempts to find a middleware by the given name within this application. /// Attempts to find a middleware by the given name within this application.
findMiddleware(key) { findMiddleware(key) {
@ -347,6 +352,7 @@ class Angel extends AngelBase {
Future handleAngelHttpException(AngelHttpException e, StackTrace st, Future handleAngelHttpException(AngelHttpException e, StackTrace st,
RequestContext req, ResponseContext res, HttpRequest request, RequestContext req, ResponseContext res, HttpRequest request,
{bool ignoreFinalizers: false}) { {bool ignoreFinalizers: false}) {
_http ??= new AngelHttp(this);
return _http.handleAngelHttpException(e, st, req, res, request, return _http.handleAngelHttpException(e, st, req, res, request,
ignoreFinalizers: ignoreFinalizers == true); ignoreFinalizers: ignoreFinalizers == true);
} }
@ -354,6 +360,7 @@ class Angel extends AngelBase {
/// Use the serving methods in [AngelHttp] instead. /// Use the serving methods in [AngelHttp] instead.
@deprecated @deprecated
Future handleRequest(HttpRequest request) { Future handleRequest(HttpRequest request) {
_http ??= new AngelHttp(this);
return _http.handleRequest(request); return _http.handleRequest(request);
} }
@ -416,6 +423,7 @@ class Angel extends AngelBase {
Future sendResponse( Future sendResponse(
HttpRequest request, RequestContext req, ResponseContext res, HttpRequest request, RequestContext req, ResponseContext res,
{bool ignoreFinalizers: false}) { {bool ignoreFinalizers: false}) {
_http ??= new AngelHttp(this);
return _http.sendResponse(request, req, res); return _http.sendResponse(request, req, res);
} }
@ -501,7 +509,8 @@ class Angel extends AngelBase {
/// Use the serving methods in [AngelHttp] instead. /// Use the serving methods in [AngelHttp] instead.
@deprecated @deprecated
factory Angel.custom(Future<HttpServer> Function(dynamic, int) serverGenerator) { factory Angel.custom(
Future<HttpServer> Function(dynamic, int) serverGenerator) {
var app = new Angel(); var app = new Angel();
return app.._http = new AngelHttp.custom(app, serverGenerator); return app.._http = new AngelHttp.custom(app, serverGenerator);
} }

View file

@ -60,5 +60,6 @@ Future<RequestContext> acceptContentTypes(
rq.headers.set(HttpHeaders.ACCEPT, headerString); rq.headers.set(HttpHeaders.ACCEPT, headerString);
rq.close(); rq.close();
var app = new Angel(); var app = new Angel();
return app.createRequestContext(rq); var http = new AngelHttp(app);
return http.createRequestContext(rq);
} }

View file

@ -29,15 +29,17 @@ main() {
void encodingTests(Angel getApp()) { void encodingTests(Angel getApp()) {
group('encoding', () { group('encoding', () {
Angel app; Angel app;
AngelHttp http;
setUp(() { setUp(() {
app = getApp(); app = getApp();
http = new AngelHttp(app);
}); });
test('sends plaintext if no accept-encoding', () async { test('sends plaintext if no accept-encoding', () async {
var rq = new MockHttpRequest('GET', Uri.parse('/hello'))..close(); var rq = new MockHttpRequest('GET', Uri.parse('/hello'))..close();
var rs = rq.response; var rs = rq.response;
await app.handleRequest(rq); await http.handleRequest(rq);
var body = await rs.transform(UTF8.decoder).join(); var body = await rs.transform(UTF8.decoder).join();
expect(body, 'Hello, world!'); expect(body, 'Hello, world!');
@ -48,7 +50,7 @@ void encodingTests(Angel getApp()) {
..headers.set(HttpHeaders.ACCEPT_ENCODING, '*') ..headers.set(HttpHeaders.ACCEPT_ENCODING, '*')
..close(); ..close();
var rs = rq.response; var rs = rq.response;
await app.handleRequest(rq); await http.handleRequest(rq);
var body = await rs.fold<List<int>>([], (out, list) => []..addAll(list)); var body = await rs.fold<List<int>>([], (out, list) => []..addAll(list));
expect(rs.headers.value(HttpHeaders.CONTENT_ENCODING), 'deflate'); expect(rs.headers.value(HttpHeaders.CONTENT_ENCODING), 'deflate');
@ -60,7 +62,7 @@ void encodingTests(Angel getApp()) {
..headers.set(HttpHeaders.ACCEPT_ENCODING, ['foo', 'bar', '*']) ..headers.set(HttpHeaders.ACCEPT_ENCODING, ['foo', 'bar', '*'])
..close(); ..close();
var rs = rq.response; var rs = rq.response;
await app.handleRequest(rq); await http.handleRequest(rq);
var body = await rs.fold<List<int>>([], (out, list) => []..addAll(list)); var body = await rs.fold<List<int>>([], (out, list) => []..addAll(list));
expect(rs.headers.value(HttpHeaders.CONTENT_ENCODING), 'deflate'); expect(rs.headers.value(HttpHeaders.CONTENT_ENCODING), 'deflate');
@ -72,7 +74,7 @@ void encodingTests(Angel getApp()) {
..headers.set(HttpHeaders.ACCEPT_ENCODING, 'gzip') ..headers.set(HttpHeaders.ACCEPT_ENCODING, 'gzip')
..close(); ..close();
var rs = rq.response; var rs = rq.response;
await app.handleRequest(rq); await http.handleRequest(rq);
var body = await rs.fold<List<int>>([], (out, list) => []..addAll(list)); var body = await rs.fold<List<int>>([], (out, list) => []..addAll(list));
expect(rs.headers.value(HttpHeaders.CONTENT_ENCODING), 'gzip'); expect(rs.headers.value(HttpHeaders.CONTENT_ENCODING), 'gzip');
@ -84,7 +86,7 @@ void encodingTests(Angel getApp()) {
..headers.set(HttpHeaders.ACCEPT_ENCODING, ['gzip', 'deflate']) ..headers.set(HttpHeaders.ACCEPT_ENCODING, ['gzip', 'deflate'])
..close(); ..close();
var rs = rq.response; var rs = rq.response;
await app.handleRequest(rq); await http.handleRequest(rq);
var body = await rs.fold<List<int>>([], (out, list) => []..addAll(list)); var body = await rs.fold<List<int>>([], (out, list) => []..addAll(list));
expect(rs.headers.value(HttpHeaders.CONTENT_ENCODING), 'gzip'); expect(rs.headers.value(HttpHeaders.CONTENT_ENCODING), 'gzip');

View file

@ -25,5 +25,6 @@ main() {
Future<RequestContext> makeRequest(String path) { Future<RequestContext> makeRequest(String path) {
var rq = new MockHttpRequest('GET', ENDPOINT.replace(path: path))..close(); var rq = new MockHttpRequest('GET', ENDPOINT.replace(path: path))..close();
var app = new Angel(); var app = new Angel();
return app.createRequestContext(rq); var http = new AngelHttp(app);
return http.createRequestContext(rq);
} }

View file

@ -17,9 +17,11 @@ Future printResponse(MockHttpResponse rs) {
main() { main() {
Angel app; Angel app;
AngelHttp http;
setUp(() { setUp(() {
app = new Angel()..lazyParseBodies = true; app = new Angel()..lazyParseBodies = true;
http = new AngelHttp(app);
app.get('/cookie', (@CookieValue('token') String jwt) { app.get('/cookie', (@CookieValue('token') String jwt) {
return jwt; return jwt;
@ -61,7 +63,7 @@ main() {
// Invalid request // Invalid request
var rq = new MockHttpRequest('GET', Uri.parse('/header'))..close(); var rq = new MockHttpRequest('GET', Uri.parse('/header'))..close();
var rs = rq.response; var rs = rq.response;
await app.handleRequest(rq); await http.handleRequest(rq);
await printResponse(rs); await printResponse(rs);
expect(rs.statusCode, 400); expect(rs.statusCode, 400);
@ -71,7 +73,7 @@ main() {
..headers.add('x-foo', 'bar') ..headers.add('x-foo', 'bar')
..close(); ..close();
rs = rq.response; rs = rq.response;
await app.handleRequest(rq); await http.handleRequest(rq);
var body = await readResponse(rs); var body = await readResponse(rs);
print('Body: $body'); print('Body: $body');
@ -83,7 +85,7 @@ main() {
// Invalid request // Invalid request
var rq = new MockHttpRequest('GET', Uri.parse('/session'))..close(); var rq = new MockHttpRequest('GET', Uri.parse('/session'))..close();
var rs = rq.response; var rs = rq.response;
await app.handleRequest(rq); await http.handleRequest(rq);
await printResponse(rs); await printResponse(rs);
expect(rs.statusCode, 500); expect(rs.statusCode, 500);
@ -92,7 +94,7 @@ main() {
rq.session['foo'] = 'bar'; rq.session['foo'] = 'bar';
rq.close(); rq.close();
rs = rq.response; rs = rq.response;
await app.handleRequest(rq); await http.handleRequest(rq);
await printResponse(rs); await printResponse(rs);
expect(rs.statusCode, 200); expect(rs.statusCode, 200);
@ -105,7 +107,7 @@ main() {
test('pattern matching', () async { test('pattern matching', () async {
var rq = new MockHttpRequest('GET', Uri.parse('/match?mode=pos'))..close(); var rq = new MockHttpRequest('GET', Uri.parse('/match?mode=pos'))..close();
var rs = rq.response; var rs = rq.response;
await app.handleRequest(rq); await http.handleRequest(rq);
var body = await readResponse(rs); var body = await readResponse(rs);
print('Body: $body'); print('Body: $body');
expect(rs.statusCode, 200); expect(rs.statusCode, 200);
@ -113,7 +115,7 @@ main() {
rq = new MockHttpRequest('GET', Uri.parse('/match?mode=neg'))..close(); rq = new MockHttpRequest('GET', Uri.parse('/match?mode=neg'))..close();
rs = rq.response; rs = rq.response;
await app.handleRequest(rq); await http.handleRequest(rq);
body = await readResponse(rs); body = await readResponse(rs);
print('Body: $body'); print('Body: $body');
expect(rs.statusCode, 200); expect(rs.statusCode, 200);
@ -122,7 +124,7 @@ main() {
// Fallback // Fallback
rq = new MockHttpRequest('GET', Uri.parse('/match?mode=ambi'))..close(); rq = new MockHttpRequest('GET', Uri.parse('/match?mode=ambi'))..close();
rs = rq.response; rs = rq.response;
await app.handleRequest(rq); await http.handleRequest(rq);
body = await readResponse(rs); body = await readResponse(rs);
print('Body: $body'); print('Body: $body');
expect(rs.statusCode, 200); expect(rs.statusCode, 200);

View file

@ -6,9 +6,11 @@ import 'package:test/test.dart';
main() { main() {
Angel app; Angel app;
AngelHttp http;
setUp(() { setUp(() {
app = new Angel()..inject('global', 305); // Pitbull! app = new Angel()..inject('global', 305); // Pitbull!
http = new AngelHttp(app);
app.get('/string/:string', (String string) => string); app.get('/string/:string', (String string) => string);
@ -33,21 +35,21 @@ main() {
test('String type annotation', () async { test('String type annotation', () async {
var rq = new MockHttpRequest('GET', Uri.parse('/string/hello'))..close(); var rq = new MockHttpRequest('GET', Uri.parse('/string/hello'))..close();
await app.handleRequest(rq); await http.handleRequest(rq);
var rs = await rq.response.transform(UTF8.decoder).join(); var rs = await rq.response.transform(UTF8.decoder).join();
expect(rs, JSON.encode('hello')); expect(rs, JSON.encode('hello'));
}); });
test('Primitive after parsed param injection', () async { test('Primitive after parsed param injection', () async {
var rq = new MockHttpRequest('GET', Uri.parse('/num/parsed/24'))..close(); var rq = new MockHttpRequest('GET', Uri.parse('/num/parsed/24'))..close();
await app.handleRequest(rq); await http.handleRequest(rq);
var rs = await rq.response.transform(UTF8.decoder).join(); var rs = await rq.response.transform(UTF8.decoder).join();
expect(rs, JSON.encode(24)); expect(rs, JSON.encode(24));
}); });
test('globally-injected primitive', () async { test('globally-injected primitive', () async {
var rq = new MockHttpRequest('GET', Uri.parse('/num/global'))..close(); var rq = new MockHttpRequest('GET', Uri.parse('/num/global'))..close();
await app.handleRequest(rq); await http.handleRequest(rq);
var rs = await rq.response.transform(UTF8.decoder).join(); var rs = await rq.response.transform(UTF8.decoder).join();
expect(rs, JSON.encode(305)); expect(rs, JSON.encode(305));
}); });
@ -56,8 +58,8 @@ main() {
try { try {
var rq = new MockHttpRequest('GET', Uri.parse('/num/unparsed/32')) var rq = new MockHttpRequest('GET', Uri.parse('/num/unparsed/32'))
..close(); ..close();
var req = await app.createRequestContext(rq); var req = await http.createRequestContext(rq);
var res = await app.createResponseContext(rq.response, req); var res = await http.createResponseContext(rq.response, req);
await app.runContained((num unparsed) => unparsed, req, res); await app.runContained((num unparsed) => unparsed, req, res);
throw new StateError( throw new StateError(
'ArgumentError should be thrown if a parameter cannot be resolved.'); 'ArgumentError should be thrown if a parameter cannot be resolved.');

View file

@ -100,7 +100,7 @@ main() {
}); });
tearDown(() async { tearDown(() async {
await app.httpServer.close(force: true); await app.close();
app = null; app = null;
nested = null; nested = null;
todos = null; todos = null;

View file

@ -29,23 +29,27 @@ main() {
}); });
test('custom server generator', () { test('custom server generator', () {
var app = new Angel.custom(HttpServer.bind); var app = new Angel();
expect(app.serverGenerator, HttpServer.bind); var http = new AngelHttp.custom(app, HttpServer.bind);
expect(http.serverGenerator, HttpServer.bind);
}); });
test('default error handler', () async { test('default error handler', () async {
var app = new Angel(); var app = new Angel();
var http = new AngelHttp(app);
var rq = new MockHttpRequest('GET', $foo); var rq = new MockHttpRequest('GET', $foo);
rq.close(); rq.close();
var rs = rq.response; var rs = rq.response;
var req = await app.createRequestContext(rq); var req = await http.createRequestContext(rq);
var res = await app.createResponseContext(rs); var res = await http.createResponseContext(rs);
var e = new AngelHttpException(null, var e = new AngelHttpException(null,
statusCode: 321, message: 'Hello', errors: ['foo', 'bar']); statusCode: 321, message: 'Hello', errors: ['foo', 'bar']);
await app.errorHandler(e, req, res); await app.errorHandler(e, req, res);
await app.sendResponse(rq, req, res); await http.sendResponse(rq, req, res);
expect(rs.headers.value(HttpHeaders.CONTENT_TYPE), expect(
ContentType.HTML.toString()); ContentType.parse(rs.headers.value(HttpHeaders.CONTENT_TYPE)).mimeType,
ContentType.HTML.mimeType,
);
expect(rs.statusCode, e.statusCode); expect(rs.statusCode, e.statusCode);
var body = await rs.transform(UTF8.decoder).join(); var body = await rs.transform(UTF8.decoder).join();
expect(body, contains('<title>${e.message}</title>')); expect(body, contains('<title>${e.message}</title>'));
@ -81,24 +85,27 @@ main() {
test('global injection added to injection map', () async { test('global injection added to injection map', () async {
var app = new Angel()..inject('a', 'b'); var app = new Angel()..inject('a', 'b');
var http = new AngelHttp(app);
app.get('/', (String a) => a); app.get('/', (String a) => a);
var rq = new MockHttpRequest('GET', Uri.parse('/'))..close(); var rq = new MockHttpRequest('GET', Uri.parse('/'))..close();
await app.handleRequest(rq); await http.handleRequest(rq);
var body = await rq.response.transform(UTF8.decoder).join(); var body = await rq.response.transform(UTF8.decoder).join();
expect(body, JSON.encode('b')); expect(body, JSON.encode('b'));
}); });
test('global injected serializer', () async { test('global injected serializer', () async {
var app = new Angel()..injectSerializer((_) => 'x'); var app = new Angel()..serializer = (_) => 'x';
var http = new AngelHttp(app);
app.get($foo.path, (req, ResponseContext res) => res.serialize(null)); app.get($foo.path, (req, ResponseContext res) => res.serialize(null));
var rq = new MockHttpRequest('GET', $foo)..close(); var rq = new MockHttpRequest('GET', $foo)..close();
await app.handleRequest(rq); await http.handleRequest(rq);
var body = await rq.response.transform(UTF8.decoder).join(); var body = await rq.response.transform(UTF8.decoder).join();
expect(body, 'x'); expect(body, 'x');
}); });
group('handler results', () { group('handler results', () {
var app = new Angel(); var app = new Angel();
var http = new AngelHttp(app);
app.responseFinalizers app.responseFinalizers
.add((req, res) => throw new AngelHttpException.forbidden()); .add((req, res) => throw new AngelHttpException.forbidden());
RequestContext req; RequestContext req;
@ -106,8 +113,8 @@ main() {
setUp(() async { setUp(() async {
var rq = new MockHttpRequest('GET', $foo)..close(); var rq = new MockHttpRequest('GET', $foo)..close();
req = await app.createRequestContext(rq); req = await http.createRequestContext(rq);
res = await app.createResponseContext(rq.response); res = await http.createResponseContext(rq.response);
}); });
group('getHandlerResult', () { group('getHandlerResult', () {
@ -140,12 +147,14 @@ main() {
group('handleAngelHttpException', () { group('handleAngelHttpException', () {
Angel app; Angel app;
AngelHttp http;
setUp(() async { setUp(() async {
app = new Angel(); app = new Angel();
app.get('/wtf', () => throw new AngelHttpException.forbidden()); app.get('/wtf', () => throw new AngelHttpException.forbidden());
app.get('/wtf2', () => throw new AngelHttpException.forbidden()); app.get('/wtf2', () => throw new AngelHttpException.forbidden());
await app.startServer(InternetAddress.LOOPBACK_IP_V4, 0); http = new AngelHttp(app);
await http.startServer(InternetAddress.LOOPBACK_IP_V4, 0);
var oldHandler = app.errorHandler; var oldHandler = app.errorHandler;
app.errorHandler = (e, req, res) { app.errorHandler = (e, req, res) {
@ -161,7 +170,7 @@ main() {
var rq = new MockHttpRequest('GET', new Uri(path: 'wtf')) var rq = new MockHttpRequest('GET', new Uri(path: 'wtf'))
..headers.set(HttpHeaders.ACCEPT, ContentType.JSON.toString()); ..headers.set(HttpHeaders.ACCEPT, ContentType.JSON.toString());
rq.close(); rq.close();
await app.handleRequest(rq); await http.handleRequest(rq);
expect(rq.response.statusCode, HttpStatus.FORBIDDEN); expect(rq.response.statusCode, HttpStatus.FORBIDDEN);
expect( expect(
rq.response.headers.contentType.mimeType, ContentType.JSON.mimeType); rq.response.headers.contentType.mimeType, ContentType.JSON.mimeType);
@ -171,7 +180,7 @@ main() {
var rq = new MockHttpRequest('GET', new Uri(path: 'wtf')) var rq = new MockHttpRequest('GET', new Uri(path: 'wtf'))
..headers.set(HttpHeaders.ACCEPT, ContentType.JSON.toString()); ..headers.set(HttpHeaders.ACCEPT, ContentType.JSON.toString());
rq.close(); rq.close();
await app.handleRequest(rq); await http.handleRequest(rq);
expect(rq.response.statusCode, HttpStatus.FORBIDDEN); expect(rq.response.statusCode, HttpStatus.FORBIDDEN);
expect( expect(
rq.response.headers.contentType.mimeType, ContentType.JSON.mimeType); rq.response.headers.contentType.mimeType, ContentType.JSON.mimeType);
@ -181,7 +190,7 @@ main() {
var rq = new MockHttpRequest('GET', new Uri(path: 'wtf2')); var rq = new MockHttpRequest('GET', new Uri(path: 'wtf2'));
rq.headers.set(HttpHeaders.ACCEPT, ContentType.HTML.toString()); rq.headers.set(HttpHeaders.ACCEPT, ContentType.HTML.toString());
rq.close(); rq.close();
await app.handleRequest(rq); await http.handleRequest(rq);
expect(rq.response.statusCode, HttpStatus.FORBIDDEN); expect(rq.response.statusCode, HttpStatus.FORBIDDEN);
expect( expect(
rq.response.headers.contentType?.mimeType, ContentType.HTML.mimeType); rq.response.headers.contentType?.mimeType, ContentType.HTML.mimeType);

View file

@ -9,9 +9,11 @@ import 'encoders_buffer_test.dart' show encodingTests;
main() { main() {
Angel app; Angel app;
AngelHttp http;
setUp(() { setUp(() {
app = new Angel(); app = new Angel();
http = new AngelHttp(app);
app.logger = new Logger('streaming_test') app.logger = new Logger('streaming_test')
..onRecord.listen((rec) { ..onRecord.listen((rec) {
@ -66,11 +68,11 @@ main() {
}; };
}); });
tearDown(() => app.close()); tearDown(() => http.close());
_expectHelloBye(String path) async { _expectHelloBye(String path) async {
var rq = new MockHttpRequest('GET', Uri.parse(path))..close(); var rq = new MockHttpRequest('GET', Uri.parse(path))..close();
await app.handleRequest(rq); await http.handleRequest(rq);
var body = await rq.response.transform(UTF8.decoder).join(); var body = await rq.response.transform(UTF8.decoder).join();
expect(body, 'Hello, world!bye'); expect(body, 'Hello, world!bye');
} }
@ -81,7 +83,7 @@ main() {
test('cannot write after close', () async { test('cannot write after close', () async {
var rq = new MockHttpRequest('GET', Uri.parse('/overwrite'))..close(); var rq = new MockHttpRequest('GET', Uri.parse('/overwrite'))..close();
await app.handleRequest(rq); await http.handleRequest(rq);
var body = await rq.response.transform(UTF8.decoder).join(); var body = await rq.response.transform(UTF8.decoder).join();
if (rq.response.statusCode != 32) if (rq.response.statusCode != 32)
@ -91,7 +93,7 @@ main() {
test('res => addError', () async { test('res => addError', () async {
try { try {
var rq = new MockHttpRequest('GET', Uri.parse('/error'))..close(); var rq = new MockHttpRequest('GET', Uri.parse('/error'))..close();
await app.handleRequest(rq); await http.handleRequest(rq);
var body = await rq.response.transform(UTF8.decoder).join(); var body = await rq.response.transform(UTF8.decoder).join();
throw 'addError should throw error; response: $body'; throw 'addError should throw error; response: $body';
} on StateError { } on StateError {