MCPcopy Create free account
hub / github.com/danielmiessler/Fabric / TestScanFilesSkipsDirectories

Function TestScanFilesSkipsDirectories

cmd/code2context/code_test.go:52–74  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

50}
51
52func TestScanFilesSkipsDirectories(t *testing.T) {
53 tmpDir := t.TempDir()
54
55 file1 := filepath.Join(tmpDir, "test.go")
56 subDir := filepath.Join(tmpDir, "subdir")
57
58 require.NoError(t, os.WriteFile(file1, []byte("package main\n"), 0644))
59 require.NoError(t, os.MkdirAll(subDir, 0755))
60
61 // Include a directory in the file list - should be skipped
62 files := []string{file1, subDir}
63
64 jsonData, err := ScanFiles(files, "test")
65 require.NoError(t, err)
66
67 var result []any
68 err = json.Unmarshal(jsonData, &result)
69 require.NoError(t, err)
70
71 // Check that only 1 file was counted (directory was skipped)
72 report := result[1].(map[string]any)
73 assert.Equal(t, float64(1), report["files"])
74}
75
76func TestScanFilesNonExistentFile(t *testing.T) {
77 files := []string{"/nonexistent/file.go"}

Callers

nothing calls this directly

Calls 1

ScanFilesFunction · 0.85

Tested by

no test coverage detected