MCPcopy Create free account
hub / github.com/google/go-cloud / TestIndependentBatchReturn

Function TestIndependentBatchReturn

pubsub/pubsub_test.go:306–325  ·  view source on GitHub ↗

TestIndependentBatchReturn verifies that when multiple batch requests are sent, as long as one of them succeeds it should not block Subscription.Receive.

(t *testing.T)

Source from the content-addressed store, hash-verified

304// TestIndependentBatchReturn verifies that when multiple batch requests are sent,
305// as long as one of them succeeds it should not block Subscription.Receive.
306func TestIndependentBatchReturn(t *testing.T) {
307 s := NewSubscription(
308 &secondReceiveBlockedDriverSub{},
309 &batcher.Options{MaxBatchSize: 1, MaxHandlers: 2}, // force 2 batches by allowing 2 handlers and 1 msg per batch
310 nil,
311 )
312 ctx := context.Background()
313 defer s.Shutdown(ctx)
314
315 // Set the batch size to force 2 batches to be called.
316 s.runningBatchSize = 2
317 ctxTimeout, cancel := context.WithTimeout(ctx, 10*time.Second)
318 defer cancel()
319 m, err := s.Receive(ctxTimeout)
320 if err != nil {
321 t.Fatal("Receive should not fail", err)
322 return
323 }
324 m.Ack()
325}
326
327func TestRetryTopic(t *testing.T) {
328 // Test that Send is retried if the driver returns a retryable error.

Callers

nothing calls this directly

Calls 4

ShutdownMethod · 0.95
ReceiveMethod · 0.95
NewSubscriptionFunction · 0.85
AckMethod · 0.65

Tested by

no test coverage detected