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

Function TestContextStream

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

Source from the content-addressed store, hash-verified

3015}
3016
3017func TestContextStream(t *testing.T) {
3018 w := CreateTestResponseRecorder()
3019 c, _ := CreateTestContext(w)
3020
3021 stopStream := true
3022 c.Stream(func(w io.Writer) bool {
3023 defer func() {
3024 stopStream = false
3025 }()
3026
3027 _, err := w.Write([]byte("test"))
3028 require.NoError(t, err)
3029
3030 return stopStream
3031 })
3032
3033 assert.Equal(t, "testtest", w.Body.String())
3034}
3035
3036func TestContextStreamWithClientGone(t *testing.T) {
3037 w := CreateTestResponseRecorder()

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected