MCPcopy Create free account
hub / github.com/conventionalcommit/commitlint / TestSyntaxLeadingBlankLines

Function TestSyntaxLeadingBlankLines

test/syntax_sections_test.go:11–40  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func 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
42func TestLeadingBlankRulesRejectMissingCRLFBlank(t *testing.T) {
43 _, validBody := (&rule.BodyLeadingBlankRule{}).Validate(&mockCommit{

Callers

nothing calls this directly

Calls 8

ParseAndLintMethod · 0.95
NewDefaultFunction · 0.92
NewLinterFunction · 0.92
IssuesMethod · 0.80
ErrorMethod · 0.80
RuleNameMethod · 0.80
InputMethod · 0.80
DescriptionMethod · 0.65

Tested by

no test coverage detected