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

Function TestPartialInputReader_DoesNotEmitTwice

llm/partial_input_test.go:39–50  ·  view source on GitHub ↗

TestPartialInputReader_DoesNotEmitTwice pins the dedup contract: once a field has been surfaced, subsequent re-parses (because more fragments arrived) must not re-emit it.

(t *testing.T)

Source from the content-addressed store, hash-verified

37// once a field has been surfaced, subsequent re-parses (because more
38// fragments arrived) must not re-emit it.
39func TestPartialInputReader_DoesNotEmitTwice(t *testing.T) {
40 r := NewPartialInputReader()
41 emits := 0
42 r.OnField = func(_ PartialInputField) { emits++ }
43
44 r.Feed(`{"url":"https://example.com"}`)
45 r.Feed("") // no-op
46 r.Feed(`{"url":"https://example.com","extra":1}`)
47 // The reader resets on each Feed by re-parsing the full buffer
48 // — but the emitted map ensures one fire per field.
49 assert.Equal(t, 1, emits, "the same field never re-emits")
50}
51
52// TestPartialInputReader_MultipleStringFields covers the common shape
53// produced by @coder exec: cmd + cwd in one envelope.

Callers

nothing calls this directly

Calls 3

FeedMethod · 0.95
NewPartialInputReaderFunction · 0.85
EqualMethod · 0.80

Tested by

no test coverage detected