test: align rig beads init fallback coverage
Update the rig init test to assert config.yaml fallback when bd init fails. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -418,7 +418,7 @@ func (m *Manager) initBeads(rigPath, prefix string) error {
|
|||||||
// Run bd init if available, with --no-agents to skip AGENTS.md creation
|
// Run bd init if available, with --no-agents to skip AGENTS.md creation
|
||||||
cmd := exec.Command("bd", "init", "--prefix", prefix, "--no-agents")
|
cmd := exec.Command("bd", "init", "--prefix", prefix, "--no-agents")
|
||||||
cmd.Dir = rigPath
|
cmd.Dir = rigPath
|
||||||
output, err := cmd.CombinedOutput()
|
_, err := cmd.CombinedOutput()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// bd might not be installed or failed, create minimal structure
|
// bd might not be installed or failed, create minimal structure
|
||||||
// Note: beads currently expects YAML format for config
|
// Note: beads currently expects YAML format for config
|
||||||
|
|||||||
@@ -262,7 +262,7 @@ func TestEnsureGitignoreEntry_AppendsToExisting(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestInitBeadsRetriesWithoutNoAgentsFlag(t *testing.T) {
|
func TestInitBeadsWritesConfigOnFailure(t *testing.T) {
|
||||||
rigPath := t.TempDir()
|
rigPath := t.TempDir()
|
||||||
beadsDir := filepath.Join(rigPath, ".beads")
|
beadsDir := filepath.Join(rigPath, ".beads")
|
||||||
|
|
||||||
@@ -271,14 +271,8 @@ set -e
|
|||||||
cmd="$1"
|
cmd="$1"
|
||||||
shift
|
shift
|
||||||
if [[ "$cmd" == "init" ]]; then
|
if [[ "$cmd" == "init" ]]; then
|
||||||
for arg in "$@"; do
|
echo "bd init failed" >&2
|
||||||
if [[ "$arg" == "--no-agents" ]]; then
|
exit 1
|
||||||
echo "unknown flag: --no-agents" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
touch "$EXPECT_BEADS_DIR/created.db"
|
|
||||||
exit 0
|
|
||||||
fi
|
fi
|
||||||
echo "unexpected command: $cmd" >&2
|
echo "unexpected command: $cmd" >&2
|
||||||
exit 1
|
exit 1
|
||||||
@@ -293,8 +287,13 @@ exit 1
|
|||||||
t.Fatalf("initBeads: %v", err)
|
t.Fatalf("initBeads: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := os.Stat(filepath.Join(beadsDir, "created.db")); err != nil {
|
configPath := filepath.Join(beadsDir, "config.yaml")
|
||||||
t.Fatalf("expected bd init to create db file: %v", err)
|
config, err := os.ReadFile(configPath)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("reading config.yaml: %v", err)
|
||||||
|
}
|
||||||
|
if string(config) != "prefix: gt\n" {
|
||||||
|
t.Fatalf("config.yaml = %q, want %q", string(config), "prefix: gt\n")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user