aboutsummaryrefslogtreecommitdiff
path: root/go/analysis/validate_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'go/analysis/validate_test.go')
-rw-r--r--go/analysis/validate_test.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/go/analysis/validate_test.go b/go/analysis/validate_test.go
index 1116034f7..7f4ee2c05 100644
--- a/go/analysis/validate_test.go
+++ b/go/analysis/validate_test.go
@@ -11,33 +11,43 @@ import (
func TestValidate(t *testing.T) {
var (
+ run = func(p *Pass) (interface{}, error) {
+ return nil, nil
+ }
dependsOnSelf = &Analyzer{
Name: "dependsOnSelf",
Doc: "this analyzer depends on itself",
+ Run: run,
}
inCycleA = &Analyzer{
Name: "inCycleA",
Doc: "this analyzer depends on inCycleB",
+ Run: run,
}
inCycleB = &Analyzer{
Name: "inCycleB",
Doc: "this analyzer depends on inCycleA and notInCycleA",
+ Run: run,
}
pointsToCycle = &Analyzer{
Name: "pointsToCycle",
Doc: "this analyzer depends on inCycleA",
+ Run: run,
}
notInCycleA = &Analyzer{
Name: "notInCycleA",
Doc: "this analyzer depends on notInCycleB and notInCycleC",
+ Run: run,
}
notInCycleB = &Analyzer{
Name: "notInCycleB",
Doc: "this analyzer depends on notInCycleC",
+ Run: run,
}
notInCycleC = &Analyzer{
Name: "notInCycleC",
Doc: "this analyzer has no dependencies",
+ Run: run,
}
)
@@ -116,3 +126,27 @@ func TestCycleInRequiresGraphErrorMessage(t *testing.T) {
t.Errorf("error string %s does not contain expected substring %q", errMsg, wantSubstring)
}
}
+
+func TestValidateEmptyDoc(t *testing.T) {
+ withoutDoc := &Analyzer{
+ Name: "withoutDoc",
+ Run: func(p *Pass) (interface{}, error) {
+ return nil, nil
+ },
+ }
+ err := Validate([]*Analyzer{withoutDoc})
+ if err == nil || !strings.Contains(err.Error(), "is undocumented") {
+ t.Errorf("got unexpected error while validating analyzers withoutDoc: %v", err)
+ }
+}
+
+func TestValidateNoRun(t *testing.T) {
+ withoutRun := &Analyzer{
+ Name: "withoutRun",
+ Doc: "this analyzer has no Run",
+ }
+ err := Validate([]*Analyzer{withoutRun})
+ if err == nil || !strings.Contains(err.Error(), "has nil Run") {
+ t.Errorf("got unexpected error while validating analyzers withoutRun: %v", err)
+ }
+}