Added command length tests for INCRBY command. Renamed INCRBY key func. Return WRONG_ARG_RESPONSE from key funcs when commands are not the correct length.

This commit is contained in:
Kelvin Mwinuka
2024-06-25 12:28:23 +08:00
parent 95f7175f8e
commit 5433b88776
4 changed files with 102 additions and 20 deletions

View File

@@ -2195,20 +2195,29 @@ func Test_Generic(t *testing.T) {
expectedResponse: 17,
expectedError: nil,
},
// {
// name: "6. Command too long",
// key: "IncrByKey6",
// increment: "5",
// presetValue: nil,
// command: []resp.Value{
// resp.StringValue("INCRBY"),
// resp.StringValue("IncrByKey6"),
// resp.StringValue("5"),
// resp.StringValue("extra_arg"),
// },
// expectedResponse: 0,
// expectedError: errors.New("ERR wrong number of arguments for 'incrby' command"),
// },
{
name: "5. Command too short",
key: "IncrByKey5",
increment: "5",
presetValue: nil,
command: []resp.Value{resp.StringValue("INCRBY"), resp.StringValue("IncrByKey5")},
expectedResponse: 0,
expectedError: errors.New(constants.WrongArgsResponse),
},
{
name: "6. Command too long",
key: "IncrByKey6",
increment: "5",
presetValue: nil,
command: []resp.Value{
resp.StringValue("INCRBY"),
resp.StringValue("IncrByKey6"),
resp.StringValue("5"),
resp.StringValue("extra_arg"),
},
expectedResponse: 0,
expectedError: errors.New(constants.WrongArgsResponse),
},
}
for _, test := range tests {