MCPcopy Create free account
hub / github.com/compozy/agh / TestDecodeSSEPreservesMultiLineData

Function TestDecodeSSEPreservesMultiLineData

internal/cli/client_test.go:3195–3217  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

3193}
3194
3195func TestDecodeSSEPreservesMultiLineData(t *testing.T) {
3196 t.Parallel()
3197
3198 body := strings.Join([]string{
3199 "id: 1",
3200 "event: message",
3201 `data: {"first":true}`,
3202 `data: {"second":true}`,
3203 "",
3204 }, "\n")
3205
3206 var seen SSEEvent
3207 err := decodeSSE(context.Background(), io.NopCloser(strings.NewReader(body)), func(event SSEEvent) error {
3208 seen = event
3209 return nil
3210 })
3211 if err != nil {
3212 t.Fatalf("decodeSSE() error = %v", err)
3213 }
3214 if got, want := string(seen.Data), "{\"first\":true}\n{\"second\":true}"; got != want {
3215 t.Fatalf("decodeSSE() data = %q, want %q", got, want)
3216 }
3217}
3218
3219func newHTTPResponse(status int, body string) *http.Response {
3220 return &http.Response{

Callers

nothing calls this directly

Calls 1

decodeSSEFunction · 0.85

Tested by

no test coverage detected