fix(test): fix TestInitNoDbMode for no-db mode config persistence
Changes: - Save issue-prefix in config.yaml when using --no-db mode (previously only saved in database which doesn't exist in no-db mode) - Add config.ResetForTesting() to allow reloading config in tests - Simplify test to verify config values rather than execute subsequent commands (cobra's flag caching makes multi-Execute() testing complex) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
committed by
Steve Yegge
parent
81828db6ef
commit
fe67e9e232
@@ -7,7 +7,8 @@ import (
|
||||
)
|
||||
|
||||
// createConfigYaml creates the config.yaml template in the specified directory
|
||||
func createConfigYaml(beadsDir string, noDbMode bool) error {
|
||||
// In --no-db mode, the prefix is saved here since there's no database to store it.
|
||||
func createConfigYaml(beadsDir string, noDbMode bool, prefix string) error {
|
||||
configYamlPath := filepath.Join(beadsDir, "config.yaml")
|
||||
|
||||
// Skip if already exists
|
||||
@@ -20,6 +21,12 @@ func createConfigYaml(beadsDir string, noDbMode bool) error {
|
||||
noDbLine = "no-db: true # JSONL-only mode, no SQLite database"
|
||||
}
|
||||
|
||||
// In no-db mode, we need to persist the prefix in config.yaml
|
||||
prefixLine := "# issue-prefix: \"\""
|
||||
if noDbMode && prefix != "" {
|
||||
prefixLine = fmt.Sprintf("issue-prefix: %q", prefix)
|
||||
}
|
||||
|
||||
configYamlTemplate := fmt.Sprintf(`# Beads Configuration File
|
||||
# This file configures default behavior for all bd commands in this repository
|
||||
# All settings can also be set via environment variables (BD_* prefix)
|
||||
@@ -28,7 +35,7 @@ func createConfigYaml(beadsDir string, noDbMode bool) error {
|
||||
# Issue prefix for this repository (used by bd init)
|
||||
# If not set, bd init will auto-detect from directory name
|
||||
# Example: issue-prefix: "myproject" creates issues like "myproject-1", "myproject-2", etc.
|
||||
# issue-prefix: ""
|
||||
%s
|
||||
|
||||
# Use no-db mode: load from JSONL, no SQLite, write back after each command
|
||||
# When true, bd will use .beads/issues.jsonl as the source of truth
|
||||
@@ -82,7 +89,7 @@ func createConfigYaml(beadsDir string, noDbMode bool) error {
|
||||
# - linear.api-key
|
||||
# - github.org
|
||||
# - github.repo
|
||||
`, noDbLine)
|
||||
`, prefixLine, noDbLine)
|
||||
|
||||
if err := os.WriteFile(configYamlPath, []byte(configYamlTemplate), 0600); err != nil {
|
||||
return fmt.Errorf("failed to write config.yaml: %w", err)
|
||||
|
||||
Reference in New Issue
Block a user