20 lines
411 B
Go
20 lines
411 B
Go
package api
|
|
|
|
import "testing"
|
|
|
|
func TestDecodeJSONBytesIgnoresUnknownFields(t *testing.T) {
|
|
payload := []byte(`{"known":"value","status_at_collection":"ok"}`)
|
|
|
|
var req struct {
|
|
Known string `json:"known"`
|
|
}
|
|
|
|
if err := decodeJSONBytes(payload, &req); err != nil {
|
|
t.Fatalf("decode payload: %v", err)
|
|
}
|
|
if req.Known != "value" {
|
|
t.Fatalf("expected known field to be decoded, got %q", req.Known)
|
|
}
|
|
}
|
|
|