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

Function TestWantConnQueue_len

internal/pool/want_conn_test.go:844–872  ·  view source on GitHub ↗

TestWantConnQueue_len tests the len() method.

(t *testing.T)

Source from the content-addressed store, hash-verified

842
843// TestWantConnQueue_len tests the len() method.
844func TestWantConnQueue_len(t *testing.T) {
845 q := newWantConnQueue()
846
847 // Test empty queue
848 if length := q.len(); length != 0 {
849 t.Errorf("empty queue len() = %d, want 0", length)
850 }
851
852 // Add elements and verify length
853 for i := 1; i <= 5; i++ {
854 w := &wantConn{
855 ctx: context.Background(),
856 result: make(chan wantConnResult, 1),
857 }
858 q.enqueue(w)
859
860 if length := q.len(); length != i {
861 t.Errorf("queue len() after %d enqueues = %d, want %d", i, length, i)
862 }
863 }
864
865 // Remove elements and verify length
866 for i := 4; i >= 0; i-- {
867 q.dequeue()
868 if length := q.len(); length != i {
869 t.Errorf("queue len() after dequeue = %d, want %d", length, i)
870 }
871 }
872}
873
874// TestWantConnQueue_len_Concurrent tests len() thread safety.
875func TestWantConnQueue_len_Concurrent(t *testing.T) {

Callers

nothing calls this directly

Calls 4

newWantConnQueueFunction · 0.85
enqueueMethod · 0.80
dequeueMethod · 0.80
lenMethod · 0.45

Tested by

no test coverage detected