fix: make database_removal_scenario test more realistic
The test was creating an empty .beads/ directory after simulating rm -rf, but FindBeadsDir() requires some project files (config.yaml, metadata.json, or *.db/*.jsonl) to recognize a directory as a valid beads directory. Updated the test to create a minimal config.yaml like bd init actually does before auto-import runs. This makes the test more realistic and fixes the flakiness.
This commit is contained in:
@@ -158,9 +158,14 @@ func testDatabaseRemovalScenario(t *testing.T) {
|
||||
runCmd(t, dir, "git", "add", ".beads/issues.jsonl")
|
||||
runCmd(t, dir, "git", "commit", "-m", "Add issues")
|
||||
|
||||
// Simulate rm -rf .beads/
|
||||
// Simulate rm -rf .beads/ followed by partial bd init
|
||||
// (in practice, bd init creates config.yaml before auto-import)
|
||||
os.RemoveAll(beadsDir)
|
||||
os.MkdirAll(beadsDir, 0755)
|
||||
// Create minimal config so FindBeadsDir recognizes this as a beads directory
|
||||
if err := os.WriteFile(filepath.Join(beadsDir, "config.yaml"), []byte("issue-prefix: test\n"), 0644); err != nil {
|
||||
t.Fatalf("Failed to write config.yaml: %v", err)
|
||||
}
|
||||
|
||||
// Change to test directory
|
||||
t.Chdir(dir)
|
||||
|
||||
Reference in New Issue
Block a user