feat(eda): name and delete capture sources; an armed binding blocks the delete

This commit is contained in:
sam committed 2026-10-05 21:05:58 +11:00
1 parent 738044a949
commit d295fa2680
22 files changed
+1103 -592

No files matched your search

@@ -9,6 +9,7 @@ import (
"github.com/samcharles93/archie-core/internal/domain/binding"
"github.com/samcharles93/archie-core/internal/domain/eventtype"
"github.com/samcharles93/archie-core/internal/domain/mapping"
"github.com/samcharles93/archie-core/internal/domain/source"
"github.com/samcharles93/archie-core/internal/domain/storecontract"
"github.com/samcharles93/archie-core/internal/infrastructure/postgres"
"github.com/samcharles93/archie-core/internal/infrastructure/postgres/pgstore"
@@ -148,4 +149,24 @@ func TestBindingLifecycle(t *testing.T) {
if err := eda.PauseBinding(ctx, "missing"); !errors.Is(err, storecontract.ErrBindingNotFound) {
t.Fatalf("pause of a missing binding = %v, want ErrBindingNotFound", err)
}
// A source is not deleted while an armed binding fires on it.
if err := eda.InsertSource(ctx, source.Source{Path: "forge", Signing: source.SigningSigned}); err != nil {
t.Fatal(err)
}
if err := eda.ApproveBinding(ctx, id); err != nil {
t.Fatal(err)
}
if err := eda.DeleteSource(ctx, "forge"); !errors.Is(err, storecontract.ErrSourceInUse) {
t.Fatalf("delete of a source an armed binding fires on = %v, want ErrSourceInUse", err)
}
if err := eda.PauseBinding(ctx, id); err != nil {
t.Fatal(err)
}
if err := eda.DeleteSource(ctx, "forge"); err != nil {
t.Fatalf("delete of a source with no armed binding = %v", err)
}
if err := eda.DeleteSource(ctx, "forge"); !errors.Is(err, storecontract.ErrSourceNotFound) {
t.Fatalf("second delete = %v, want ErrSourceNotFound", err)
}
}