(t *testing.T)
| 9 | ) |
| 10 | |
| 11 | func TestSyntaxLeadingBlankLines(t *testing.T) { |
| 12 | conf := config.NewDefault() |
| 13 | conf.Rules = []string{"body-leading-blank", "footer-leading-blank"} |
| 14 | linter, err := config.NewLinter(conf) |
| 15 | if err != nil { |
| 16 | t.Fatal(err) |
| 17 | } |
| 18 | for _, tt := range []struct{ name, line, blank string }{ |
| 19 | {"lf", "\n", "\n"}, |
| 20 | {"crlf", "\r\n", "\r\n"}, |
| 21 | {"lf then crlf", "\n", "\r\n"}, |
| 22 | {"crlf then lf", "\r\n", "\n"}, |
| 23 | } { |
| 24 | t.Run(tt.name, func(t *testing.T) { |
| 25 | input := "feat: expose records" + tt.line + tt.blank + "Body text." + tt.line + tt.blank + "Refs #9" + tt.line |
| 26 | result, err := linter.ParseAndLint(input) |
| 27 | if err != nil { |
| 28 | t.Fatal(err) |
| 29 | } |
| 30 | if len(result.Issues()) != 0 { |
| 31 | for _, issue := range result.Issues() { |
| 32 | t.Error(issue.RuleName(), issue.Description()) |
| 33 | } |
| 34 | } |
| 35 | if result.Input() != input { |
| 36 | t.Fatal("input changed") |
| 37 | } |
| 38 | }) |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | func TestLeadingBlankRulesRejectMissingCRLFBlank(t *testing.T) { |
| 43 | _, validBody := (&rule.BodyLeadingBlankRule{}).Validate(&mockCommit{ |
nothing calls this directly
no test coverage detected