Documentation
¶
Overview ¶
Package recordingtest provides shared test helpers for exercising internal/recording's AttachRecorderHooks/ProtocolRecorder wiring through the production *protocolserver.ProtocolHandler entry points.
This is a plain (non-_test.go) package rather than an external recording_test file because its helpers must be importable both from internal/recording's own tests and from internal/server's e2e tests — Go test files, even in an external _test package, are never importable from another package. It lives under internal/protocolserver (not internal/recording) because it imports protocolserver: placed next to the package it drives, recording's production tree stays free of any protocolserver import. It adds no import cycle because protocolserver's production code never imports recordingtest.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type MemExporter ¶
type MemExporter struct {
// contains filtered or unexported fields
}
MemExporter captures Records emitted by the BatchProcessor for inspection. The mutex is mandatory: BatchProcessor exports on its own goroutine.
func NewRecordingTestHandler ¶
func NewRecordingTestHandler(t *testing.T, scenario typ.RuleScenario, mode obs.RecordMode) (*protocolserver.ProtocolHandler, *obs.Sink, *MemExporter)
NewRecordingTestHandler builds a *protocolserver.ProtocolHandler whose GetOrCreateScenarioSink callback always returns the same in-memory-backed sink for scenario, mirroring what root's *Server does via its scenarioRecordSinks map.
func (*MemExporter) Snapshot ¶
func (m *MemExporter) Snapshot() []*obs.Record
type StreamableRecorder ¶
type StreamableRecorder struct {
*httptest.ResponseRecorder
// contains filtered or unexported fields
}
StreamableRecorder adds CloseNotifier to httptest.ResponseRecorder so gin.Context.Stream (which ProcessStream calls) doesn't panic.
func NewRecordingTestContext ¶
NewRecordingTestContext builds a gin.Context wired to a StreamableRecorder, with a POST /v1/messages request carrying body as its JSON payload.
func NewStreamableRecorder ¶
func NewStreamableRecorder() *StreamableRecorder
func (*StreamableRecorder) CloseNotify ¶
func (s *StreamableRecorder) CloseNotify() <-chan bool