MCPcopy Index your code
hub / github.com/keploy/keploy / newTestSession

Function newTestSession

pkg/agent/proxy/integrations/http/recordv2_test.go:80–102  ·  view source on GitHub ↗

newTestSession constructs a *supervisor.Session wired to fresh ClientStream/DestStream and a mocks channel. The session is ready to be passed to h.recordV2 directly — we skip the supervisor wrapper because the test exercises the parser logic, not the supervisor.

(t *testing.T)

Source from the content-addressed store, hash-verified

78// to be passed to h.recordV2 directly — we skip the supervisor wrapper
79// because the test exercises the parser logic, not the supervisor.
80func newTestSession(t *testing.T) (
81 sess *supervisor.Session,
82 sendReq func([]byte, time.Time, time.Time),
83 closeReq func(),
84 sendResp func([]byte, time.Time, time.Time),
85 closeResp func(),
86 mocks chan *models.Mock,
87) {
88 t.Helper()
89 client, sendReq, closeReq := makeStream(t, fakeconn.FromClient, 16)
90 dest, sendResp, closeResp := makeStream(t, fakeconn.FromDest, 16)
91 mocks = make(chan *models.Mock, 8)
92 sess = &supervisor.Session{
93 ClientStream: client,
94 DestStream: dest,
95 Mocks: mocks,
96 Logger: zaptest.NewLogger(t),
97 ClientConnID: "test-client-1",
98 DestConnID: "test-dest-1",
99 Ctx: context.Background(),
100 }
101 return sess, sendReq, closeReq, sendResp, closeResp, mocks
102}
103
104// TestRecordV2_HappyPath_ChunkTimestampsCarried pushes one request chunk
105// and one response chunk, then asserts the emitted mock's timestamps

Calls 1

makeStreamFunction · 0.85

Tested by

no test coverage detected