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)
| 18 | // a JSON object built up across multiple Feed calls eventually parses |
| 19 | // cleanly and surfaces every top-level string field exactly once. |
| 20 | func 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 |
nothing calls this directly
no test coverage detected