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

Function createMockPoolConnection

maintnotifications/pool_hook_test.go:39–46  ·  view source on GitHub ↗

createMockPoolConnection creates a mock pool connection for testing

()

Source from the content-addressed store, hash-verified

37
38// createMockPoolConnection creates a mock pool connection for testing
39func createMockPoolConnection() *pool.Conn {
40 mockNetConn := &mockNetConn{addr: "test:6379"}
41 conn := pool.NewConn(mockNetConn)
42 conn.SetUsable(true) // Make connection usable for testing (transitions to IDLE)
43 // Simulate real flow: connection is acquired (IDLE → IN_USE) before OnPut is called
44 conn.SetUsed(true) // Transition to IN_USE state
45 return conn
46}
47
48// mockPool implements pool.Pooler for testing
49type mockPool struct {

Calls 3

SetUsableMethod · 0.95
SetUsedMethod · 0.95
NewConnFunction · 0.92

Tested by

no test coverage detected