MCPcopy
hub / github.com/labstack/echo / TestNestedJSONUsesFreshDelayedWriter

Function TestNestedJSONUsesFreshDelayedWriter

dispatch_pool_test.go:45–52  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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).
45func 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
54type nestedJSONSerializer struct{}
55

Callers

nothing calls this directly

Calls 3

JSONMethod · 0.95
NewFunction · 0.85
NewContextMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…