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

Function TestFileExistsF

pkg/platform/yaml/codec_test.go:469–498  ·  view source on GitHub ↗

TestFileExistsF tests format-aware file existence check.

(t *testing.T)

Source from the content-addressed store, hash-verified

467
468// TestFileExistsF tests format-aware file existence check.
469func TestFileExistsF(t *testing.T) {
470 tempDir, err := os.MkdirTemp("", "fileexists_test")
471 if err != nil {
472 t.Fatal(err)
473 }
474 defer os.RemoveAll(tempDir)
475 logger := testLogger()
476
477 // Create a .json file
478 if err := os.WriteFile(filepath.Join(tempDir, "test.json"), []byte("{}"), 0644); err != nil {
479 t.Fatal(err)
480 }
481
482 ctx := context.Background()
483 exists, err := FileExistsF(ctx, logger, tempDir, "test", FormatJSON)
484 if err != nil {
485 t.Fatal(err)
486 }
487 if !exists {
488 t.Error("expected test.json to exist")
489 }
490
491 exists, err = FileExistsF(ctx, logger, tempDir, "test", FormatYAML)
492 if err != nil {
493 t.Fatal(err)
494 }
495 if exists {
496 t.Error("expected test.yaml to NOT exist")
497 }
498}
499
500// TestReadFileAnyPrefersPreferred verifies ReadFileAny picks the preferred
501// format when both files exist.

Callers

nothing calls this directly

Calls 3

FileExistsFFunction · 0.85
testLoggerFunction · 0.70
ErrorMethod · 0.45

Tested by

no test coverage detected