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)
| 754 | // programming-error guard — it must error when called on a YAML reader so |
| 755 | // callers can't accidentally skip the yaml path. |
| 756 | func 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. |
| 788 | func TestReadSessionIndicesF(t *testing.T) { |
nothing calls this directly
no test coverage detected