Skip to content

Commit bfe39fd

Browse files
committed
Add tests to validate custom config dir is used
1 parent f292fa3 commit bfe39fd

File tree

4 files changed

+68
-0
lines changed

4 files changed

+68
-0
lines changed

dotnet/test/SessionTests.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,5 +299,16 @@ public async Task Should_Create_Session_With_Custom_Config_Dir()
299299
var assistantMessage = await TestHelper.GetFinalAssistantMessageAsync(session);
300300
Assert.NotNull(assistantMessage);
301301
Assert.Contains("2", assistantMessage!.Data.Content);
302+
303+
// Verify that the custom config directory was created and contains files
304+
Assert.True(Directory.Exists(customConfigDir), $"Custom config dir {customConfigDir} should exist");
305+
306+
// Check that session state was written to the custom config dir
307+
var sessionStateDir = Path.Join(customConfigDir, "session-state");
308+
Assert.True(Directory.Exists(sessionStateDir), $"Session state dir {sessionStateDir} should exist");
309+
310+
// Verify session files exist in the custom config dir
311+
var sessionDir = Path.Join(sessionStateDir, session.SessionId);
312+
Assert.True(Directory.Exists(sessionDir), $"Session dir {sessionDir} should exist");
302313
}
303314
}

go/e2e/session_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package e2e
22

33
import (
4+
"os"
45
"regexp"
56
"strings"
67
"testing"
@@ -645,6 +646,23 @@ func TestSession(t *testing.T) {
645646
if assistantMessage.Data.Content == nil || !strings.Contains(*assistantMessage.Data.Content, "2") {
646647
t.Errorf("Expected assistant message to contain '2', got %v", assistantMessage.Data.Content)
647648
}
649+
650+
// Verify that the custom config directory was created and contains files
651+
if _, err := os.Stat(customConfigDir); os.IsNotExist(err) {
652+
t.Errorf("Expected custom config dir %q to exist", customConfigDir)
653+
}
654+
655+
// Check that session state was written to the custom config dir
656+
sessionStateDir := customConfigDir + "/session-state"
657+
if _, err := os.Stat(sessionStateDir); os.IsNotExist(err) {
658+
t.Errorf("Expected session state dir %q to exist", sessionStateDir)
659+
}
660+
661+
// Verify session files exist in the custom config dir
662+
sessionDir := sessionStateDir + "/" + session.SessionID
663+
if _, err := os.Stat(sessionDir); os.IsNotExist(err) {
664+
t.Errorf("Expected session dir %q to exist", sessionDir)
665+
}
648666
})
649667
}
650668

nodejs/test/e2e/session.test.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import fs from "fs/promises";
12
import { describe, expect, it, onTestFinished } from "vitest";
23
import { ParsedHttpExchange } from "../../../test/harness/replayingCapiProxy.js";
34
import { CopilotClient } from "../../src/index.js";
@@ -312,6 +313,29 @@ describe("Sessions", async () => {
312313
await session.send({ prompt: "What is 1+1?" });
313314
const assistantMessage = await getFinalAssistantMessage(session);
314315
expect(assistantMessage.data.content).toContain("2");
316+
317+
// Verify that the custom config directory was created and contains files
318+
const customConfigDirExists = await fs
319+
.access(customConfigDir)
320+
.then(() => true)
321+
.catch(() => false);
322+
expect(customConfigDirExists).toBe(true);
323+
324+
// Check that session state was written to the custom config dir
325+
const sessionStateDir = `${customConfigDir}/session-state`;
326+
const sessionStateDirExists = await fs
327+
.access(sessionStateDir)
328+
.then(() => true)
329+
.catch(() => false);
330+
expect(sessionStateDirExists).toBe(true);
331+
332+
// Verify session files exist in the custom config dir
333+
const sessionDir = `${sessionStateDir}/${session.sessionId}`;
334+
const sessionDirExists = await fs
335+
.access(sessionDir)
336+
.then(() => true)
337+
.catch(() => false);
338+
expect(sessionDirExists).toBe(true);
315339
});
316340
});
317341

python/e2e/test_session.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,21 @@ async def test_should_create_session_with_custom_config_dir(self, ctx: E2ETestCo
339339
assistant_message = await get_final_assistant_message(session)
340340
assert "2" in assistant_message.data.content
341341

342+
# Verify that the custom config directory was created and contains files
343+
assert os.path.isdir(custom_config_dir), (
344+
f"Custom config dir {custom_config_dir} should exist"
345+
)
346+
347+
# Check that session state was written to the custom config dir
348+
session_state_dir = os.path.join(custom_config_dir, "session-state")
349+
assert os.path.isdir(session_state_dir), (
350+
f"Session state dir {session_state_dir} should exist"
351+
)
352+
353+
# Verify session files exist in the custom config dir
354+
session_dir = os.path.join(session_state_dir, session.session_id)
355+
assert os.path.isdir(session_dir), f"Session dir {session_dir} should exist"
356+
342357

343358
def _get_system_message(exchange: dict) -> str:
344359
messages = exchange.get("request", {}).get("messages", [])

0 commit comments

Comments
 (0)