test(backup): split embedded effective-value cases (#4946) (#4947)

Keep SQL-server defaults and explicit backup overrides covered in every build. Move only the two embedded auto-detection cases into a CGO-tagged companion so non-CGO runs no longer assert an unavailable storage mode.

Agent-Signature: codex-tui-gpt-5.6-sol-ultra on behalf of Ewen Cuthiell
This commit is contained in:
ecuthiell 2026-07-23 19:25:16 -06:00 • committed by GitHub
commit 84da9d36a2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 38 additions and 23 deletions

View file

@ -0,0 +1,24 @@
//go:build cgo
package main
import "testing"
func TestConfigGetBackupEnabled_EffectiveValue_Embedded(t *testing.T) {
runConfigGetBackupEnabledEffectiveValueCases(t, []backupEnabledEffectiveValueCase{
{
name: "unset + no remote → off (no git remote)",
envVal: "\x00",
hasRemote: false,
wantPrefix: "false ",
wantContains: "no git remote",
},
{
name: "unset + remote → on (git remote)",
envVal: "\x00",
hasRemote: true,
wantPrefix: "true ",
wantContains: "git remote detected",
},
})
}

View file

@ -8,34 +8,22 @@ import (
"github.com/steveyegge/beads/internal/config"
)
type backupEnabledEffectiveValueCase struct {
name string
envVal string // "\x00" = unset
hasRemote bool
sharedServer bool
wantPrefix string // leading "true "/"false "
wantContains string // source annotation substring
}
// TestConfigGetBackupEnabled_EffectiveValue pins wy-zrmqr fix #3: `bd config
// get backup.enabled` must report the EFFECTIVE value (what isBackupAutoEnabled
// actually returns) plus its source, not the raw stored value. Before the fix
// it printed "false"/"not set" even while auto-backup was running via
// primeHasGitRemote — the mismatch that hid the storm from operators.
func TestConfigGetBackupEnabled_EffectiveValue(t *testing.T) {
tests := []struct {
name string
envVal string // "\x00" = unset
hasRemote bool
sharedServer bool
wantPrefix string // leading "true "/"false "
wantContains string // source annotation substring
}{
{
name: "unset + no remote → off (no git remote)",
envVal: "\x00",
hasRemote: false,
wantPrefix: "false ",
wantContains: "no git remote",
},
{
name: "unset + remote → on (git remote)",
envVal: "\x00",
hasRemote: true,
wantPrefix: "true ",
wantContains: "git remote detected",
},
runConfigGetBackupEnabledEffectiveValueCases(t, []backupEnabledEffectiveValueCase{
{
name: "unset + remote + sql-server → off (server mode)",
envVal: "\x00",
@ -59,8 +47,11 @@ func TestConfigGetBackupEnabled_EffectiveValue(t *testing.T) {
wantPrefix: "false ",
wantContains: "env var",
},
}
})
}
func runConfigGetBackupEnabledEffectiveValueCases(t *testing.T, tests []backupEnabledEffectiveValueCase) {
t.Helper()
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
orig := primeHasGitRemote