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

Function TestTryDial_AppliesDialTimeoutWhenSet

internal/pool/try_dial_test.go:11–28  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func TestTryDial_AppliesDialTimeoutWhenSet(t *testing.T) {
12 p := NewConnPool(&Options{
13 Dialer: func(ctx context.Context) (net.Conn, error) {
14 if _, ok := ctx.Deadline(); !ok {
15 return nil, errors.New("expected deadline in tryDial")
16 }
17 c1, c2 := net.Pipe()
18 _ = c2.Close()
19 return c1, nil
20 },
21 PoolSize: 1,
22 MaxConcurrentDials: 1,
23 DialTimeout: 200 * time.Millisecond,
24 })
25 defer p.Close()
26
27 p.tryDial()
28}
29
30func TestTryDial_DoesNotApplyDialTimeoutWhenDisabled(t *testing.T) {
31 p := NewConnPool(&Options{

Callers

nothing calls this directly

Calls 4

CloseMethod · 0.95
tryDialMethod · 0.95
NewConnPoolFunction · 0.85
CloseMethod · 0.65

Tested by

no test coverage detected