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

Function TestPartialInputReader_EmitsCompleteFields

llm/partial_input_test.go:20–34  ·  view source on GitHub ↗

TestPartialInputReader_EmitsCompleteFields verifies the happy path: a JSON object built up across multiple Feed calls eventually parses cleanly and surfaces every top-level string field exactly once.

(t *testing.T)

Source from the content-addressed store, hash-verified

18// a JSON object built up across multiple Feed calls eventually parses
19// cleanly and surfaces every top-level string field exactly once.
20func TestPartialInputReader_EmitsCompleteFields(t *testing.T) {
21 r := NewPartialInputReader()
22 var emitted []PartialInputField
23 r.OnField = func(f PartialInputField) {
24 emitted = append(emitted, f)
25 }
26
27 r.Feed(`{"query":"golang errg`)
28 assert.Empty(t, emitted, "incomplete JSON must not emit yet")
29
30 r.Feed(`roup"}`)
31 require.Len(t, emitted, 1, "the closed string yields exactly one event")
32 assert.Equal(t, "query", emitted[0].Name)
33 assert.Equal(t, "golang errgroup", emitted[0].Value)
34}
35
36// TestPartialInputReader_DoesNotEmitTwice pins the dedup contract:
37// once a field has been surfaced, subsequent re-parses (because more

Callers

nothing calls this directly

Calls 4

FeedMethod · 0.95
NewPartialInputReaderFunction · 0.85
EqualMethod · 0.80
LenMethod · 0.45

Tested by

no test coverage detected