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

Function TestDetectModule

scanner/filegraph_test.go:265–290  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

263}
264
265func TestDetectModule(t *testing.T) {
266 tests := []struct {
267 name string
268 content string
269 expected string
270 }{
271 {name: "module exists", content: "module github.com/example/project\n\ngo 1.22\n", expected: "github.com/example/project"},
272 {name: "module missing", content: "go 1.22\n", expected: ""},
273 }
274
275 for _, tt := range tests {
276 t.Run(tt.name, func(t *testing.T) {
277 root := t.TempDir()
278 if tt.content != "" {
279 if err := os.WriteFile(filepath.Join(root, "go.mod"), []byte(tt.content), 0o644); err != nil {
280 t.Fatal(err)
281 }
282 }
283
284 got := detectModule(root)
285 if got != tt.expected {
286 t.Errorf("detectModule() = %q, want %q", got, tt.expected)
287 }
288 })
289 }
290}
291
292func TestFileGraphHubAndConnectedFiles(t *testing.T) {
293 fg := &FileGraph{

Callers

nothing calls this directly

Calls 1

detectModuleFunction · 0.85

Tested by

no test coverage detected