(t *testing.T)
| 188 | } |
| 189 | |
| 190 | func 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 | |
| 231 | func TestIgnore_CustomPatternsOnlyWhenDefaultsDisabled(t *testing.T) { |
| 232 | conf := config.NewDefault() |
nothing calls this directly
no test coverage detected