test(events): prove WriterLive off/shadow/live hook matrix
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -295,3 +295,32 @@ func TestE0B_ShadowDoesNotAck_PG(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestE2_WriterLiveModes_PG(t *testing.T) {
|
||||
pool, ctx := e0bPool(t)
|
||||
env := fmt.Sprintf("e2-%d", time.Now().UnixNano())
|
||||
if events.WriterLive(ctx, pool, env, events.ConsumerNotify) {
|
||||
t.Fatal("missing row must not be live")
|
||||
}
|
||||
if err := events.SetMode(ctx, pool, env, events.ConsumerNotify, events.ModeOff); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if events.WriterLive(ctx, pool, env, events.ConsumerNotify) {
|
||||
t.Fatal("off must keep hook writers")
|
||||
}
|
||||
if err := events.SetMode(ctx, pool, env, events.ConsumerNotify, events.ModeShadow); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if events.WriterLive(ctx, pool, env, events.ConsumerNotify) {
|
||||
t.Fatal("shadow must keep hook writers")
|
||||
}
|
||||
if err := events.SetMode(ctx, pool, env, events.ConsumerNotify, events.ModeLive); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !events.WriterLive(ctx, pool, env, events.ConsumerNotify) {
|
||||
t.Fatal("live must stop hook writers")
|
||||
}
|
||||
if err := events.SetMode(ctx, pool, env, events.ConsumerNotify, events.ModeOff); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,6 +183,12 @@ func TestAuthAndIntegrityGoDeadLetter(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestWriterLiveNilPool(t *testing.T) {
|
||||
if WriterLive(context.Background(), nil, "dev", ConsumerNotify) {
|
||||
t.Fatal("nil pool must keep in-process writers")
|
||||
}
|
||||
}
|
||||
|
||||
func TestReplayRequiresScope(t *testing.T) {
|
||||
if err := AuthorizeReplay(ReplayRequest{}); err != ErrReplayScope {
|
||||
t.Fatalf("empty: %v", err)
|
||||
|
||||
Reference in New Issue
Block a user