MCPcopy Create free account
hub / github.com/betta-tech/byo-coding-agent / TestSinkReceivesEventsInOrder

Function TestSinkReceivesEventsInOrder

internal/debug/debug_test.go:146–169  ·  view source on GitHub ↗

The sink is called once per Record while enabled, in order, with the fully-constructed Event.

(t *testing.T)

Source from the content-addressed store, hash-verified

144// The sink is called once per Record while enabled, in order, with the
145// fully-constructed Event.
146func TestSinkReceivesEventsInOrder(t *testing.T) {
147 debug.SetEnabled(true)
148 t.Cleanup(func() {
149 debug.SetEnabled(false)
150 debug.SetSink(nil)
151 })
152 debug.Clear()
153
154 var got []debug.Event
155 debug.SetSink(func(e debug.Event) { got = append(got, e) })
156
157 debug.Record("a", debug.LevelInfo, "first")
158 debug.Record("b", debug.LevelWarn, "second")
159
160 if len(got) != 2 {
161 t.Fatalf("sink got %d events, want 2", len(got))
162 }
163 if got[0].Message != "first" || got[1].Message != "second" {
164 t.Errorf("sink events out of order: %+v", got)
165 }
166 if got[0].Source != "a" || got[1].Source != "b" {
167 t.Errorf("sink dropped Source field: %+v", got)
168 }
169}
170
171// Latest walks back from the newest event to find one with a non-empty
172// payload, skipping payload-less events along the way.

Callers

nothing calls this directly

Calls 4

SetEnabledFunction · 0.92
SetSinkFunction · 0.92
ClearFunction · 0.92
RecordFunction · 0.92

Tested by

no test coverage detected