MCPcopy
hub / github.com/grafana/tempo / TestFindYamlFilesNonRecursive

Function TestFindYamlFilesNonRecursive

tools/chloggen/internal/chlog/entry_test.go:552–572  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

550}
551
552func TestFindYamlFilesNonRecursive(t *testing.T) {
553 dir := t.TempDir()
554
555 // Create a YAML file in the root dir
556 rootYAML, err := os.Create(filepath.Join(dir, "root.yaml")) //nolint:gosec
557 require.NoError(t, err)
558 defer rootYAML.Close()
559
560 // Create a subdirectory with a YAML file inside it
561 subdir := filepath.Join(dir, "nested")
562 require.NoError(t, os.Mkdir(subdir, 0o750))
563
564 nestedYML, err := os.Create(filepath.Join(subdir, "nested.yml")) //nolint:gosec
565 require.NoError(t, err)
566 defer nestedYML.Close()
567
568 files, err := findYamlFiles(dir)
569 require.NoError(t, err)
570 // Should only include files directly under dir, not nested ones
571 assert.ElementsMatch(t, []string{rootYAML.Name()}, files)
572}
573
574func writeEntry(t *testing.T, dir string, entry *Entry, ext string) {
575 require.Contains(t, []string{"yaml", "yml"}, ext, "ext must be 'yaml' or 'yml'")

Callers

nothing calls this directly

Calls 4

findYamlFilesFunction · 0.85
JoinMethod · 0.65
CloseMethod · 0.65
NameMethod · 0.65

Tested by

no test coverage detected