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

Function TestWantConnQueue_dropFrontDone_AllDone

internal/pool/want_conn_test.go:526–556  ·  view source on GitHub ↗

TestWantConnQueue_dropFrontDone_AllDone tests dropFrontDone when all elements are done.

(t *testing.T)

Source from the content-addressed store, hash-verified

524
525// TestWantConnQueue_dropFrontDone_AllDone tests dropFrontDone when all elements are done.
526func TestWantConnQueue_dropFrontDone_AllDone(t *testing.T) {
527 q := newWantConnQueue()
528
529 // Create 3 wantConn items, all marked as done
530 for i := 0; i < 3; i++ {
531 w := &wantConn{
532 ctx: context.Background(),
533 done: true, // Mark as done
534 result: make(chan wantConnResult, 1),
535 }
536 q.enqueue(w)
537 }
538
539 // Verify initial queue length
540 if q.len() != 3 {
541 t.Errorf("initial queue length = %d, want 3", q.len())
542 }
543
544 // Call dropFrontDone
545 count := q.discardDoneAtFront()
546
547 // Verify all 3 elements were removed
548 if count != 3 {
549 t.Errorf("dropFrontDone() = %d, want 3", count)
550 }
551
552 // Verify queue is now empty
553 if q.len() != 0 {
554 t.Errorf("queue length after dropFrontDone = %d, want 0", q.len())
555 }
556}
557
558// TestWantConnQueue_dropFrontDone_NoneDone tests dropFrontDone when no elements are done.
559func TestWantConnQueue_dropFrontDone_NoneDone(t *testing.T) {

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