(t *testing.T)
| 103 | } |
| 104 | |
| 105 | func TestQueue_RegisterHandlerAfterSend(t *testing.T) { |
| 106 | q := New[*testMessage]("test", 10) |
| 107 | defer q.Close() |
| 108 | |
| 109 | received := make(chan *testMessage, 1) |
| 110 | |
| 111 | // Send first |
| 112 | q.Send(context.Background(), &testMessage{ID: 1}) |
| 113 | |
| 114 | // Small delay then register handler |
| 115 | time.Sleep(50 * time.Millisecond) |
| 116 | q.RegisterHandler(func(ctx context.Context, msg *testMessage) error { |
| 117 | received <- msg |
| 118 | return nil |
| 119 | }) |
| 120 | |
| 121 | // Send another message that should be received |
| 122 | q.Send(context.Background(), &testMessage{ID: 2}) |
| 123 | |
| 124 | select { |
| 125 | case r := <-received: |
| 126 | if r.ID != 2 { |
| 127 | // First message was dropped (no handler), second should be received |
| 128 | t.Logf("received message ID: %d", r.ID) |
| 129 | } |
| 130 | case <-time.After(time.Second): |
| 131 | t.Fatal("timeout waiting for message") |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | func TestQueue_Close(t *testing.T) { |
| 136 | q := New[*testMessage]("test", 10) |
nothing calls this directly
no test coverage detected