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

Function TestWantConn_tryDeliver_WithError

internal/pool/want_conn_test.go:80–106  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

78}
79
80func TestWantConn_tryDeliver_WithError(t *testing.T) {
81 w := &wantConn{
82 ctx: context.Background(),
83 result: make(chan wantConnResult, 1),
84 }
85
86 testErr := errors.New("test error")
87
88 // Test delivery with error
89 delivered := w.tryDeliver(nil, testErr)
90 if !delivered {
91 t.Error("tryDeliver() = false, want true")
92 }
93
94 // Check result
95 select {
96 case result := <-w.result:
97 if result.cn != nil {
98 t.Errorf("result.cn = %v, want nil", result.cn)
99 }
100 if result.err != testErr {
101 t.Errorf("result.err = %v, want %v", result.err, testErr)
102 }
103 case <-time.After(time.Millisecond):
104 t.Error("Expected result to be sent to channel")
105 }
106}
107
108func TestWantConn_tryDeliver_AlreadyDone(t *testing.T) {
109 w := &wantConn{

Callers

nothing calls this directly

Calls 2

tryDeliverMethod · 0.95
ErrorMethod · 0.45

Tested by

no test coverage detected