MCPcopy
hub / github.com/keploy/keploy / TestEncodeDocToYAMLStreaming

Function TestEncodeDocToYAMLStreaming

pkg/platform/yaml/codec_test.go:273–288  ·  view source on GitHub ↗

TestEncodeDocToYAMLStreaming verifies EncodeDocTo writes a single YAML document that re-parses cleanly.

(t *testing.T)

Source from the content-addressed store, hash-verified

271// TestEncodeDocToYAMLStreaming verifies EncodeDocTo writes a single YAML
272// document that re-parses cleanly.
273func TestEncodeDocToYAMLStreaming(t *testing.T) {
274 doc := buildHTTPDoc()
275
276 var buf bytes.Buffer
277 if err := EncodeDocTo(&buf, FormatYAML, doc); err != nil {
278 t.Fatalf("EncodeDocTo(YAML): %v", err)
279 }
280
281 var roundTrip NetworkTrafficDoc
282 if err := yamlLib.Unmarshal(buf.Bytes(), &roundTrip); err != nil {
283 t.Fatalf("yaml.Unmarshal of streamed output: %v", err)
284 }
285 if roundTrip.Name != "test-1" {
286 t.Errorf("name = %q", roundTrip.Name)
287 }
288}
289
290// TestMockReaderNDJSON tests reading NDJSON mock files.
291func TestMockReaderNDJSON(t *testing.T) {

Callers

nothing calls this directly

Calls 4

buildHTTPDocFunction · 0.85
EncodeDocToFunction · 0.85
UnmarshalMethod · 0.80
BytesMethod · 0.45

Tested by

no test coverage detected