apiTest<T extends ApiService> method

Future<void> Function() apiTest<T extends ApiService>(
  1. FutureOr<void> body(
    1. RestClient client
    )
)

Implementation

Future<void> Function() apiTest<T extends ApiService>(
    FutureOr<void> Function(RestClient client) body) {
  return test(() async {
    final api = resolve<T>();
    final client = await RestClient.connectHttp2(
      Uri(
        scheme: 'http',
        host: InternetAddress.loopbackIPv4.host,
        port: api.port,
        path: api.basePath,
      ),
    );
    try {
      await body(client);
    } finally {
      await client.close();
    }
  });
}