Adding tests for APPEND

This commit is contained in:
DMcP89
2024-07-02 14:08:17 -04:00
parent fca160c590
commit 26224f1d1a
4 changed files with 3580 additions and 3443 deletions

View File

@@ -182,16 +182,19 @@ func handleAppend(params internal.HandlerFuncParams) ([]byte, error) {
}); err != nil {
return nil, err
}
return []byte(fmt.Sprintf("$%d\r\n%s\r\n", len(value), value)), nil
return []byte(fmt.Sprintf(":%d\r\n", len(value))), nil
}
currentValue, ok := params.GetValues(params.Context, []string{key})[key].(string)
if !ok {
return nil, fmt.Errorf("Value at key %s is not a string", key)
}
currentValue := params.GetValues(params.Context, []string{key})[key]
newValue := fmt.Sprintf("%v%s", currentValue, value)
if err = params.SetValues(params.Context, map[string]interface{}{
key: internal.AdaptType(newValue),
}); err != nil {
return nil, err
}
return []byte(fmt.Sprintf("$%d\r\n%s\r\n", len(newValue), newValue)), nil
return []byte(fmt.Sprintf(":%d\r\n", len(newValue))), nil
}
func Commands() []internal.Command {