34 lines
650 B
Go
34 lines
650 B
Go
package app
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
)
|
|
|
|
func TestDefaultConfigUsesCODEXHomeOverride(t *testing.T) {
|
|
override := filepath.Join(t.TempDir(), "custom-codex")
|
|
t.Setenv("CODEX_HOME", override)
|
|
|
|
cfg := DefaultConfig()
|
|
|
|
if cfg.CodexHome != override {
|
|
t.Fatalf("CodexHome = %q, want %q", cfg.CodexHome, override)
|
|
}
|
|
}
|
|
|
|
func TestDefaultConfigFallsBackToUserCodexHome(t *testing.T) {
|
|
t.Setenv("CODEX_HOME", "")
|
|
home, err := os.UserHomeDir()
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
cfg := DefaultConfig()
|
|
|
|
want := filepath.Join(home, ".codex")
|
|
if cfg.CodexHome != want {
|
|
t.Fatalf("CodexHome = %q, want %q", cfg.CodexHome, want)
|
|
}
|
|
}
|