Skip to content

Commit 2a2571a

Browse files
committed
add tests
1 parent 8c3503d commit 2a2571a

5 files changed

Lines changed: 84 additions & 0 deletions

File tree

dotnet/test/SessionTests.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,4 +285,19 @@ public async Task Should_Pass_Streaming_Option_To_Session_Creation()
285285
Assert.NotNull(assistantMessage);
286286
Assert.Contains("2", assistantMessage!.Data.Content);
287287
}
288+
289+
[Fact]
290+
public async Task Should_Create_Session_With_Custom_Config_Dir()
291+
{
292+
var customConfigDir = Path.Combine(Ctx.HomeDir, "custom-config");
293+
var session = await Client.CreateSessionAsync(new SessionConfig { ConfigDir = customConfigDir });
294+
295+
Assert.Matches(@"^[a-f0-9-]+$", session.SessionId);
296+
297+
// Session should work normally with custom config dir
298+
await session.SendAsync(new MessageOptions { Prompt = "What is 1+1?" });
299+
var assistantMessage = await TestHelper.GetFinalAssistantMessageAsync(session);
300+
Assert.NotNull(assistantMessage);
301+
Assert.Contains("2", assistantMessage!.Data.Content);
302+
}
288303
}

go/e2e/session_test.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,38 @@ func TestSession(t *testing.T) {
614614
t.Errorf("Expected assistant message to contain '2', got %v", assistantMessage.Data.Content)
615615
}
616616
})
617+
618+
t.Run("should create session with custom config dir", func(t *testing.T) {
619+
ctx.ConfigureForTest(t)
620+
621+
customConfigDir := ctx.HomeDir + "/custom-config"
622+
session, err := client.CreateSession(&copilot.SessionConfig{
623+
ConfigDir: customConfigDir,
624+
})
625+
if err != nil {
626+
t.Fatalf("Failed to create session with custom config dir: %v", err)
627+
}
628+
629+
matched, _ := regexp.MatchString(`^[a-f0-9-]+$`, session.SessionID)
630+
if !matched {
631+
t.Errorf("Expected session ID to match UUID pattern, got %q", session.SessionID)
632+
}
633+
634+
// Session should work normally with custom config dir
635+
_, err = session.Send(copilot.MessageOptions{Prompt: "What is 1+1?"})
636+
if err != nil {
637+
t.Fatalf("Failed to send message: %v", err)
638+
}
639+
640+
assistantMessage, err := testharness.GetFinalAssistantMessage(session, 60*time.Second)
641+
if err != nil {
642+
t.Fatalf("Failed to get assistant message: %v", err)
643+
}
644+
645+
if assistantMessage.Data.Content == nil || !strings.Contains(*assistantMessage.Data.Content, "2") {
646+
t.Errorf("Expected assistant message to contain '2', got %v", assistantMessage.Data.Content)
647+
}
648+
})
617649
}
618650

619651
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
@@ -299,6 +299,20 @@ describe("Sessions", async () => {
299299
const assistantMessage = await getFinalAssistantMessage(session);
300300
expect(assistantMessage.data.content).toContain("2");
301301
});
302+
303+
it("should create session with custom config dir", async () => {
304+
const customConfigDir = `${homeDir}/custom-config`;
305+
const session = await client.createSession({
306+
configDir: customConfigDir,
307+
});
308+
309+
expect(session.sessionId).toMatch(/^[a-f0-9-]+$/);
310+
311+
// Session should work normally with custom config dir
312+
await session.send({ prompt: "What is 1+1?" });
313+
const assistantMessage = await getFinalAssistantMessage(session);
314+
expect(assistantMessage.data.content).toContain("2");
315+
});
302316
});
303317

304318
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
@@ -326,6 +326,19 @@ async def test_should_pass_streaming_option_to_session_creation(self, ctx: E2ETe
326326
assistant_message = await get_final_assistant_message(session)
327327
assert "2" in assistant_message.data.content
328328

329+
async def test_should_create_session_with_custom_config_dir(self, ctx: E2ETestContext):
330+
import os
331+
332+
custom_config_dir = os.path.join(ctx.home_dir, "custom-config")
333+
session = await ctx.client.create_session({"config_dir": custom_config_dir})
334+
335+
assert session.session_id
336+
337+
# Session should work normally with custom config dir
338+
await session.send({"prompt": "What is 1+1?"})
339+
assistant_message = await get_final_assistant_message(session)
340+
assert "2" in assistant_message.data.content
341+
329342

330343
def _get_system_message(exchange: dict) -> str:
331344
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)