Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/src/adapter/io/io_adapter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class IOAdapter extends Adapter {
}

@override
Future<void> close() => _server.close(force: true);
Future<void> close() => _server.close();

@override
ConnectionsInfo get connectionsInfo {
Expand Down
2 changes: 2 additions & 0 deletions lib/src/router/relic_app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ final class RelicApp implements RelicRouter {

Future<void> close() async {
await _reloadSubscription?.cancel();
_reloadSubscription = null;
await _server?.close();
_server = null;
}

Future<void> _init() async {
Expand Down
25 changes: 25 additions & 0 deletions test/router/relic_app_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,31 @@ void main() {
await app.close();
});

test('Given a RelicApp, '
'when calling serve twice, '
'then it fails the second time', () async {
final app =
RelicApp()..any('/', (final ctx) => ctx.respond(Response.ok()));

await app.serve(port: 0);
await expectLater(app.serve(port: 0), throwsStateError);

await app.close();
});

test('Given a RelicApp, '
'when calling serve, close, serve, '
'then it succeeds', () async {
final app =
RelicApp()..any('/', (final ctx) => ctx.respond(Response.ok()));

await app.serve(port: 0);
await app.close();
await expectLater(app.serve(port: 0), completes);

await app.close();
});

test('Given a RelicApp, '
'when hot-reloading isolate, '
'then it is rebuild', () async {
Expand Down
Loading