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

Function TestDepsFileGraphHubAndConnectedFiles

scanner/deps_test.go:724–754  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

722}
723
724func TestDepsFileGraphHubAndConnectedFiles(t *testing.T) {
725 fg := &FileGraph{
726 Imports: map[string][]string{
727 "a.go": {"hub.go", "c.go"},
728 "b.go": {"hub.go"},
729 },
730 Importers: map[string][]string{
731 "hub.go": {"a.go", "b.go", "d.go"},
732 "a.go": {"x.go"},
733 },
734 }
735
736 if !fg.IsHub("hub.go") {
737 t.Fatal("expected hub.go to be treated as hub")
738 }
739 if fg.IsHub("a.go") {
740 t.Fatal("did not expect a.go to be treated as hub")
741 }
742
743 hubs := fg.HubFiles()
744 if len(hubs) != 1 || hubs[0] != "hub.go" {
745 t.Fatalf("expected only hub.go as hub, got %v", hubs)
746 }
747
748 connected := fg.ConnectedFiles("a.go")
749 sort.Strings(connected)
750 want := []string{"c.go", "hub.go", "x.go"}
751 if !reflect.DeepEqual(connected, want) {
752 t.Fatalf("expected connected files %v, got %v", want, connected)
753 }
754}
755
756func TestDepsDetectLanguage(t *testing.T) {
757 tests := []struct {

Callers

nothing calls this directly

Calls 3

IsHubMethod · 0.95
HubFilesMethod · 0.95
ConnectedFilesMethod · 0.95

Tested by

no test coverage detected