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

Function TestScanDirectory

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

Source from the content-addressed store, hash-verified

73}
74
75func TestScanDirectory(t *testing.T) {
76 tmpDir := t.TempDir()
77
78 file1 := filepath.Join(tmpDir, "main.go")
79 require.NoError(t, os.WriteFile(file1, []byte("package main\n"), 0644))
80
81 jsonData, err := ScanDirectory(tmpDir, 3, "Test instructions", []string{})
82 require.NoError(t, err)
83
84 var result []any
85 err = json.Unmarshal(jsonData, &result)
86 require.NoError(t, err)
87 assert.Len(t, result, 3)
88
89 instr := result[2].(map[string]any)
90 assert.Equal(t, "Test instructions", instr["details"])
91}
92
93// TestScanDirectory_SkipsSymlinks checks that ScanDirectory does not follow a
94// symlink to a file outside the project.

Callers

nothing calls this directly

Calls 1

ScanDirectoryFunction · 0.85

Tested by

no test coverage detected