forked from mtusi2026/mtusi2026lab6
18 lines
456 B
Go
18 lines
456 B
Go
package handler
|
|
|
|
import (
|
|
"encoding/json"
|
|
"testing"
|
|
)
|
|
|
|
func TestMessageJSONRequiresStringTextAndArrayIDs(t *testing.T) {
|
|
for _, body := range []string{`{"attachment_ids":[]}`, `{"text":null,"attachment_ids":[]}`, `{"text":"ok","attachment_ids":null}`} {
|
|
t.Run(body, func(t *testing.T) {
|
|
var message CreateMessage
|
|
if err := json.Unmarshal([]byte(body), &message); err == nil {
|
|
t.Fatal("accepted a missing/null required field")
|
|
}
|
|
})
|
|
}
|
|
}
|