MCPcopy Create free account
hub / github.com/MiniCodeMonkey/chief / TestResolve_env

Function TestResolve_env

internal/agent/resolve_test.go:63–101  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

61}
62
63func 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
103func TestResolve_normalize(t *testing.T) {
104 got := mustResolve(t, " CODEX ", "", nil)

Callers

nothing calls this directly

Calls 3

mustResolveFunction · 0.85
NameMethod · 0.65
CLIPathMethod · 0.65

Tested by

no test coverage detected