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)
| 254 | // clear RESP3-related error instead of silently sending a meaningless |
| 255 | // CLIENT MAINT_NOTIFICATIONS command on a RESP2 connection. |
| 256 | func 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 |
nothing calls this directly
no test coverage detected