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

Function TestReAuthRespectsClosed

internal/auth/streaming/pool_hook_state_test.go:219–240  ·  view source on GitHub ↗

TestReAuthRespectsClosed verifies that re-auth doesn't happen on closed connections.

(t *testing.T)

Source from the content-addressed store, hash-verified

217
218// TestReAuthRespectsClosed verifies that re-auth doesn't happen on closed connections.
219func TestReAuthRespectsClosed(t *testing.T) {
220 // Create a connection
221 cn := pool.NewConn(nil)
222
223 // Initialize to IDLE state
224 cn.GetStateMachine().Transition(pool.StateInitializing)
225 cn.GetStateMachine().Transition(pool.StateIdle)
226
227 // Close the connection
228 cn.GetStateMachine().Transition(pool.StateClosed)
229
230 // Try to transition to UNUSABLE - should fail
231 _, err := cn.GetStateMachine().TryTransition([]pool.ConnState{pool.StateIdle}, pool.StateUnusable)
232 if err == nil {
233 t.Error("Expected error when trying to transition CLOSED → UNUSABLE, but got none")
234 }
235
236 // Verify state is still CLOSED
237 if state := cn.GetStateMachine().GetState(); state != pool.StateClosed {
238 t.Errorf("Expected state to remain CLOSED, got %s", state)
239 }
240}

Callers

nothing calls this directly

Calls 6

GetStateMachineMethod · 0.95
NewConnFunction · 0.92
TransitionMethod · 0.80
TryTransitionMethod · 0.80
ErrorMethod · 0.45
GetStateMethod · 0.45

Tested by

no test coverage detected