@@ -11,33 +11,43 @@ import (
11
11
12
12
func TestValidate (t * testing.T ) {
13
13
var (
14
+ run = func (p * Pass ) (interface {}, error ) {
15
+ return nil , nil
16
+ }
14
17
dependsOnSelf = & Analyzer {
15
18
Name : "dependsOnSelf" ,
16
19
Doc : "this analyzer depends on itself" ,
20
+ Run : run ,
17
21
}
18
22
inCycleA = & Analyzer {
19
23
Name : "inCycleA" ,
20
24
Doc : "this analyzer depends on inCycleB" ,
25
+ Run : run ,
21
26
}
22
27
inCycleB = & Analyzer {
23
28
Name : "inCycleB" ,
24
29
Doc : "this analyzer depends on inCycleA and notInCycleA" ,
30
+ Run : run ,
25
31
}
26
32
pointsToCycle = & Analyzer {
27
33
Name : "pointsToCycle" ,
28
34
Doc : "this analyzer depends on inCycleA" ,
35
+ Run : run ,
29
36
}
30
37
notInCycleA = & Analyzer {
31
38
Name : "notInCycleA" ,
32
39
Doc : "this analyzer depends on notInCycleB and notInCycleC" ,
40
+ Run : run ,
33
41
}
34
42
notInCycleB = & Analyzer {
35
43
Name : "notInCycleB" ,
36
44
Doc : "this analyzer depends on notInCycleC" ,
45
+ Run : run ,
37
46
}
38
47
notInCycleC = & Analyzer {
39
48
Name : "notInCycleC" ,
40
49
Doc : "this analyzer has no dependencies" ,
50
+ Run : run ,
41
51
}
42
52
)
43
53
@@ -116,3 +126,27 @@ func TestCycleInRequiresGraphErrorMessage(t *testing.T) {
116
126
t .Errorf ("error string %s does not contain expected substring %q" , errMsg , wantSubstring )
117
127
}
118
128
}
129
+
130
+ func TestValidateEmptyDoc (t * testing.T ) {
131
+ withoutDoc := & Analyzer {
132
+ Name : "withoutDoc" ,
133
+ Run : func (p * Pass ) (interface {}, error ) {
134
+ return nil , nil
135
+ },
136
+ }
137
+ err := Validate ([]* Analyzer {withoutDoc })
138
+ if err == nil || ! strings .Contains (err .Error (), "is undocumented" ) {
139
+ t .Errorf ("got unexpected error while validating analyzers withoutDoc: %v" , err )
140
+ }
141
+ }
142
+
143
+ func TestValidateNoRun (t * testing.T ) {
144
+ withoutRun := & Analyzer {
145
+ Name : "withoutRun" ,
146
+ Doc : "this analyzer has no Run" ,
147
+ }
148
+ err := Validate ([]* Analyzer {withoutRun })
149
+ if err == nil || ! strings .Contains (err .Error (), "has nil Run" ) {
150
+ t .Errorf ("got unexpected error while validating analyzers withoutRun: %v" , err )
151
+ }
152
+ }
0 commit comments