package events import ( "encoding/json" "testing" ) // The payload marshals with the keys clients read, and empty lists as []. func TestOpportunitiesUpdatedPayloadJSON(t *testing.T) { payload := OpportunitiesUpdatedPayload{ New: []string{"ocds-1"}, Updated: []string{}, Summary: OpportunitiesSummary{ New: 1, }, } encoded, err := json.Marshal(payload) if err != nil { t.Fatal(err) } want := `{"new":["ocds-1"],"updated":[],"summary":{"new":1,"updated":0}}` if string(encoded) != want { t.Errorf("JSON = %s; want %s", encoded, want) } }