test(agent/agentcontextconfig): isolate TestContextPartsFromDir from host HOME (#25649)

ContextPartsFromDir scans ~/.coder/skills via DefaultSkillsDir.
On machines with real skills installed, these leaked into test
results. Set HOME/USERPROFILE to temp dirs on the parent test
so subtests run in a clean environment.
This commit is contained in:
Mathias Fredriksson
2026-05-25 17:59:32 +03:00
committed by GitHub
parent 00a6dc56a7
commit 52e73b1343
+4 -1
View File
@@ -42,8 +42,11 @@ func writeSkillMetaFile(t *testing.T, dir, name, description string) string {
return writeSkillMetaFileInRoot(t, filepath.Join(dir, ".agents", "skills"), name, description)
}
//nolint:paralleltest,tparallel // Uses t.Setenv to isolate HOME.
func TestContextPartsFromDir(t *testing.T) {
t.Parallel()
// Prevent ~/.coder/skills on the host from leaking into results.
t.Setenv("HOME", t.TempDir())
t.Setenv("USERPROFILE", t.TempDir())
t.Run("ReturnsInstructionFilePart", func(t *testing.T) {
t.Parallel()