| 1 | package main |
| 2 | |
| 3 | import ( |
| 4 | "encoding/json" |
| 5 | "strings" |
| 6 | "testing" |
| 7 | ) |
| 8 | |
| 9 | func TestInboxCancelResultViewMarshalsEmptyIDsAsArray(t *testing.T) { |
| 10 | view := InboxCancelResultView{DiscardedItemIDs: []string{}} |
| 11 | data, err := json.Marshal(view) |
| 12 | if err != nil { |
| 13 | t.Fatal(err) |
| 14 | } |
| 15 | if got := string(data); !strings.Contains(got, `"discardedItemIds":[]`) { |
| 16 | t.Fatalf("cancel result JSON = %s, want non-null array", got) |
| 17 | } |
| 18 | } |
| 19 |