Skip to content

Commit 26a732f

Browse files
committed
add tests
1 parent 77cab7a commit 26a732f

File tree

5 files changed

+84
-0
lines changed

5 files changed

+84
-0
lines changed

dotnet/test/SessionTests.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,4 +322,19 @@ public async Task Should_Receive_Session_Events()
322322

323323
await session.DisposeAsync();
324324
}
325+
326+
[Fact]
327+
public async Task Should_Create_Session_With_Custom_Config_Dir()
328+
{
329+
var customConfigDir = Path.Combine(Ctx.HomeDir, "custom-config");
330+
var session = await Client.CreateSessionAsync(new SessionConfig { ConfigDir = customConfigDir });
331+
332+
Assert.Matches(@"^[a-f0-9-]+$", session.SessionId);
333+
334+
// Session should work normally with custom config dir
335+
await session.SendAsync(new MessageOptions { Prompt = "What is 1+1?" });
336+
var assistantMessage = await TestHelper.GetFinalAssistantMessageAsync(session);
337+
Assert.NotNull(assistantMessage);
338+
Assert.Contains("2", assistantMessage!.Data.Content);
339+
}
325340
}

go/e2e/session_test.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,38 @@ func TestSession(t *testing.T) {
687687
t.Errorf("Expected assistant message to contain '300', got %v", assistantMessage.Data.Content)
688688
}
689689
})
690+
691+
t.Run("should create session with custom config dir", func(t *testing.T) {
692+
ctx.ConfigureForTest(t)
693+
694+
customConfigDir := ctx.HomeDir + "/custom-config"
695+
session, err := client.CreateSession(&copilot.SessionConfig{
696+
ConfigDir: customConfigDir,
697+
})
698+
if err != nil {
699+
t.Fatalf("Failed to create session with custom config dir: %v", err)
700+
}
701+
702+
matched, _ := regexp.MatchString(`^[a-f0-9-]+$`, session.SessionID)
703+
if !matched {
704+
t.Errorf("Expected session ID to match UUID pattern, got %q", session.SessionID)
705+
}
706+
707+
// Session should work normally with custom config dir
708+
_, err = session.Send(copilot.MessageOptions{Prompt: "What is 1+1?"})
709+
if err != nil {
710+
t.Fatalf("Failed to send message: %v", err)
711+
}
712+
713+
assistantMessage, err := testharness.GetFinalAssistantMessage(session, 60*time.Second)
714+
if err != nil {
715+
t.Fatalf("Failed to get assistant message: %v", err)
716+
}
717+
718+
if assistantMessage.Data.Content == nil || !strings.Contains(*assistantMessage.Data.Content, "2") {
719+
t.Errorf("Expected assistant message to contain '2', got %v", assistantMessage.Data.Content)
720+
}
721+
})
690722
}
691723

692724
func getSystemMessage(exchange testharness.ParsedHttpExchange) string {

nodejs/test/e2e/session.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,20 @@ describe("Sessions", async () => {
334334
const assistantMessage = await getFinalAssistantMessage(session);
335335
expect(assistantMessage.data.content).toContain("300");
336336
});
337+
338+
it("should create session with custom config dir", async () => {
339+
const customConfigDir = `${homeDir}/custom-config`;
340+
const session = await client.createSession({
341+
configDir: customConfigDir,
342+
});
343+
344+
expect(session.sessionId).toMatch(/^[a-f0-9-]+$/);
345+
346+
// Session should work normally with custom config dir
347+
await session.send({ prompt: "What is 1+1?" });
348+
const assistantMessage = await getFinalAssistantMessage(session);
349+
expect(assistantMessage.data.content).toContain("2");
350+
});
337351
});
338352

339353
function getSystemMessage(exchange: ParsedHttpExchange): string | undefined {

python/e2e/test_session.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,19 @@ def on_event(event):
360360
assistant_message = await get_final_assistant_message(session)
361361
assert "300" in assistant_message.data.content
362362

363+
async def test_should_create_session_with_custom_config_dir(self, ctx: E2ETestContext):
364+
import os
365+
366+
custom_config_dir = os.path.join(ctx.home_dir, "custom-config")
367+
session = await ctx.client.create_session({"config_dir": custom_config_dir})
368+
369+
assert session.session_id
370+
371+
# Session should work normally with custom config dir
372+
await session.send({"prompt": "What is 1+1?"})
373+
assistant_message = await get_final_assistant_message(session)
374+
assert "2" in assistant_message.data.content
375+
363376

364377
def _get_system_message(exchange: dict) -> str:
365378
messages = exchange.get("request", {}).get("messages", [])
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
models:
2+
- claude-sonnet-4.5
3+
conversations:
4+
- messages:
5+
- role: system
6+
content: ${system}
7+
- role: user
8+
content: What is 1+1?
9+
- role: assistant
10+
content: 1 + 1 = 2

0 commit comments

Comments
 (0)