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

Function TestDecodeSSEStopsEarly

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

Source from the content-addressed store, hash-verified

3099}
3100
3101func TestDecodeSSEStopsEarly(t *testing.T) {
3102 t.Parallel()
3103
3104 body := strings.Join([]string{
3105 "id: 1",
3106 "event: done",
3107 `data: {"ok":true}`,
3108 "",
3109 "id: 2",
3110 "event: later",
3111 `data: {"ok":false}`,
3112 "",
3113 }, "\n")
3114
3115 count := 0
3116 err := decodeSSE(context.Background(), io.NopCloser(strings.NewReader(body)), func(event SSEEvent) error {
3117 count++
3118 if event.Event == "done" {
3119 return errStopSSE
3120 }
3121 return nil
3122 })
3123 if err != nil {
3124 t.Fatalf("decodeSSE() error = %v", err)
3125 }
3126 if count != 1 {
3127 t.Fatalf("decodeSSE() count = %d, want 1", count)
3128 }
3129}
3130
3131func TestDecodeSSERejectsNilArguments(t *testing.T) {
3132 t.Parallel()

Callers

nothing calls this directly

Calls 1

decodeSSEFunction · 0.85

Tested by

no test coverage detected