TestNestedJSONUsesFreshDelayedWriter guards the nested c.JSON case: a serializer that calls c.JSON re-entrantly must not corrupt the outer delayedStatusWriter (regression test for c.dsw self-reference).
(t *testing.T)
| 43 | // TestNestedJSONUsesFreshDelayedWriter guards the nested c.JSON case: a serializer that calls c.JSON |
| 44 | // re-entrantly must not corrupt the outer delayedStatusWriter (regression test for c.dsw self-reference). |
| 45 | func TestNestedJSONUsesFreshDelayedWriter(t *testing.T) { |
| 46 | e := New() |
| 47 | e.JSONSerializer = nestedJSONSerializer{} |
| 48 | rec := httptest.NewRecorder() |
| 49 | c := e.NewContext(httptest.NewRequest(http.MethodGet, "/", nil), rec) |
| 50 | assert.NoError(t, c.JSON(http.StatusOK, map[string]int{"outer": 1})) |
| 51 | assert.Equal(t, http.StatusOK, rec.Code) |
| 52 | } |
| 53 | |
| 54 | type nestedJSONSerializer struct{} |
| 55 |
nothing calls this directly
no test coverage detected
searching dependent graphs…