on main help sign in
Update internal/llm/prompt/prompt_test.go

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

commitb7935b4ef8a834da5ec4514e96aeab65a66f537f authorTai Groot <tai@taigrr.com> dateThu 10 Jul 2025, 18:21 (1 year ago) parentf8d8ce3
1 file changed+10−11
internal/llm/prompt/prompt_test.go+10−11
internal/llm/prompt/prompt_test.go+10−11
@@ -89,20 +89,19 @@ func TestProcessContextPaths(t *testing.T) {
8989 }
9090
9191 // Test with tilde expansion (if we can create a file in home directory)
92− home, err := os.UserHomeDir()
92+ tmpDir := t.TempDir()
93+ t.Setenv("HOME", tmpDir)
94+ homeTestFile := filepath.Join(tmpDir, "crush_test_file.txt")
95+ err := os.WriteFile(homeTestFile, []byte(testContent), 0o644)
9396 if err == nil {
94− homeTestFile := filepath.Join(home, "crush_test_file.txt")
95− err = os.WriteFile(homeTestFile, []byte(testContent), 0o644)
96− if err == nil {
97− defer os.Remove(homeTestFile) // Clean up
97+ defer os.Remove(homeTestFile) // Clean up
9898
99− tildeFile := "~/crush_test_file.txt"
100− result = processContextPaths("", []string{tildeFile})
101− expected = "# From:" + homeTestFile + "\n" + testContent
99+ tildeFile := "~/crush_test_file.txt"
100+ result = processContextPaths("", []string{tildeFile})
101+ expected = "# From:" + homeTestFile + "\n" + testContent
102102
103− if result != expected {
104− t.Errorf("processContextPaths with tilde expansion failed.\nGot: %q\nWant: %q", result, expected)
105− }
103+ if result != expected {
104+ t.Errorf("processContextPaths with tilde expansion failed.\nGot: %q\nWant: %q", result, expected)
106105 }
107106 }
108107}