From the redis docs, response for a PING is,
Command: PING [message]
Response:
Simple string reply: PONG when no argument is provided.
Bulk string reply: the provided argument.
It clearly states that when there is no message provided as argument, the cli expects a simple string +PONG\r\n
as a response. This might be a small nitpick, but the test doesn’t assert whether the response is actually in simple string format, and it passes even when bulk string $4\r\nPONG\r\n
is provided as response.
Looking at the source code for the redis-tester
, the assertion for ping response is run as NewStringAssertion
which accepts for both simple and bulk strings.
// test_ping_pong.go
commandTestCase := test_cases.SendCommandTestCase{
Command: "ping",
Args: []string{},
Assertion: resp_assertions.NewStringAssertion("PONG"),
}
// ...
// string_assertion.go
func NewStringAssertion(expectedValue string) RESPAssertion {
return StringAssertion{ExpectedValue: expectedValue}
}
func (a StringAssertion) Run(value resp_value.Value) error {
// PONG should be a simple string response
if value.Type != resp_value.SIMPLE_STRING && value.Type != resp_value.BULK_STRING {
return fmt.Errorf("Expected simple string or bulk string, got %s", value.Type)
}
// ...
}
This is not a breaking issue that needs to be fixed, but would be nice if the tests could be more specific.