From 06b3320a67f7676a0635aa2e359f8cec7d79eec6 Mon Sep 17 00:00:00 2001 From: Harry Miller Date: Sat, 26 Sep 2026 06:01:42 -0700 Subject: [PATCH] test(cmd/bd): stop three tests depending on the developer's actor env (#6560) (#6706) TestPrepareSelectedCommandContext_RebindsTargetConfig and _DoesNotMergeCallerConfigForUnsetKeys assert that a config.yaml actor is rebound, but BEADS_ACTOR outranks config.yaml on purpose (resolveConfiguredActor, the GH#4645 fix), and so does BD_ACTOR through viper's BD-prefixed AutomaticEnv. Either one exported in a shell made the assertion unsatisfiable. A new clearActorEnv helper blanks both, following the t.Setenv("X", "") idiom these tests already use for the Dolt server env. A full cmd/bd run with both variables set found a third: TestCollectViperEntriesWithEnvOverride sets BD_ACTOR and expects it as the reported source, but an exported BEADS_ACTOR wins. It now blanks BEADS_ACTOR. CI runners set neither variable, so all three only failed locally. No product code changes. Agent-Signature: claude-code-opus-5-5-unknown-reasoning on behalf of Harry Miller Co-authored-by: Claude Opus 5.5 (1M context) --- cmd/bd/config_show_test.go | 3 +++ cmd/bd/context_binding_test.go | 15 +++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/cmd/bd/config_show_test.go b/cmd/bd/config_show_test.go index 4e409ee32..7001a6d07 100644 --- a/cmd/bd/config_show_test.go +++ b/cmd/bd/config_show_test.go @@ -284,6 +284,9 @@ func TestCollectViperEntriesWithEnvOverride(t *testing.T) { defer os.Chdir(origDir) //nolint:errcheck t.Setenv("BD_ACTOR", "env-bot") + // BEADS_ACTOR outranks BD_ACTOR on purpose (GH#4645), so one exported in + // the developer's shell would be reported as the source instead (GH#6560). + t.Setenv("BEADS_ACTOR", "") t.Setenv("BEADS_TEST_IGNORE_REPO_CONFIG", "1") config.ResetForTesting() if err := config.Initialize(); err != nil { diff --git a/cmd/bd/context_binding_test.go b/cmd/bd/context_binding_test.go index 9302203a4..adaec2f6a 100644 --- a/cmd/bd/context_binding_test.go +++ b/cmd/bd/context_binding_test.go @@ -51,9 +51,23 @@ func restoreRootFlagState(t *testing.T, state map[string]flagSnapshot) { } } +// clearActorEnv blanks the two environment variables that outrank a +// config.yaml actor, so a test asserting the config value is rebound does not +// depend on the developer's shell (GH#6560). BEADS_ACTOR outranks it +// deliberately: resolveConfiguredActor checks the env first, which is the +// GH#4645 fix. BD_ACTOR does too, because viper's BD-prefixed AutomaticEnv +// reads it as the actor key ahead of the file. CI runners set neither, which is +// why these tests only ever failed locally. +func clearActorEnv(t *testing.T) { + t.Helper() + t.Setenv("BEADS_ACTOR", "") + t.Setenv("BD_ACTOR", "") +} + func TestPrepareSelectedCommandContext_RebindsTargetConfig(t *testing.T) { t.Setenv("BEADS_DOLT_SERVER_DATABASE", "") t.Setenv("BEADS_DOLT_SERVER_PORT", "") + clearActorEnv(t) callerDir := t.TempDir() callerBeadsDir := filepath.Join(callerDir, ".beads") @@ -134,6 +148,7 @@ func TestPrepareSelectedCommandContext_RebindsTargetConfig(t *testing.T) { func TestPrepareSelectedCommandContext_DoesNotMergeCallerConfigForUnsetKeys(t *testing.T) { t.Setenv("BEADS_DOLT_SERVER_DATABASE", "") t.Setenv("BEADS_DOLT_SERVER_PORT", "") + clearActorEnv(t) root := t.TempDir() callerDir := filepath.Join(root, "caller")