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

Function TestConfig_Parse_ValidFile

test/config_test.go:202–240  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

200}
201
202func TestConfig_Parse_ValidFile(t *testing.T) {
203 tmpDir := t.TempDir()
204 confPath := filepath.Join(tmpDir, "commitlint.yaml")
205
206 confContent := `min-version: v0.9.0
207formatter: default
208rules:
209 - header-min-length
210 - header-max-length
211 - type-enum
212severity:
213 default: error
214settings:
215 header-min-length:
216 argument: 10
217 header-max-length:
218 argument: 50
219 type-enum:
220 argument:
221 - feat
222 - fix
223`
224 err := os.WriteFile(confPath, []byte(confContent), 0o644)
225 if err != nil {
226 t.Fatalf("failed to write config file: %v", err)
227 }
228
229 conf, err := config.Parse(confPath)
230 if err != nil {
231 t.Fatalf("unexpected error: %v", err)
232 }
233
234 if conf.Formatter != "default" {
235 t.Errorf("expected formatter 'default', got %q", conf.Formatter)
236 }
237 if len(conf.Rules) != 3 {
238 t.Errorf("expected 3 rules, got %d", len(conf.Rules))
239 }
240}
241
242func TestConfig_Parse_OldVersionKey(t *testing.T) {
243 tmpDir := t.TempDir()

Callers

nothing calls this directly

Calls 1

ParseFunction · 0.92

Tested by

no test coverage detected