mirror of
https://github.com/EchoVault/SugarDB.git
synced 2025-10-30 02:51:47 +08:00
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:
@@ -139,7 +139,7 @@ func expireAtKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
|
||||
func incrKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) != 2 {
|
||||
return internal.KeyExtractionFuncResult{}, errors.New("wrong number of arguments for INCR")
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.KeyExtractionFuncResult{
|
||||
WriteKeys: cmd[1:2],
|
||||
@@ -148,13 +148,22 @@ func incrKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
|
||||
func decrKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) != 2 {
|
||||
return internal.KeyExtractionFuncResult{}, errors.New("wrong number of arguments for INCR")
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.KeyExtractionFuncResult{
|
||||
WriteKeys: cmd[1:2],
|
||||
}, nil
|
||||
}
|
||||
|
||||
func incrByKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) != 3 {
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.KeyExtractionFuncResult{
|
||||
WriteKeys: []string{cmd[1]},
|
||||
}, nil
|
||||
}
|
||||
|
||||
func decrByKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) != 3 {
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
|
||||
Reference in New Issue
Block a user