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

Function TestPartialInputReader_HonoursMaxBuffer

llm/partial_input_test.go:94–109  ·  view source on GitHub ↗

TestPartialInputReader_HonoursMaxBuffer guards against pathological streams (a misbehaving provider sending megabytes of partial JSON). We refuse to grow past the configured cap.

(t *testing.T)

Source from the content-addressed store, hash-verified

92// streams (a misbehaving provider sending megabytes of partial JSON).
93// We refuse to grow past the configured cap.
94func TestPartialInputReader_HonoursMaxBuffer(t *testing.T) {
95 // Cap chosen to fit the first object but reject the second.
96 r := NewPartialInputReader().WithMaxBuffer(20)
97 emits := 0
98 r.OnField = func(_ PartialInputField) { emits++ }
99
100 // 12 bytes — fits.
101 r.Feed(`{"k":"abc"}`)
102 // Push past the cap with a long second object.
103 for i := 0; i < 100; i++ {
104 r.Feed("xxxx")
105 }
106 // First object emits; subsequent oversized feeds are refused.
107 assert.Equal(t, 1, emits)
108 assert.LessOrEqual(t, len(r.Snapshot()), 20)
109}
110
111// TestPartialInputReader_FedConcurrentlyDoesNotRace exercises the
112// mutex under a small fan-in scenario. We don't expect concurrent

Callers

nothing calls this directly

Calls 5

NewPartialInputReaderFunction · 0.85
WithMaxBufferMethod · 0.80
FeedMethod · 0.80
EqualMethod · 0.80
SnapshotMethod · 0.45

Tested by

no test coverage detected