diff --git a/cmd/bd/config_get_backup_enabled_embedded_test.go b/cmd/bd/config_get_backup_enabled_embedded_test.go new file mode 100644 index 000000000..01c28c5cf --- /dev/null +++ b/cmd/bd/config_get_backup_enabled_embedded_test.go @@ -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", + }, + }) +} diff --git a/cmd/bd/config_get_backup_enabled_test.go b/cmd/bd/config_get_backup_enabled_test.go index 724254dd6..158764b14 100644 --- a/cmd/bd/config_get_backup_enabled_test.go +++ b/cmd/bd/config_get_backup_enabled_test.go @@ -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