beads/cmd/bd/setup/setup_test_helpers.go
kev e90f980ada feat(setup): omit bd dolt push from template when no remote configured
RenderSection() and ReplaceSection() now accept RenderOpts with a
HasRemote flag. When false, "bd dolt push" is stripped from the
session-completion code block (and the Auto-Sync informational bullet
in the full profile). This prevents agents from dutifully running a
no-op every session on solo/local-only projects.

bd init detects the remote via shouldWireInitRemote(); bd setup detects
it by reading sync.remote / sync.git-remote from config.yaml. The
existing no-arg RenderSection() and ReplaceSection() default to
HasRemote=true for full backward compatibility.

Closes beads-ozg.
2026-04-27 17:37:42 -04:00

36 lines
828 B
Go

package setup
import (
"testing"
"github.com/steveyegge/beads/internal/templates/agents"
)
type exitCapture struct {
called bool
code int
}
func stubSetupExit(t *testing.T) *exitCapture {
t.Helper()
cap := &exitCapture{}
orig := setupExit
setupExit = func(code int) {
cap.called = true
cap.code = code
}
t.Cleanup(func() {
setupExit = orig
})
return cap
}
// stubDetectRenderOpts overrides detectRenderOptsImpl to return
// DefaultRenderOpts (HasRemote=true), matching what agents.RenderSection()
// produces. This prevents hash mismatches in tests where no beads config exists.
func stubDetectRenderOpts(t *testing.T) {
t.Helper()
orig := detectRenderOptsImpl
detectRenderOptsImpl = func() agents.RenderOpts { return agents.DefaultRenderOpts() }
t.Cleanup(func() { detectRenderOptsImpl = orig })
}