-------- 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)
| 98 | // response chunk from DestStream, then emits a mock anchored to the |
| 99 | // chunk timestamps. Exits cleanly; supervisor should report StatusOK. |
| 100 | func 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 | |
| 123 | func TestV2_HappyPath_ChunkTimestampsCarried(t *testing.T) { |
| 124 | t.Parallel() |