MCPcopy
hub / github.com/redis/go-redis / TestWantConnQueue_dropFrontDone_NoneDone

Function TestWantConnQueue_dropFrontDone_NoneDone

internal/pool/want_conn_test.go:559–589  ·  view source on GitHub ↗

TestWantConnQueue_dropFrontDone_NoneDone tests dropFrontDone when no elements are done.

(t *testing.T)

Source from the content-addressed store, hash-verified

557
558// TestWantConnQueue_dropFrontDone_NoneDone tests dropFrontDone when no elements are done.
559func TestWantConnQueue_dropFrontDone_NoneDone(t *testing.T) {
560 q := newWantConnQueue()
561
562 // Create 3 wantConn items, none marked as done
563 for i := 0; i < 3; i++ {
564 w := &wantConn{
565 ctx: context.Background(),
566 done: false, // Not done
567 result: make(chan wantConnResult, 1),
568 }
569 q.enqueue(w)
570 }
571
572 // Verify initial queue length
573 if q.len() != 3 {
574 t.Errorf("initial queue length = %d, want 3", q.len())
575 }
576
577 // Call dropFrontDone
578 count := q.discardDoneAtFront()
579
580 // Verify no elements were removed
581 if count != 0 {
582 t.Errorf("dropFrontDone() = %d, want 0", count)
583 }
584
585 // Verify queue length unchanged
586 if q.len() != 3 {
587 t.Errorf("queue length after dropFrontDone = %d, want 3", q.len())
588 }
589}
590
591// TestWantConnQueue_dropFrontDone_PartialDone tests dropFrontDone with mixed done/not-done elements.
592// This is the core test case that verifies dropFrontDone stops at the first not-done element.

Callers

nothing calls this directly

Calls 4

newWantConnQueueFunction · 0.85
enqueueMethod · 0.80
discardDoneAtFrontMethod · 0.80
lenMethod · 0.45

Tested by

no test coverage detected