fix: support delete in --no-db mode (GH#822)
Add CreateTombstone() to MemoryStorage and deleteBatchFallback() to handle deletion when SQLite is not available. This fixes the error "tombstone operation not supported by this storage backend" when using bd delete with --no-db flag. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
committed by
Steve Yegge
parent
ee51298fd5
commit
b161e22144
@@ -2,6 +2,7 @@ package memory
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -949,6 +950,68 @@ func TestStatistics_TombstonesExcludedFromTotal(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCreateTombstone(t *testing.T) {
|
||||
store := setupTestMemory(t)
|
||||
defer store.Close()
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
// Create an issue
|
||||
issue := &types.Issue{
|
||||
Title: "Test Issue",
|
||||
Status: types.StatusOpen,
|
||||
Priority: 1,
|
||||
IssueType: types.TypeTask,
|
||||
}
|
||||
if err := store.CreateIssue(ctx, issue, "test"); err != nil {
|
||||
t.Fatalf("CreateIssue failed: %v", err)
|
||||
}
|
||||
issueID := issue.ID
|
||||
|
||||
// Create tombstone
|
||||
if err := store.CreateTombstone(ctx, issueID, "test-actor", "test deletion"); err != nil {
|
||||
t.Fatalf("CreateTombstone failed: %v", err)
|
||||
}
|
||||
|
||||
// Verify the issue is now a tombstone
|
||||
updated, err := store.GetIssue(ctx, issueID)
|
||||
if err != nil {
|
||||
t.Fatalf("GetIssue failed: %v", err)
|
||||
}
|
||||
|
||||
if updated.Status != types.StatusTombstone {
|
||||
t.Errorf("Expected status=%s, got %s", types.StatusTombstone, updated.Status)
|
||||
}
|
||||
if updated.DeletedAt == nil {
|
||||
t.Error("Expected DeletedAt to be set")
|
||||
}
|
||||
if updated.DeletedBy != "test-actor" {
|
||||
t.Errorf("Expected DeletedBy=test-actor, got %s", updated.DeletedBy)
|
||||
}
|
||||
if updated.DeleteReason != "test deletion" {
|
||||
t.Errorf("Expected DeleteReason='test deletion', got %s", updated.DeleteReason)
|
||||
}
|
||||
if updated.OriginalType != string(types.TypeTask) {
|
||||
t.Errorf("Expected OriginalType=%s, got %s", types.TypeTask, updated.OriginalType)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCreateTombstone_NotFound(t *testing.T) {
|
||||
store := setupTestMemory(t)
|
||||
defer store.Close()
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
// Try to create tombstone for non-existent issue
|
||||
err := store.CreateTombstone(ctx, "nonexistent", "test", "reason")
|
||||
if err == nil {
|
||||
t.Fatal("Expected error for non-existent issue")
|
||||
}
|
||||
if !strings.Contains(err.Error(), "not found") {
|
||||
t.Errorf("Expected 'not found' error, got: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestConfigOperations(t *testing.T) {
|
||||
store := setupTestMemory(t)
|
||||
defer store.Close()
|
||||
|
||||
Reference in New Issue
Block a user