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

Function TestFileGraphHubAndConnectedFiles

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

Source from the content-addressed store, hash-verified

290}
291
292func TestFileGraphHubAndConnectedFiles(t *testing.T) {
293 fg := &FileGraph{
294 Imports: map[string][]string{
295 "a.go": {"b.go", "c.go"},
296 "d.go": {"a.go"},
297 },
298 Importers: map[string][]string{
299 "a.go": {"d.go"},
300 "b.go": {"a.go", "x.go", "y.go"},
301 "c.go": {"a.go"},
302 },
303 }
304
305 tests := []struct {
306 name string
307 path string
308 expected bool
309 }{
310 {name: "hub file", path: "b.go", expected: true},
311 {name: "non hub file", path: "a.go", expected: false},
312 }
313
314 for _, tt := range tests {
315 t.Run(tt.name, func(t *testing.T) {
316 got := fg.IsHub(tt.path)
317 if got != tt.expected {
318 t.Errorf("IsHub(%q) = %v, want %v", tt.path, got, tt.expected)
319 }
320 })
321 }
322
323 t.Run("hub files list", func(t *testing.T) {
324 got := fg.HubFiles()
325 sort.Strings(got)
326 want := []string{"b.go"}
327 if !reflect.DeepEqual(got, want) {
328 t.Errorf("HubFiles() = %v, want %v", got, want)
329 }
330 })
331
332 t.Run("connected files", func(t *testing.T) {
333 got := fg.ConnectedFiles("a.go")
334 sort.Strings(got)
335 want := []string{"b.go", "c.go", "d.go"}
336 if !reflect.DeepEqual(got, want) {
337 t.Errorf("ConnectedFiles() = %v, want %v", got, want)
338 }
339 })
340}
341
342func TestTryDirMatch(t *testing.T) {
343 files := []FileInfo{

Callers

nothing calls this directly

Calls 3

IsHubMethod · 0.95
HubFilesMethod · 0.95
ConnectedFilesMethod · 0.95

Tested by

no test coverage detected