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:
parent
04f3c2fc4c
commit
84da9d36a2
2 changed files with 38 additions and 23 deletions
24
cmd/bd/config_get_backup_enabled_embedded_test.go
Normal file
24
cmd/bd/config_get_backup_enabled_embedded_test.go
Normal 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",
|
||||
},
|
||||
})
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue