Skip to content

Commit

Permalink
add test to lint the built in rules
Browse files Browse the repository at this point in the history
  • Loading branch information
Larry Hitchon committed Jul 16, 2018
1 parent a089dd1 commit 8a59f38
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions cli/app_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package main

import (
"github.com/stelligent/config-lint/assertion"
"github.com/stelligent/config-lint/linter"
"testing"
)

Expand Down Expand Up @@ -88,3 +90,45 @@ func TestProfileExceptions(t *testing.T) {
t.Errorf("Unexpected ResourceID found in Except: %s", id)
}
}

func TestBuiltInTerraformRules(t *testing.T) {
ruleSet, err := loadBuiltInRuleSet("assets/lint-rules.yml")
if err != nil {
t.Errorf("Expecting loadBuiltInRulesSet to not return error: %s", err.Error())
}
vs := assertion.StandardValueSource{}
filenames := []string{"assets/terraform.yml"}
l, err := linter.NewLinter(ruleSet, vs, filenames)
if err != nil {
t.Errorf("Expecting NewLinter to not return error: %s", err.Error())
}
options := linter.Options{}
report, err := l.Validate(ruleSet, options)
if err != nil {
t.Errorf("Expecting Validate to not return error: %s", err.Error())
}
if len(report.Violations) != 0 {
t.Errorf("Expecting Validate for built in rules to not report any violations: %v", report.Violations)
}
}

func TestBuiltInLinterRules(t *testing.T) {
ruleSet, err := loadBuiltInRuleSet("assets/lint-rules.yml")
if err != nil {
t.Errorf("Expecting loadBuiltInRulesSet to not return error: %s", err.Error())
}
vs := assertion.StandardValueSource{}
filenames := []string{"assets/lint-rules.yml"}
l, err := linter.NewLinter(ruleSet, vs, filenames)
if err != nil {
t.Errorf("Expecting NewLinter to not return error: %s", err.Error())
}
options := linter.Options{}
report, err := l.Validate(ruleSet, options)
if err != nil {
t.Errorf("Expecting Validate to not return error: %s", err.Error())
}
if len(report.Violations) != 0 {
t.Errorf("Expecting Validate for built in lint-rules to not report any violations: %v", report.Violations)
}
}

0 comments on commit 8a59f38

Please sign in to comment.