Skip to content

Commit 1796f4c

Browse files
Copilotbrunoborges
andcommitted
Add test for closing session after client stops
Co-authored-by: brunoborges <129743+brunoborges@users.noreply.github.com>
1 parent e27f282 commit 1796f4c

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

src/test/java/com/github/copilot/sdk/CopilotClientTest.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,28 @@ void testForceStopWithNoConnectionCompletes() throws Exception {
424424
}
425425
}
426426

427+
@Test
428+
void testCloseSessionAfterStoppingClientDoesNotThrow() throws Exception {
429+
if (cliPath == null) {
430+
System.out.println("Skipping test: CLI not found");
431+
return;
432+
}
433+
434+
try (var client = new CopilotClient(new CopilotClientOptions().setCliPath(cliPath))) {
435+
var session = client.createSession().get();
436+
437+
// Stop the client first (which closes the RPC connection)
438+
client.stop().get();
439+
440+
// Then close the session - should not throw even though RPC is closed
441+
assertDoesNotThrow(() -> session.close(), "Closing session after client.stop() should not throw exception");
442+
443+
// Verify session is terminated
444+
assertThrows(IllegalStateException.class, () -> session.send("test"),
445+
"Session should be terminated after close()");
446+
}
447+
}
448+
427449
// ===== start() idempotency =====
428450

429451
@Test

0 commit comments

Comments
 (0)