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

Function initConnOnMockServer

internal_maint_notif_test.go:226–236  ·  view source on GitHub ↗

initConnOnMockServer dials srv, puts the connection into INITIALIZING and runs c.initConn against it. It returns the error from initConn (if any).

(t *testing.T, c *baseClient, srv interface{ Addr() string })

Source from the content-addressed store, hash-verified

224// initConnOnMockServer dials srv, puts the connection into INITIALIZING and
225// runs c.initConn against it. It returns the error from initConn (if any).
226func initConnOnMockServer(t *testing.T, c *baseClient, srv interface{ Addr() string }) error {
227 t.Helper()
228 netConn, err := net.DialTimeout("tcp", srv.Addr(), 2*time.Second)
229 if err != nil {
230 t.Fatalf("failed to dial mock server: %v", err)
231 }
232 t.Cleanup(func() { _ = netConn.Close() })
233 cn := pool.NewConn(netConn)
234 cn.GetStateMachine().Transition(pool.StateInitializing)
235 return c.initConn(context.Background(), cn)
236}
237
238// newTestBaseClient builds a baseClient wired up with hooks for use in
239// tests that exercise initConn directly.

Calls 7

GetStateMachineMethod · 0.95
NewConnFunction · 0.92
CleanupMethod · 0.80
TransitionMethod · 0.80
initConnMethod · 0.80
CloseMethod · 0.65
AddrMethod · 0.45

Tested by

no test coverage detected