From 3475ea5f0709e8672ea7ad317ac92a55dcc4b37a Mon Sep 17 00:00:00 2001 From: Ryan Lamb <4955475+kinyoklion@users.noreply.github.com> Date: Thu, 7 May 2026 15:14:51 -0700 Subject: [PATCH] feat: add isClosed observer to TestSseClient Lets test code assert that the SUT correctly tears the SSE connection down. Test-only addition; the production SSEClient implementations do not expose this state, and the TestSseClient class is already documented as test-only with no semver guarantee. --- packages/event_source_client/lib/src/test_sse_client.dart | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/event_source_client/lib/src/test_sse_client.dart b/packages/event_source_client/lib/src/test_sse_client.dart index d65df43..c8f497e 100644 --- a/packages/event_source_client/lib/src/test_sse_client.dart +++ b/packages/event_source_client/lib/src/test_sse_client.dart @@ -37,6 +37,12 @@ final class TestSseClient implements SSEClient { bool hasCapability(SSECapability capability) => _capabilities.contains(capability); + /// Whether [close] has been called on this client. Test-only -- + /// production [SSEClient] implementations do not expose this state, + /// and tests asserting against it are inherently white-box. Use to + /// verify that code under test correctly tears the connection down. + bool get isClosed => _messageEventsController.isClosed; + /// Emit an event on the stream. /// Has no effect if the client has been closed. ///