MCPcopy Create free account
hub / github.com/JordanCoin/codemap / TestScanForDepsRejectsNonAstGrepSg

Function TestScanForDepsRejectsNonAstGrepSg

scanner/astgrep_test.go:218–241  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

216}
217
218func TestScanForDepsRejectsNonAstGrepSg(t *testing.T) {
219 if runtime.GOOS == "windows" {
220 t.Skip("requires shell script execution")
221 }
222
223 tmpDir := t.TempDir()
224 fakeBinary := filepath.Join(tmpDir, "sg")
225 if err := os.WriteFile(fakeBinary, []byte("#!/bin/sh\necho 'setgroups utility' >&2\nexit 1\n"), 0755); err != nil {
226 t.Fatalf("failed to create fake sg binary: %v", err)
227 }
228
229 oldPath := os.Getenv("PATH")
230 if err := os.Setenv("PATH", tmpDir); err != nil {
231 t.Fatalf("failed to set PATH: %v", err)
232 }
233 t.Cleanup(func() {
234 _ = os.Setenv("PATH", oldPath)
235 })
236
237 _, err := ScanForDeps(t.TempDir())
238 if !errors.Is(err, ErrAstGrepNotFound) {
239 t.Fatalf("expected ErrAstGrepNotFound, got %v", err)
240 }
241}
242
243func TestBundledAstGrepCandidates(t *testing.T) {
244 tmpDir := t.TempDir()

Callers

nothing calls this directly

Calls 1

ScanForDepsFunction · 0.85

Tested by

no test coverage detected