|
7 | 7 | import static org.junit.jupiter.api.Assertions.assertEquals; |
8 | 8 | import static org.junit.jupiter.api.Assertions.assertFalse; |
9 | 9 | import static org.junit.jupiter.api.Assertions.assertNotNull; |
| 10 | +import static org.junit.jupiter.api.Assertions.assertNull; |
10 | 11 | import static org.junit.jupiter.api.Assertions.assertTrue; |
11 | 12 | import static org.junit.jupiter.api.Assertions.fail; |
12 | 13 |
|
|
19 | 20 |
|
20 | 21 | import org.junit.jupiter.api.AfterAll; |
21 | 22 | import org.junit.jupiter.api.BeforeAll; |
| 23 | +import org.junit.jupiter.api.Disabled; |
22 | 24 | import org.junit.jupiter.api.Test; |
23 | 25 |
|
24 | 26 | import com.github.copilot.sdk.events.AbstractSessionEvent; |
@@ -693,6 +695,48 @@ void testShouldDeleteSession() throws Exception { |
693 | 695 | } |
694 | 696 | } |
695 | 697 |
|
| 698 | + /** |
| 699 | + * Verifies that session metadata can be retrieved by ID. |
| 700 | + * <p> |
| 701 | + * TODO: Re-enable once test harness CAPI proxy supports this test's session |
| 702 | + * lifecycle. |
| 703 | + * |
| 704 | + * @see Snapshot: session/should_get_session_metadata |
| 705 | + */ |
| 706 | + @Disabled("Needs test harness CAPI proxy support") |
| 707 | + @Test |
| 708 | + void testShouldGetSessionMetadata() throws Exception { |
| 709 | + ctx.configureForTest("session", "should_get_session_metadata"); |
| 710 | + |
| 711 | + try (CopilotClient client = ctx.createClient()) { |
| 712 | + CopilotSession session = client |
| 713 | + .createSession(new SessionConfig().setOnPermissionRequest(PermissionHandler.APPROVE_ALL)).get(); |
| 714 | + |
| 715 | + session.sendAndWait(new MessageOptions().setPrompt("Say hello")).get(60, TimeUnit.SECONDS); |
| 716 | + |
| 717 | + // Small delay to ensure session file is written to disk |
| 718 | + Thread.sleep(200); |
| 719 | + |
| 720 | + // Get metadata for the session we just created |
| 721 | + var metadata = client.getSessionMetadata(session.getSessionId()).get(30, TimeUnit.SECONDS); |
| 722 | + assertNotNull(metadata); |
| 723 | + assertEquals(session.getSessionId(), metadata.getSessionId()); |
| 724 | + assertNotNull(metadata.getStartTime()); |
| 725 | + assertNotNull(metadata.getModifiedTime()); |
| 726 | + |
| 727 | + // Verify context field |
| 728 | + if (metadata.getContext() != null) { |
| 729 | + assertNotNull(metadata.getContext().getCwd()); |
| 730 | + } |
| 731 | + |
| 732 | + // Verify non-existent session returns null |
| 733 | + var notFound = client.getSessionMetadata("non-existent-session-id").get(30, TimeUnit.SECONDS); |
| 734 | + assertNull(notFound); |
| 735 | + |
| 736 | + session.close(); |
| 737 | + } |
| 738 | + } |
| 739 | + |
696 | 740 | /** |
697 | 741 | * Verifies that sessions can be created with custom tools. |
698 | 742 | * |
|
0 commit comments