MCPcopy Create free account
hub / github.com/diillson/chatcli / TestPartialInputReader_FeedAfterClose

Function TestPartialInputReader_FeedAfterClose

llm/partial_input_test.go:80–89  ·  view source on GitHub ↗

TestPartialInputReader_FeedAfterClose is a no-op safety check: after Close, additional fragments are silently dropped rather than re-triggering emit. Prevents races where the SSE loop holds onto the reader past its lifetime.

(t *testing.T)

Source from the content-addressed store, hash-verified

78// re-triggering emit. Prevents races where the SSE loop holds onto
79// the reader past its lifetime.
80func TestPartialInputReader_FeedAfterClose(t *testing.T) {
81 r := NewPartialInputReader()
82 emits := 0
83 r.OnField = func(_ PartialInputField) { emits++ }
84
85 r.Feed(`{"q":"a"}`)
86 r.Close()
87 r.Feed(`{"q":"b","other":"c"}`)
88 assert.Equal(t, 1, emits, "post-Close Feeds are ignored")
89}
90
91// TestPartialInputReader_HonoursMaxBuffer guards against pathological
92// streams (a misbehaving provider sending megabytes of partial JSON).

Callers

nothing calls this directly

Calls 4

FeedMethod · 0.95
CloseMethod · 0.95
NewPartialInputReaderFunction · 0.85
EqualMethod · 0.80

Tested by

no test coverage detected