MCPcopy
hub / github.com/nats-io/nats.go / TestPullConsumer_checkPending

Function TestPullConsumer_checkPending

jetstream/jetstream_test.go:349–528  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

347}
348
349func TestPullConsumer_checkPending(t *testing.T) {
350
351 tests := []struct {
352 name string
353 givenSub *pullSubscription
354 fetchInProgress bool
355 shouldSend bool
356 expectedPullRequest *pullRequest
357 }{
358 {
359 name: "msgs threshold not reached, bytes not set, no pull request",
360 givenSub: &pullSubscription{
361 pending: pendingMsgs{
362 msgCount: 10,
363 },
364 consumeOpts: &consumeOpts{
365 ThresholdMessages: 5,
366 MaxMessages: 10,
367 },
368 },
369 shouldSend: false,
370 },
371 {
372 name: "pending msgs below threshold, send pull request",
373 givenSub: &pullSubscription{
374 pending: pendingMsgs{
375 msgCount: 4,
376 byteCount: 400, // byte count should be ignored
377 },
378 consumeOpts: &consumeOpts{
379 ThresholdMessages: 5,
380 MaxMessages: 10,
381 },
382 },
383 shouldSend: true,
384 expectedPullRequest: &pullRequest{
385 Batch: 6,
386 MaxBytes: 0,
387 },
388 },
389 {
390 name: "pending msgs below threshold but PR in progress",
391 givenSub: &pullSubscription{
392 pending: pendingMsgs{
393 msgCount: 4,
394 },
395 consumeOpts: &consumeOpts{
396 ThresholdMessages: 5,
397 MaxMessages: 10,
398 },
399 },
400 fetchInProgress: true,
401 shouldSend: false,
402 },
403 {
404 name: "pending bytes below threshold, send pull request",
405 givenSub: &pullSubscription{
406 pending: pendingMsgs{

Callers

nothing calls this directly

Calls 3

StoreMethod · 0.80
ErrorfMethod · 0.80
checkPendingMethod · 0.80

Tested by

no test coverage detected