fix: keep workbench user ids compatible
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
package httpapi
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestUserIDJSONAcceptsIMUserID(t *testing.T) {
|
||||
var body struct {
|
||||
RecorderUserID userID `json:"recorder_user_id"`
|
||||
AttendeeUserIDs []userID `json:"attendee_user_ids"`
|
||||
}
|
||||
raw := []byte(`{"recorder_user_id":"usrag7w9xJ6hto","attendee_user_ids":["usr1RqTFgHSenM"]}`)
|
||||
if err := json.Unmarshal(raw, &body); err != nil {
|
||||
t.Fatalf("unmarshal: %v", err)
|
||||
}
|
||||
if body.RecorderUserID == 0 || len(body.AttendeeUserIDs) != 1 || body.AttendeeUserIDs[0] == 0 {
|
||||
t.Fatalf("decoded zero ids: %+v", body)
|
||||
}
|
||||
if got := formatUserID(int64(body.RecorderUserID)); got != "usrag7w9xJ6hto" {
|
||||
t.Fatalf("roundtrip recorder=%q", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestUserIDJSONStillAcceptsNumericID(t *testing.T) {
|
||||
var id userID
|
||||
if err := json.Unmarshal([]byte(`1573862062872858624`), &id); err != nil {
|
||||
t.Fatalf("unmarshal numeric: %v", err)
|
||||
}
|
||||
if id != 1573862062872858624 {
|
||||
t.Fatalf("id=%d", id)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user