summaryrefslogtreecommitdiff
path: root/internal/appconfig/config_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/appconfig/config_test.go')
-rw-r--r--internal/appconfig/config_test.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/internal/appconfig/config_test.go b/internal/appconfig/config_test.go
index cf9a725..c98d904 100644
--- a/internal/appconfig/config_test.go
+++ b/internal/appconfig/config_test.go
@@ -2,6 +2,7 @@ package appconfig
import (
"bytes"
+ "errors"
"io"
"log"
"os"
@@ -314,6 +315,26 @@ func TestGetConfigPath_XDG(t *testing.T) {
}
}
+func TestDefaultConfigPath_UsesResolvedPath(t *testing.T) {
+ dir := t.TempDir()
+ t.Setenv("XDG_CONFIG_HOME", dir)
+
+ got := DefaultConfigPath()
+ want := filepath.Join(dir, "hexai", "config.toml")
+ if got != want {
+ t.Fatalf("DefaultConfigPath() = %q, want %q", got, want)
+ }
+}
+
+func TestDefaultConfigPath_FallsBackOnError(t *testing.T) {
+ got := configPathOrFallback(func() (string, error) {
+ return "", errors.New("boom")
+ })
+ if got != configPathFallback {
+ t.Fatalf("configPathOrFallback() = %q, want %q", got, configPathFallback)
+ }
+}
+
func TestStateDir_XDG(t *testing.T) {
dir := t.TempDir()
t.Setenv("XDG_STATE_HOME", dir)