test: cover string user ids in workbench payloads
This commit is contained in:
@@ -27,8 +27,6 @@ type optionalUserID struct {
|
||||
|
||||
func (id *optionalUserID) UnmarshalJSON(raw []byte) error {
|
||||
if strings.TrimSpace(string(raw)) == "null" {
|
||||
id.set = true
|
||||
id.value = 0
|
||||
return nil
|
||||
}
|
||||
value, err := parseUserIDJSON(raw)
|
||||
@@ -52,11 +50,7 @@ func parseUserIDJSON(raw []byte) (int64, error) {
|
||||
if err := json.Unmarshal(raw, &text); err == nil {
|
||||
return parseUserID(text)
|
||||
}
|
||||
var number int64
|
||||
if err := json.Unmarshal(raw, &number); err == nil {
|
||||
return number, nil
|
||||
}
|
||||
return 0, fmt.Errorf("invalid user id")
|
||||
return 0, fmt.Errorf("user id must be a string")
|
||||
}
|
||||
|
||||
func parseUserID(value string) (int64, error) {
|
||||
|
||||
Reference in New Issue
Block a user