MCPcopy Index your code
hub / github.com/conventionalcommit/commitlint / TestIgnore_CustomPatternsAdditive

Function TestIgnore_CustomPatternsAdditive

test/ignore_test.go:190–229  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

188}
189
190func TestIgnore_CustomPatternsAdditive(t *testing.T) {
191 conf := config.NewDefault()
192 conf.IgnorePatterns = []string{`^CUSTOM-\d+`, `^WIP `}
193
194 rules, err := config.GetEnabledRules(conf)
195 if err != nil {
196 t.Fatalf("unexpected error: %v", err)
197 }
198 linter, err := lint.New(conf, rules)
199 if err != nil {
200 t.Fatalf("unexpected error: %v", err)
201 }
202
203 // Custom pattern matches
204 result, err := linter.ParseAndLint("CUSTOM-123 some ticket work")
205 if err != nil {
206 t.Fatalf("unexpected error: %v", err)
207 }
208 if len(result.Issues()) != 0 {
209 t.Errorf("expected custom pattern to be ignored, got %d issues", len(result.Issues()))
210 }
211
212 // WIP matches
213 result, err = linter.ParseAndLint("WIP adding new feature")
214 if err != nil {
215 t.Fatalf("unexpected error: %v", err)
216 }
217 if len(result.Issues()) != 0 {
218 t.Errorf("expected WIP to be ignored, got %d issues", len(result.Issues()))
219 }
220
221 // Default merge pattern STILL present (additive), should be ignored
222 result, err = linter.ParseAndLint("Merge pull request #123 from owner/branch")
223 if err != nil {
224 t.Fatalf("unexpected error: %v", err)
225 }
226 if len(result.Issues()) != 0 {
227 t.Error("merge should be ignored - user patterns are additive to defaults")
228 }
229}
230
231func TestIgnore_CustomPatternsOnlyWhenDefaultsDisabled(t *testing.T) {
232 conf := config.NewDefault()

Callers

nothing calls this directly

Calls 6

NewDefaultFunction · 0.92
GetEnabledRulesFunction · 0.92
NewFunction · 0.92
ParseAndLintMethod · 0.80
IssuesMethod · 0.80
ErrorMethod · 0.80

Tested by

no test coverage detected