Skip to content

Commit

Permalink
Merge pull request #310 from yxxhero/match-lowcase-hello
Browse files Browse the repository at this point in the history
feat: match lowercase hello command
  • Loading branch information
rueian committed Jul 21, 2023
2 parents 1cf8498 + 899258a commit 5b290a8
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pipe.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
33 changes: 33 additions & 0 deletions pipe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
})
}

}

0 comments on commit 5b290a8

Please sign in to comment.