52 lines
1.2 KiB
Go
52 lines
1.2 KiB
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 TestDefaultConfigUsesDockerRuntimeOverrides(t *testing.T) {
|
|
t.Setenv("HTTP_ADDR", "0.0.0.0:18083")
|
|
t.Setenv("STATIC_DIR", "/app/web/dist")
|
|
t.Setenv("WORKSPACE_ROOT", "/app")
|
|
|
|
cfg := DefaultConfig()
|
|
|
|
if cfg.HTTPAddr != "0.0.0.0:18083" {
|
|
t.Fatalf("HTTPAddr = %q, want %q", cfg.HTTPAddr, "0.0.0.0:18083")
|
|
}
|
|
if cfg.StaticDir != "/app/web/dist" {
|
|
t.Fatalf("StaticDir = %q, want %q", cfg.StaticDir, "/app/web/dist")
|
|
}
|
|
if cfg.WorkspaceRoot != "/app" {
|
|
t.Fatalf("WorkspaceRoot = %q, want %q", cfg.WorkspaceRoot, "/app")
|
|
}
|
|
}
|
|
|
|
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)
|
|
}
|
|
}
|