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

Function TestSyntaxBreakingIndicators

test/syntax_breaking_test.go:9–46  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

7)
8
9func TestSyntaxBreakingIndicators(t *testing.T) {
10 conf := config.NewDefault()
11 conf.Rules = []string{"breaking-change-exclamation-mark"}
12 linter, err := config.NewLinter(conf)
13 if err != nil {
14 t.Fatal(err)
15 }
16 for _, tt := range []struct {
17 name, input string
18 wantIssue bool
19 }{
20 {"neither", "feat: expose records", false},
21 {"header only", "feat!: expose records", true},
22 {"spaced footer only", "feat: expose records\n\nBREAKING CHANGE: remove key", true},
23 {"hyphenated footer only", "feat: expose records\n\nBREAKING-CHANGE: remove key", true},
24 {"both spaced", "feat!: expose records\n\nBREAKING CHANGE: remove key", false},
25 {"both hyphenated", "feat(store)!: expose records\n\nBREAKING-CHANGE: remove key", false},
26 {"description bang", "feat: retain ! in description", false},
27 {"description bang with footer", "feat: retain ! in description\n\nBREAKING CHANGE: remove key", true},
28 } {
29 t.Run(tt.name, func(t *testing.T) {
30 result, err := linter.ParseAndLint(tt.input)
31 if err != nil {
32 t.Fatal(err)
33 }
34 want := 0
35 if tt.wantIssue {
36 want = 1
37 }
38 if len(result.Issues()) != want {
39 t.Fatalf("issues=%v, want %d", result.Issues(), want)
40 }
41 if want != 0 && result.Issues()[0].RuleName() != "breaking-change-exclamation-mark" {
42 t.Fatalf("unexpected issue: %s", result.Issues()[0].RuleName())
43 }
44 })
45 }
46}

Callers

nothing calls this directly

Calls 5

ParseAndLintMethod · 0.95
NewDefaultFunction · 0.92
NewLinterFunction · 0.92
IssuesMethod · 0.80
RuleNameMethod · 0.80

Tested by

no test coverage detected