(t *testing.T)
| 10 | ) |
| 11 | |
| 12 | func TestLintRecoveredIssues(t *testing.T) { |
| 13 | conf := config.NewDefault() |
| 14 | conf.Rules = []string{"type-enum", "body-leading-blank", "body-max-line-length", "header-trim"} |
| 15 | conf.Settings["body-max-line-length"] = lint.RuleSetting{Argument: 10} |
| 16 | conf.Severity.Default = lint.SeverityWarn |
| 17 | linter, err := config.NewLinter(conf) |
| 18 | if err != nil { |
| 19 | t.Fatal(err) |
| 20 | } |
| 21 | input := " unknown:expose records\n" + strings.Repeat("x", 11) |
| 22 | result, err := linter.ParseAndLint(input) |
| 23 | if err != nil { |
| 24 | t.Fatal(err) |
| 25 | } |
| 26 | want := []string{"parser", "parser", "parser", "type-enum", "body-leading-blank", "body-max-line-length", "header-trim"} |
| 27 | var rules []string |
| 28 | for _, issue := range result.Issues() { |
| 29 | rules = append(rules, issue.RuleName()) |
| 30 | severity := lint.SeverityWarn |
| 31 | if issue.RuleName() == "parser" { |
| 32 | severity = lint.SeverityError |
| 33 | } |
| 34 | if issue.Severity() != severity { |
| 35 | t.Fatalf("severity=%s for %s", issue.Severity(), issue.RuleName()) |
| 36 | } |
| 37 | } |
| 38 | if !reflect.DeepEqual(rules, want) || result.Input() != input { |
| 39 | t.Fatalf("rules=%v, want %v", rules, want) |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | func TestLintAmbiguousHeaderSkipsRules(t *testing.T) { |
| 44 | conf := config.NewDefault() |
nothing calls this directly
no test coverage detected