Going
This commit is contained in:
parent
c219b9bcb6
commit
16f0ad0db6
2 changed files with 13 additions and 0 deletions
|
@ -3,6 +3,7 @@ import 'dart:convert';
|
|||
import 'dart:io';
|
||||
import 'package:angel_client/io.dart' as client;
|
||||
import 'package:angel_framework/angel_framework.dart';
|
||||
import 'package:mock_request/mock_request.dart';
|
||||
import 'package:uuid/uuid.dart';
|
||||
|
||||
final Uuid _uuid = new Uuid();
|
||||
|
@ -42,6 +43,17 @@ Future<TestClient> connectTo(Angel app,
|
|||
return client;
|
||||
}
|
||||
|
||||
Future<MockHttpResponse> mock(Angel app, String method, Uri uri,
|
||||
{Iterable<Cookie> cookies: const [],
|
||||
Map<String, dynamic> headers: const {}}) async {
|
||||
var rq = new MockHttpRequest(method, uri);
|
||||
rq.cookies.addAll(cookies ?? []);
|
||||
headers.forEach(rq.headers.add);
|
||||
await rq.close();
|
||||
await app.handleRequest(rq);
|
||||
return rq.response;
|
||||
}
|
||||
|
||||
/// Interacts with an Angel server.
|
||||
class TestClient extends client.Rest {
|
||||
final HttpServer server;
|
||||
|
|
|
@ -8,6 +8,7 @@ dependencies:
|
|||
angel_framework: "^1.0.0-dev"
|
||||
http: "^0.11.3+9"
|
||||
matcher: "^0.12.0+2"
|
||||
mock_request: ^1.0.0
|
||||
uuid: "^0.5.3"
|
||||
dev_dependencies:
|
||||
test: "^0.12.17+2"
|
||||
|
|
Loading…
Reference in a new issue