MCPcopy Create free account
hub / github.com/codehamr/codehamr / TestReexecGuardOverridesPreexistingValue

Function TestReexecGuardOverridesPreexistingValue

cmd/codehamr/main_test.go:41–47  ·  view source on GitHub ↗

TestReexecGuardOverridesPreexistingValue pins the loop-guard env semantics maybeSelfUpdate relies on: the re-exec'd child must see CODEHAMR_NO_UPDATE_CHECK=="1" even when a user already exported a different value. os.Setenv (the fix) overwrites in place; the old append(os.Environ(),…) left the stale

(t *testing.T)

Source from the content-addressed store, hash-verified

39// first, which Unix execve resolves first, defeating the guard; update.Check
40// short-circuits only on exactly "1".
41func TestReexecGuardOverridesPreexistingValue(t *testing.T) {
42 t.Setenv("CODEHAMR_NO_UPDATE_CHECK", "0") // user set it wrong; restored after test
43 var got []string
44 for _, kv := range reexecEnv() {
45 if strings.HasPrefix(kv, "CODEHAMR_NO_UPDATE_CHECK=") {
46 got = append(got, kv)
47 }
48 }
49 if len(got) != 1 || got[0] != "CODEHAMR_NO_UPDATE_CHECK=1" {
50 t.Fatalf("re-exec env must carry exactly one guard entry set to 1, got %v", got)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected