Fix FK constraint failures in AddComment and ApplyCompaction (bd-5arw)

Amp-Thread-ID: https://ampcode.com/threads/T-4358e6e4-28ea-4ed7-ba3f-3da39072e169
Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
Steve Yegge
2025-11-20 18:55:10 -05:00
parent 4560f55795
commit 345766badc
4 changed files with 66 additions and 11 deletions

View File

@@ -3,6 +3,7 @@ package sqlite
import (
"context"
"database/sql"
"strings"
"testing"
"time"
@@ -369,3 +370,22 @@ func TestApplyCompaction(t *testing.T) {
func timePtr(t time.Time) *time.Time {
return &t
}
func TestApplyCompactionNotFound(t *testing.T) {
store, cleanup := setupTestDB(t)
defer cleanup()
ctx := context.Background()
nonExistentID := "bd-999"
err := store.ApplyCompaction(ctx, nonExistentID, 1, 100, 50, "abc123")
if err == nil {
t.Fatal("Expected error, got nil")
}
expectedError := "issue bd-999 not found"
if !strings.Contains(err.Error(), expectedError) {
t.Errorf("Expected error to contain %q, got %q", expectedError, err.Error())
}
}