MustMarshalJSON marshalls the given interface into JSON. If there is any error, it fails the test.
(t *testing.T, v interface{})
| 273 | // MustMarshalJSON marshalls the given interface into JSON. |
| 274 | // If there is any error, it fails the test. |
| 275 | func MustMarshalJSON(t *testing.T, v interface{}) []byte { |
| 276 | b, err := json.Marshal(v) |
| 277 | if err != nil { |
| 278 | t.Fatalf("%s: marshalling data: %s", t.Name(), err.Error()) |
| 279 | } |
| 280 | |
| 281 | return b |
| 282 | } |
| 283 | |
| 284 | // MustUnmarshalJSON marshalls the given interface into JSON. |
| 285 | // If there is any error, it fails the test. |