@@ -69,9 +69,32 @@ var pkgs = &PackageList{
69
69
ImportPath : "github.com/test/repo/unique/unique_vendor_one" ,
70
70
Imports : []string {},
71
71
},
72
+
73
+ // simulate a package that is not brought in through any of the repo entrypoints
74
+ // ("github.com/test/repo/root" in this case) but exists in the codebase
75
+ // because another package that is part of its repo is a transitive dependency
76
+ // of one of the main repo's entrypoints.
77
+ {
78
+ Dir : "/path/to/github.com/test/repo/unique/unique_vendor_two" ,
79
+ ImportPath : "github.com/test/repo/unique/unique_vendor_two" ,
80
+ Imports : []string {
81
+ "github.com/test/repo/no/node/should/exist/for/this/pkg" ,
82
+ },
83
+ },
72
84
},
73
85
}
74
86
87
+ // pkgsWithNoNodes is a map containing importPaths for packages
88
+ // that are not expected to have a node in the dependency graph
89
+ var pkgsWithNoNodes = map [string ]bool {
90
+ "github.com/test/repo/no/node/should/exist/for/this/pkg" : true ,
91
+ }
92
+
93
+ func shouldHaveNode (name string ) bool {
94
+ _ , exists := pkgsWithNoNodes [name ]
95
+ return ! exists
96
+ }
97
+
75
98
func TestBuildGraphCreatesExpectedNodesAndEdges (t * testing.T ) {
76
99
invalidImports := map [string ]bool {
77
100
"fmt" : true ,
@@ -98,8 +121,16 @@ func TestBuildGraphCreatesExpectedNodesAndEdges(t *testing.T) {
98
121
}
99
122
100
123
to , exists := g .NodeByName (dep )
124
+ if ! shouldHaveNode (dep ) {
125
+ if exists {
126
+ t .Fatalf ("expected node with name %q to not exist" , dep )
127
+ }
128
+
129
+ continue
130
+ }
131
+
101
132
if ! exists || ! g .Has (to ) {
102
- t .Fatalf ("expected node with name " )
133
+ t .Fatalf ("expected node with name %q to exist" , dep )
103
134
}
104
135
105
136
if ! g .HasEdgeFromTo (from , to ) {
0 commit comments