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

Function TestInitConn_HelloFallback_ModeEnabled

internal_maint_notif_test.go:256–278  ·  view source on GitHub ↗

TestInitConn_HelloFallback_ModeEnabled verifies that when the server rejects HELLO (so the connection falls back to RESP2) and the user has explicitly requested ModeEnabled with Protocol: 3, initConn fails with a clear RESP3-related error instead of silently sending a meaningless CLIENT MAINT_NOTIFI

(t *testing.T)

Source from the content-addressed store, hash-verified

254// clear RESP3-related error instead of silently sending a meaningless
255// CLIENT MAINT_NOTIFICATIONS command on a RESP2 connection.
256func TestInitConn_HelloFallback_ModeEnabled(t *testing.T) {
257 srv := startMockRESP2Server(t)
258 defer srv.Close()
259
260 opt := &Options{
261 Addr: srv.Addr(),
262 Protocol: 3,
263 MaintNotificationsConfig: &maintnotifications.Config{
264 Mode: maintnotifications.ModeEnabled,
265 },
266 }
267 opt.init()
268
269 c := newTestBaseClient(opt)
270 err := initConnOnMockServer(t, c, srv)
271 if err == nil {
272 t.Fatalf("expected initConn to fail when HELLO falls back to RESP2 with ModeEnabled, got nil")
273 }
274 if !strings.Contains(err.Error(), "RESP3") {
275 t.Fatalf("expected error to mention RESP3, got %v", err)
276 }
277 assertNoMaintNotifications(t, srv)
278}
279
280// TestInitConn_HelloFallback_ModeAuto verifies that when HELLO is rejected
281// and ModeAuto is configured, initConn succeeds without sending CLIENT

Callers

nothing calls this directly

Calls 9

initMethod · 0.95
startMockRESP2ServerFunction · 0.85
newTestBaseClientFunction · 0.85
initConnOnMockServerFunction · 0.85
CloseMethod · 0.65
AddrMethod · 0.45
ContainsMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected