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

Function TestReadNextDocJSONRejectsYAMLFormat

pkg/platform/yaml/codec_test.go:756–785  ·  view source on GitHub ↗

TestReadNextDocJSONRejectsYAMLFormat verifies that ReadNextDocJSON is a programming-error guard — it must error when called on a YAML reader so callers can't accidentally skip the yaml path.

(t *testing.T)

Source from the content-addressed store, hash-verified

754// programming-error guard — it must error when called on a YAML reader so
755// callers can't accidentally skip the yaml path.
756func TestReadNextDocJSONRejectsYAMLFormat(t *testing.T) {
757 ctx := context.Background()
758 logger := testLogger()
759
760 tempDir, err := os.MkdirTemp("", "mockreader_yaml_reject")
761 if err != nil {
762 t.Fatal(err)
763 }
764 defer os.RemoveAll(tempDir)
765
766 // Write a valid YAML mocks file.
767 doc := buildHTTPDoc()
768 yamlBytes, err := yamlLib.Marshal(doc)
769 if err != nil {
770 t.Fatal(err)
771 }
772 if err := os.WriteFile(filepath.Join(tempDir, "mocks.yaml"), yamlBytes, 0644); err != nil {
773 t.Fatal(err)
774 }
775
776 reader, err := NewMockReaderF(ctx, logger, tempDir, "mocks", FormatYAML)
777 if err != nil {
778 t.Fatal(err)
779 }
780 defer reader.Close()
781
782 if _, err := reader.ReadNextDocJSON(); err == nil {
783 t.Fatal("expected error when ReadNextDocJSON is called on a YAML reader")
784 }
785}
786
787// TestReadSessionIndicesF tests format-aware file listing.
788func TestReadSessionIndicesF(t *testing.T) {

Callers

nothing calls this directly

Calls 6

buildHTTPDocFunction · 0.85
NewMockReaderFFunction · 0.85
MarshalMethod · 0.80
ReadNextDocJSONMethod · 0.80
testLoggerFunction · 0.70
CloseMethod · 0.65

Tested by

no test coverage detected