summaryrefslogtreecommitdiff
path: root/internal/hexaicli/testhelpers_test.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-03-15 23:24:00 +0200
committerPaul Buetow <paul@buetow.org>2026-03-15 23:24:00 +0200
commit8ec8ee16e23081018e32dea122ecd9a3b8d8b2c7 (patch)
tree5a564bb36fc9750d3353435d2dd3cf2f28fa5261 /internal/hexaicli/testhelpers_test.go
parent10112d4b7a8150118e705b95df73c08824ac2b22 (diff)
Release v0.23.0v0.23.0
Diffstat (limited to 'internal/hexaicli/testhelpers_test.go')
-rw-r--r--internal/hexaicli/testhelpers_test.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/internal/hexaicli/testhelpers_test.go b/internal/hexaicli/testhelpers_test.go
index 3197880..a4c9e6b 100644
--- a/internal/hexaicli/testhelpers_test.go
+++ b/internal/hexaicli/testhelpers_test.go
@@ -10,6 +10,23 @@ import (
"codeberg.org/snonux/hexai/internal/llm"
)
+func TestMain(m *testing.M) {
+ cacheDir, err := os.MkdirTemp("", "hexai-cli-cache-*")
+ if err != nil {
+ panic(err)
+ }
+ oldCacheHome := os.Getenv("XDG_CACHE_HOME")
+ _ = os.Setenv("XDG_CACHE_HOME", cacheDir)
+ code := m.Run()
+ if oldCacheHome == "" {
+ _ = os.Unsetenv("XDG_CACHE_HOME")
+ } else {
+ _ = os.Setenv("XDG_CACHE_HOME", oldCacheHome)
+ }
+ _ = os.RemoveAll(cacheDir)
+ os.Exit(code)
+}
+
// setStdin sets os.Stdin from a string and returns a restore func and reader.
func setStdin(t *testing.T, content string) (func(), *os.File) {
t.Helper()