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

Function TestLint_RuleViolations

test/lint_test.go:142–165  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

140}
141
142func TestLint_RuleViolations(t *testing.T) {
143 linter := newDefaultLinter(t)
144 for _, tc := range ruleViolationCases {
145 t.Run(tc.name, func(t *testing.T) {
146 result, err := linter.ParseAndLint(tc.msg)
147 if err != nil {
148 t.Fatalf("unexpected error: %v", err)
149 }
150 found := false
151 for _, iss := range result.Issues() {
152 if iss.RuleName() == tc.wantRule {
153 found = true
154 break
155 }
156 }
157 if !found {
158 t.Errorf("expected rule %q in issues for %q", tc.wantRule, tc.msg)
159 for _, iss := range result.Issues() {
160 t.Logf(" got: [%s] %s: %s", iss.Severity(), iss.RuleName(), iss.Description())
161 }
162 }
163 })
164 }
165}
166
167// ---------------------------------------------------------------------------
168// Result preservation

Callers

nothing calls this directly

Calls 6

newDefaultLinterFunction · 0.85
ParseAndLintMethod · 0.80
IssuesMethod · 0.80
RuleNameMethod · 0.80
SeverityMethod · 0.80
DescriptionMethod · 0.65

Tested by

no test coverage detected