D-01: callback_target contract drift cleanup. - Remove CallbackTarget from Event struct and Validate - Remove CallbackTarget from PlatformInboundMeta - Remove defaultCallbackTarget and assignment from builder - Remove callback_target column from INSERT/SELECT/dead_letter SQL - Clean up all test literals and assertions DB migration left untouched; column remains empty until a future schema cleanup migration.
44 lines
874 B
Go
44 lines
874 B
Go
package platformevent
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestEvent_Validate(t *testing.T) {
|
|
now := time.Now()
|
|
event := Event{
|
|
ID: "evt-1",
|
|
Platform: "sub2api",
|
|
EventType: TypeReplyGenerated,
|
|
Status: StatusPending,
|
|
AttemptCount: 0,
|
|
NextAttemptAt: now,
|
|
OccurredAt: now,
|
|
}
|
|
|
|
if err := event.Validate(); err != nil {
|
|
t.Fatalf("Validate() error = %v", err)
|
|
}
|
|
}
|
|
|
|
func TestEvent_ValidateRejectsInvalidStatus(t *testing.T) {
|
|
event := Event{
|
|
ID: "evt-1",
|
|
Platform: "sub2api",
|
|
EventType: TypeReplyGenerated,
|
|
Status: Status("invalid"),
|
|
NextAttemptAt: time.Now(),
|
|
OccurredAt: time.Now(),
|
|
}
|
|
|
|
err := event.Validate()
|
|
if err == nil {
|
|
t.Fatal("expected error for invalid status")
|
|
}
|
|
if !strings.Contains(err.Error(), "invalid status") {
|
|
t.Fatalf("unexpected error: %v", err)
|
|
}
|
|
}
|