MCPcopy
hub / github.com/gin-gonic/gin / TestContextStreamWithClientGone

Function TestContextStreamWithClientGone

context_test.go:3036–3052  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

3034}
3035
3036func TestContextStreamWithClientGone(t *testing.T) {
3037 w := CreateTestResponseRecorder()
3038 c, _ := CreateTestContext(w)
3039
3040 c.Stream(func(writer io.Writer) bool {
3041 defer func() {
3042 w.closeClient()
3043 }()
3044
3045 _, err := writer.Write([]byte("test"))
3046 require.NoError(t, err)
3047
3048 return true
3049 })
3050
3051 assert.Equal(t, "test", w.Body.String())
3052}
3053
3054func TestContextResetInHandler(t *testing.T) {
3055 w := CreateTestResponseRecorder()

Callers

nothing calls this directly

Calls 6

CreateTestContextFunction · 0.85
StreamMethod · 0.80
closeClientMethod · 0.80
StringMethod · 0.65
WriteMethod · 0.45

Tested by

no test coverage detected