MCPcopy Create free account
hub / github.com/Facets-cloud/flow / TestCmdWorkdirScanFindsRepos

Function TestCmdWorkdirScanFindsRepos

internal/app/workdir_test.go:151–185  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

149}
150
151func TestCmdWorkdirScanFindsRepos(t *testing.T) {
152 setupArchiveTestEnv(t)
153 // Layout:
154 // scanRoot/
155 // a/.git/config (depth 1)
156 // b/c/.git/config (depth 2)
157 // d/e/f/.git/config (depth 3)
158 // g/h/i/j/.git/config (depth 4 — should NOT be found)
159 scanRoot := t.TempDir()
160 paths := map[string]int{
161 filepath.Join(scanRoot, "a"): 1,
162 filepath.Join(scanRoot, "b", "c"): 2,
163 filepath.Join(scanRoot, "d", "e", "f"): 3,
164 filepath.Join(scanRoot, "g", "h", "i", "j"): 4,
165 }
166 for p := range paths {
167 writeFakeGitConfig(t, p, "git@github.com:x/"+filepath.Base(p)+".git")
168 }
169
170 found, err := scanForGitRepos(scanRoot, 3)
171 if err != nil {
172 t.Fatalf("scan: %v", err)
173 }
174 foundSet := map[string]bool{}
175 for _, p := range found {
176 foundSet[p] = true
177 }
178 for p, depth := range paths {
179 want := depth <= 3
180 got := foundSet[p]
181 if want != got {
182 t.Errorf("path %s (depth %d): want found=%v, got found=%v", p, depth, want, got)
183 }
184 }
185}
186
187func TestCmdWorkdirScanNoAdd(t *testing.T) {
188 setupArchiveTestEnv(t)

Callers

nothing calls this directly

Calls 3

setupArchiveTestEnvFunction · 0.85
writeFakeGitConfigFunction · 0.85
scanForGitReposFunction · 0.85

Tested by

no test coverage detected