| 270 | } |
| 271 | |
| 272 | func TestConfig_Parse_WithIgnores(t *testing.T) { |
| 273 | tmpDir := t.TempDir() |
| 274 | confPath := filepath.Join(tmpDir, "commitlint.yaml") |
| 275 | |
| 276 | confContent := `min-version: v0.9.0 |
| 277 | formatter: default |
| 278 | rules: |
| 279 | - header-min-length |
| 280 | severity: |
| 281 | default: error |
| 282 | settings: |
| 283 | header-min-length: |
| 284 | argument: 10 |
| 285 | ignores: |
| 286 | - "^WIP " |
| 287 | - "^TICKET-\\d+" |
| 288 | ` |
| 289 | err := os.WriteFile(confPath, []byte(confContent), 0o644) |
| 290 | if err != nil { |
| 291 | t.Fatalf("failed to write config file: %v", err) |
| 292 | } |
| 293 | |
| 294 | conf, err := config.Parse(confPath) |
| 295 | if err != nil { |
| 296 | t.Fatalf("unexpected error: %v", err) |
| 297 | } |
| 298 | |
| 299 | if len(conf.IgnorePatterns) != 2 { |
| 300 | t.Errorf("expected 2 ignore patterns, got %d", len(conf.IgnorePatterns)) |
| 301 | } |
| 302 | } |
| 303 | |
| 304 | func TestConfig_Parse_WithoutIgnores_UsesDefaults(t *testing.T) { |
| 305 | tmpDir := t.TempDir() |