diff --git a/pipe.go b/pipe.go index 857fdf0f..30101c35 100644 --- a/pipe.go +++ b/pipe.go @@ -19,7 +19,7 @@ import ( "github.com/redis/rueidis/internal/util" ) -var noHello = regexp.MustCompile("unknown command .?HELLO.?") +var noHello = regexp.MustCompile("unknown command .?(HELLO|hello).?") type wire interface { Do(ctx context.Context, cmd Completed) RedisResult diff --git a/pipe_test.go b/pipe_test.go index f199a68d..04c818e1 100644 --- a/pipe_test.go +++ b/pipe_test.go @@ -3534,3 +3534,36 @@ func TestCloseHook(t *testing.T) { } }) } + +func TestNoHelloRegex(t *testing.T) { + tests := []struct { + name string + match bool + resp string + }{ + { + name: "lowercase hello", + match: true, + resp: "unknown command hello", + }, + { + name: "uppercase hello", + match: true, + resp: "unknown command HELLO", + }, + { + name: "not hello", + match: false, + resp: "unknown command not hello", + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if match := noHello.MatchString(tt.resp); match != tt.match { + t.Fatalf("unexpected match %v", match) + } + }) + } + +}