MCPcopy
hub / github.com/apache/answer / TestQueue_Close

Function TestQueue_Close

internal/base/queue/queue_test.go:135–159  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

133}
134
135func TestQueue_Close(t *testing.T) {
136 q := New[*testMessage]("test", 10)
137
138 var count atomic.Int32
139 q.RegisterHandler(func(ctx context.Context, msg *testMessage) error {
140 count.Add(1)
141 return nil
142 })
143
144 // Send some messages
145 for i := range 5 {
146 q.Send(context.Background(), &testMessage{ID: i})
147 }
148
149 // Close and wait
150 q.Close()
151
152 // All messages should have been processed
153 if count.Load() != 5 {
154 t.Errorf("expected 5 messages processed, got %d", count.Load())
155 }
156
157 // Sending after close should not panic
158 q.Send(context.Background(), &testMessage{ID: 99})
159}
160
161func TestQueue_ConcurrentSend(t *testing.T) {
162 q := New[*testMessage]("test", 100)

Callers

nothing calls this directly

Calls 4

RegisterHandlerMethod · 0.65
AddMethod · 0.65
SendMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected