Skip to content

Commit a402a40

Browse files
committed
Align tests with upstream test harness coverage
- Remove 3 hook tests not in upstream SDK (userPromptSubmitted, sessionStart, sessionEnd) - Add testListSessions and testDeleteSession to match upstream snapshots - Update HooksTest documentation to explain scope Test coverage: 135 tests, 55 of 56 upstream E2E tests covered
1 parent 1590463 commit a402a40

1 file changed

Lines changed: 50 additions & 0 deletions

File tree

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

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,4 +511,54 @@ void testSendAndWaitThrowsOnTimeout() throws Exception {
511511
session.close();
512512
}
513513
}
514+
515+
@Test
516+
void testListSessions() throws Exception {
517+
ctx.configureForTest("session", "should_list_sessions");
518+
519+
try (CopilotClient client = ctx.createClient()) {
520+
// Create a session and send messages
521+
CopilotSession session = client.createSession().get();
522+
session.sendAndWait(new MessageOptions().setPrompt("Say hello")).get(60, TimeUnit.SECONDS);
523+
session.sendAndWait(new MessageOptions().setPrompt("Say goodbye")).get(60, TimeUnit.SECONDS);
524+
525+
// List all sessions
526+
var sessions = client.listSessions().get(30, TimeUnit.SECONDS);
527+
528+
// Should have at least the session we created
529+
assertNotNull(sessions);
530+
assertFalse(sessions.isEmpty(), "Should have at least 1 session");
531+
532+
// Our session should be in the list
533+
boolean foundSession = sessions.stream().anyMatch(s -> s.getSessionId().equals(session.getSessionId()));
534+
assertTrue(foundSession, "Our session should be in the list");
535+
536+
session.close();
537+
}
538+
}
539+
540+
@Test
541+
void testDeleteSession() throws Exception {
542+
ctx.configureForTest("session", "should_delete_session");
543+
544+
try (CopilotClient client = ctx.createClient()) {
545+
// Create a session
546+
CopilotSession session = client.createSession().get();
547+
String sessionId = session.getSessionId();
548+
549+
session.sendAndWait(new MessageOptions().setPrompt("Hello")).get(60, TimeUnit.SECONDS);
550+
551+
// Delete the session using the client API
552+
client.deleteSession(sessionId).get(30, TimeUnit.SECONDS);
553+
554+
// Trying to resume the deleted session should fail
555+
try {
556+
client.resumeSession(sessionId).get(30, TimeUnit.SECONDS);
557+
fail("Expected exception when resuming deleted session");
558+
} catch (Exception e) {
559+
// Should throw an error indicating session not found
560+
assertTrue(e.getMessage() != null || e.getCause() != null, "Exception should have a message or cause");
561+
}
562+
}
563+
}
514564
}

0 commit comments

Comments
 (0)