(t *testing.T)
| 722 | } |
| 723 | |
| 724 | func 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 | |
| 756 | func TestDepsDetectLanguage(t *testing.T) { |
| 757 | tests := []struct { |
nothing calls this directly
no test coverage detected