(t *testing.T)
| 275 | } |
| 276 | |
| 277 | func TestContextJSONWithEmptyIntent(t *testing.T) { |
| 278 | e := New() |
| 279 | rec := httptest.NewRecorder() |
| 280 | req := httptest.NewRequest(http.MethodGet, "/", nil) |
| 281 | c := e.NewContext(req, rec) |
| 282 | |
| 283 | u := user{ID: 1, Name: "Jon Snow"} |
| 284 | emptyIndent := "" |
| 285 | buf := new(bytes.Buffer) |
| 286 | |
| 287 | enc := json.NewEncoder(buf) |
| 288 | enc.SetIndent(emptyIndent, emptyIndent) |
| 289 | _ = enc.Encode(u) |
| 290 | err := c.JSONPretty(http.StatusOK, user{ID: 1, Name: "Jon Snow"}, emptyIndent) |
| 291 | if assert.NoError(t, err) { |
| 292 | assert.Equal(t, http.StatusOK, rec.Code) |
| 293 | assert.Equal(t, MIMEApplicationJSON, rec.Header().Get(HeaderContentType)) |
| 294 | assert.Equal(t, buf.String(), rec.Body.String()) |
| 295 | } |
| 296 | } |
| 297 | |
| 298 | func TestContextJSONP(t *testing.T) { |
| 299 | e := New() |
nothing calls this directly
no test coverage detected
searching dependent graphs…