(t *testing.T)
| 61 | } |
| 62 | |
| 63 | func TestResolve_env(t *testing.T) { |
| 64 | const keyAgent = "CHIEF_AGENT" |
| 65 | const keyPath = "CHIEF_AGENT_PATH" |
| 66 | saveAgent := os.Getenv(keyAgent) |
| 67 | savePath := os.Getenv(keyPath) |
| 68 | defer func() { |
| 69 | if saveAgent != "" { |
| 70 | os.Setenv(keyAgent, saveAgent) |
| 71 | } else { |
| 72 | os.Unsetenv(keyAgent) |
| 73 | } |
| 74 | if savePath != "" { |
| 75 | os.Setenv(keyPath, savePath) |
| 76 | } else { |
| 77 | os.Unsetenv(keyPath) |
| 78 | } |
| 79 | }() |
| 80 | |
| 81 | os.Unsetenv(keyAgent) |
| 82 | os.Unsetenv(keyPath) |
| 83 | |
| 84 | // Env provider when no flag |
| 85 | os.Setenv(keyAgent, "codex") |
| 86 | got := mustResolve(t, "", "", nil) |
| 87 | if got.Name() != "Codex" { |
| 88 | t.Errorf("with CHIEF_AGENT=codex, name = %q, want Codex", got.Name()) |
| 89 | } |
| 90 | os.Unsetenv(keyAgent) |
| 91 | |
| 92 | // Env path when no flag path |
| 93 | os.Setenv(keyAgent, "codex") |
| 94 | os.Setenv(keyPath, "/env/codex") |
| 95 | got = mustResolve(t, "", "", nil) |
| 96 | if got.CLIPath() != "/env/codex" { |
| 97 | t.Errorf("with CHIEF_AGENT_PATH, CLIPath = %q, want /env/codex", got.CLIPath()) |
| 98 | } |
| 99 | os.Unsetenv(keyPath) |
| 100 | os.Unsetenv(keyAgent) |
| 101 | } |
| 102 | |
| 103 | func TestResolve_normalize(t *testing.T) { |
| 104 | got := mustResolve(t, " CODEX ", "", nil) |
nothing calls this directly
no test coverage detected