mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-15 17:52:08 +00:00
feat: add replayable outbox adapter
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
package store
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestOutboxSQLPreservesReplayableOrderedReadAndPublishAck(t *testing.T) {
|
||||
for query, fragments := range map[string][]string{
|
||||
OutboxUnpublishedSelectSQL: {"published_at IS NULL", "ORDER BY created_at, event_id", "LIMIT $1"},
|
||||
OutboxMarkPublishedSQL: {"published_at = $2", "event_id = $1", "published_at IS NULL"},
|
||||
} {
|
||||
for _, fragment := range fragments {
|
||||
if !contains(query, fragment) {
|
||||
t.Fatalf("query %q missing %q", query, fragment)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestOutboxAdaptersRejectUnsafeArgumentsWithoutDatabase(t *testing.T) {
|
||||
if _, err := ReadUnpublishedOutbox(nil, nil, 1); err == nil {
|
||||
t.Fatal("nil database accepted")
|
||||
}
|
||||
if _, err := ReadUnpublishedOutbox(nil, nil, 1001); err == nil {
|
||||
t.Fatal("unbounded outbox batch accepted")
|
||||
}
|
||||
if err := MarkOutboxPublished(nil, nil, "event-1", time.Unix(1000, 0)); err == nil {
|
||||
t.Fatal("nil database acknowledgement accepted")
|
||||
}
|
||||
if err := MarkOutboxPublished(nil, nil, "", time.Unix(1000, 0)); err == nil {
|
||||
t.Fatal("empty event acknowledgement accepted")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user