diff --git a/.idea/angel_test.iml b/.idea/angel_test.iml
index a928d34a..02bd9dfb 100644
--- a/.idea/angel_test.iml
+++ b/.idea/angel_test.iml
@@ -12,7 +12,7 @@
-
+
\ No newline at end of file
diff --git a/README.md b/README.md
index 7df74ec3..e0b4714c 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,5 @@
# angel_test
-[![version 1.0.5](https://img.shields.io/badge/pub-1.0.5-brightgreen.svg)](https://pub.dartlang.org/packages/angel_test)
+[![version 1.0.5+1](https://img.shields.io/badge/pub-1.0.5+1-brightgreen.svg)](https://pub.dartlang.org/packages/angel_test)
[![build status](https://travis-ci.org/angel-dart/test.svg)](https://travis-ci.org/angel-dart/test)
Testing utility library for the Angel framework.
diff --git a/lib/src/client.dart b/lib/src/client.dart
index cf521aef..7d717140 100644
--- a/lib/src/client.dart
+++ b/lib/src/client.dart
@@ -23,9 +23,15 @@ final Uuid _uuid = new Uuid();
/// Shorthand for bootstrapping a [TestClient].
Future connectTo(Angel app,
- {Map initialSession, bool autoDecodeGzip: true}) async =>
- new TestClient(app, autoDecodeGzip: autoDecodeGzip != false)
- ..session.addAll(initialSession ?? {});
+ {Map initialSession, bool autoDecodeGzip: true}) async {
+ if (!app.isProduction)
+ app.properties.putIfAbsent('testMode', () => true);
+
+ for (var plugin in app.justBeforeStart)
+ await plugin(app);
+ return new TestClient(app, autoDecodeGzip: autoDecodeGzip != false)
+ ..session.addAll(initialSession ?? {});
+}
/// An `angel_client` that sends mock requests to a server, rather than actual HTTP transactions.
class TestClient extends client.BaseAngelClient {
@@ -48,9 +54,7 @@ class TestClient extends client.BaseAngelClient {
TestClient(this.server, {this.autoDecodeGzip: true}) : super(null, '/');
- Future close() async {
- await server.close();
- }
+ Future close() => server.close();
/// Opens a WebSockets connection to the server. This will automatically bind the server
/// over HTTP, if it is not already listening. Unfortunately, WebSockets cannot be mocked (yet!).
@@ -65,13 +69,13 @@ class TestClient extends client.BaseAngelClient {
return ws;
}
- Future sendUnstreamed(
- String method, url, Map headers,
- [body, Encoding encoding]) =>
+ Future sendUnstreamed(String method, url,
+ Map headers,
+ [body, Encoding encoding]) =>
send(method, url, headers, body, encoding).then(http.Response.fromStream);
- Future send(
- String method, url, Map headers,
+ Future send(String method, url,
+ Map headers,
[body, Encoding encoding]) async {
var rq = new MockHttpRequest(
method, url is Uri ? url : Uri.parse(url.toString()));
@@ -80,7 +84,9 @@ class TestClient extends client.BaseAngelClient {
if (authToken?.isNotEmpty == true)
rq.headers.set(HttpHeaders.AUTHORIZATION, 'Bearer $authToken');
- rq..cookies.addAll(cookies)..session.addAll(session);
+ rq
+ ..cookies.addAll(cookies)
+ ..session.addAll(session);
if (body is Stream>) {
await rq.addStream(body);
@@ -96,7 +102,8 @@ class TestClient extends client.BaseAngelClient {
} else if (rq.headers.contentType?.mimeType ==
'application/x-www-form-urlencoded') {
rq.write(body.keys.fold>([],
- (out, k) => out..add('$k=' + Uri.encodeComponent(body[k]))).join());
+ (out, k) => out..add('$k=' + Uri.encodeComponent(body[k])))
+ .join());
} else {
throw new UnsupportedError(
'Map bodies can only be sent for requests with the content type application/json or application/x-www-form-urlencoded.');
@@ -130,9 +137,9 @@ class TestClient extends client.BaseAngelClient {
isRedirect: rs.headers[HttpHeaders.LOCATION] != null,
headers: extractedHeaders,
persistentConnection:
- rq.headers.value(HttpHeaders.CONNECTION)?.toLowerCase()?.trim() ==
- 'keep-alive' ||
- rq.headers.persistentConnection == true,
+ rq.headers.value(HttpHeaders.CONNECTION)?.toLowerCase()?.trim() ==
+ 'keep-alive' ||
+ rq.headers.persistentConnection == true,
reasonPhrase: rs.reasonPhrase);
}
diff --git a/pubspec.yaml b/pubspec.yaml
index 46cf2e5e..fdea1229 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -2,7 +2,7 @@ author: "Tobe O "
description: "Testing utility library for the Angel framework."
homepage: "https://github.com/angel-dart/test.git"
name: "angel_test"
-version: 1.0.5
+version: 1.0.5+1
dependencies:
angel_client: "^1.0.0"
angel_framework: "^1.0.0-dev"