mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-11 19:53:42 +00:00
35 lines
1.1 KiB
Go
35 lines
1.1 KiB
Go
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")
|
|
}
|
|
}
|