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

Function TestContextRenderSSE

context_test.go:1400–1415  ·  context_test.go::TestContextRenderSSE
(t *testing.T)

Source from the content-addressed store, hash-verified

1398}
1399
1400func TestContextRenderSSE(t *testing.T) {
1401 w := httptest.NewRecorder()
1402 c, _ := CreateTestContext(w)
1403
1404 c.SSEvent("float", 1.5)
1405 c.Render(-1, sse.Event{
1406 Id: "123",
1407 Data: "text",
1408 })
1409 c.SSEvent("chat", H{
1410 "foo": "bar",
1411 "bar": "foo",
1412 })
1413
1414 assert.Equal(t, strings.ReplaceAll(w.Body.String(), " ", ""), strings.ReplaceAll("event:float\ndata:1.5\n\nid:123\ndata:text\n\nevent:chat\ndata:{\"bar\":\"foo\",\"foo\":\"bar\"}\n\n", " ", ""))
1415}
1416
1417func TestContextRenderFile(t *testing.T) {
1418 w := httptest.NewRecorder()

Callers

nothing calls this directly

Calls 4

CreateTestContextFunction · 0.85
SSEventMethod · 0.80
RenderMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected