(t *testing.T)
| 7 | ) |
| 8 | |
| 9 | func 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 | } |
nothing calls this directly
no test coverage detected