MCPcopy
hub / github.com/keploy/keploy / happyParser

Function happyParser

pkg/agent/proxy/v2_integration_test.go:100–121  ·  view source on GitHub ↗

-------- Happy-path parser -------- happyParser reads one request chunk from ClientStream and one response chunk from DestStream, then emits a mock anchored to the chunk timestamps. Exits cleanly; supervisor should report StatusOK.

(_ context.Context, sess *supervisor.Session)

Source from the content-addressed store, hash-verified

98// response chunk from DestStream, then emits a mock anchored to the
99// chunk timestamps. Exits cleanly; supervisor should report StatusOK.
100func happyParser(_ context.Context, sess *supervisor.Session) error {
101 c, err := sess.ClientStream.ReadChunk()
102 if err != nil {
103 return err
104 }
105 r, err := sess.DestStream.ReadChunk()
106 if err != nil {
107 return err
108 }
109 mock := &models.Mock{
110 Name: "happy",
111 Spec: models.MockSpec{
112 ReqTimestampMock: c.ReadAt,
113 ResTimestampMock: r.WrittenAt,
114 Metadata: map[string]string{
115 "req": string(c.Bytes),
116 "resp": string(r.Bytes),
117 },
118 },
119 }
120 return sess.EmitMock(mock)
121}
122
123func TestV2_HappyPath_ChunkTimestampsCarried(t *testing.T) {
124 t.Parallel()

Callers

nothing calls this directly

Calls 2

ReadChunkMethod · 0.80
EmitMockMethod · 0.80

Tested by

no test coverage detected