| 240 | } |
| 241 | |
| 242 | func TestConfig_Parse_OldVersionKey(t *testing.T) { |
| 243 | tmpDir := t.TempDir() |
| 244 | confPath := filepath.Join(tmpDir, "commitlint.yaml") |
| 245 | |
| 246 | // Uses the old "version:" key for backward compatibility |
| 247 | confContent := `version: v0.9.0 |
| 248 | formatter: default |
| 249 | rules: |
| 250 | - header-min-length |
| 251 | severity: |
| 252 | default: error |
| 253 | settings: |
| 254 | header-min-length: |
| 255 | argument: 10 |
| 256 | ` |
| 257 | err := os.WriteFile(confPath, []byte(confContent), 0o644) |
| 258 | if err != nil { |
| 259 | t.Fatalf("failed to write config file: %v", err) |
| 260 | } |
| 261 | |
| 262 | conf, err := config.Parse(confPath) |
| 263 | if err != nil { |
| 264 | t.Fatalf("unexpected error parsing old 'version' key: %v", err) |
| 265 | } |
| 266 | |
| 267 | if conf.MinVersion != "v0.9.0" { |
| 268 | t.Errorf("expected MinVersion 'v0.9.0', got %q", conf.MinVersion) |
| 269 | } |
| 270 | } |
| 271 | |
| 272 | func TestConfig_Parse_WithIgnores(t *testing.T) { |
| 273 | tmpDir := t.TempDir() |