From 43bc0e19635c9ef3dfb99903917fb2dcb96a8626 Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Sat, 28 Sep 2024 13:52:48 +0200 Subject: [PATCH] chore: tear down clients in event tests properly Fixes some noise around logs when I was trying to enable branch coverage. --- test/event_test.dart | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/event_test.dart b/test/event_test.dart index 748e3c6c..c55f3d3e 100644 --- a/test/event_test.dart +++ b/test/event_test.dart @@ -56,6 +56,8 @@ void main() { final event = Event.fromJson( jsonObj, Room(id: '!testroom:example.abc', client: client)); + tearDownAll(() async => client.dispose()); + test('Create from json', () async { jsonObj['content'] = json.decode(contentJson); expect(event.toJson(), jsonObj); @@ -237,6 +239,8 @@ void main() { expect(event.content.isEmpty, true); redactionEventJson.remove('redacts'); expect(event.unsigned?['redacted_because'], redactionEventJson); + + await client.dispose(); } }); @@ -248,6 +252,8 @@ void main() { expect(() async => await event.cancelSend(), throwsException); event.status = EventStatus.sending; await event.cancelSend(); + + await room.client.dispose(); }); test('sendAgain', () async { @@ -327,6 +333,8 @@ void main() { ), ); expect(event.canRedact, true); + + await client.dispose(); }); test('getLocalizedBody, isEventKnown', () async { final matrix = Client('testclient', httpClient: FakeMatrixApi()); @@ -961,6 +969,8 @@ void main() { expect(await event.calcLocalizedBody(MatrixDefaultLocalizations()), 'Unknown event unknown.event.type'); expect(event.isEventTypeKnown, false); + + await matrix.dispose(closeDatabase: true); }); test('getLocalizedBody, parameters', () async { @@ -1126,6 +1136,8 @@ void main() { await event.calcLocalizedBody(MatrixDefaultLocalizations()), 'Example accepted key verification request', ); + + await matrix.dispose(closeDatabase: true); }); test('aggregations', () {