(t *testing.T)
| 1859 | } |
| 1860 | |
| 1861 | func TestContextAbortWithStatusPureJSON(t *testing.T) { |
| 1862 | w := httptest.NewRecorder() |
| 1863 | c, _ := CreateTestContext(w) |
| 1864 | c.index = 4 |
| 1865 | |
| 1866 | in := new(testJSONAbortMsg) |
| 1867 | in.Bar = "barValue" |
| 1868 | in.Foo = "fooValue" |
| 1869 | |
| 1870 | c.AbortWithStatusPureJSON(http.StatusUnsupportedMediaType, in) |
| 1871 | |
| 1872 | assert.Equal(t, abortIndex, c.index) |
| 1873 | assert.Equal(t, http.StatusUnsupportedMediaType, c.Writer.Status()) |
| 1874 | assert.Equal(t, http.StatusUnsupportedMediaType, w.Code) |
| 1875 | assert.True(t, c.IsAborted()) |
| 1876 | |
| 1877 | contentType := w.Header().Get("Content-Type") |
| 1878 | assert.Equal(t, "application/json; charset=utf-8", contentType) |
| 1879 | |
| 1880 | buf := new(bytes.Buffer) |
| 1881 | _, err := buf.ReadFrom(w.Body) |
| 1882 | require.NoError(t, err) |
| 1883 | jsonStringBody := buf.String() |
| 1884 | assert.JSONEq(t, "{\"foo\":\"fooValue\",\"bar\":\"barValue\"}", jsonStringBody) |
| 1885 | } |
| 1886 | |
| 1887 | func TestContextError(t *testing.T) { |
| 1888 | c, _ := CreateTestContext(httptest.NewRecorder()) |
nothing calls this directly
no test coverage detected