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

Function TestSyntaxFooterRules

test/syntax_sections_test.go:54–92  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

52}
53
54func TestSyntaxFooterRules(t *testing.T) {
55 conf := config.NewDefault()
56 conf.Rules = []string{"footer-enum", "footer-type-enum", "signed-off-by", "trailer-exists"}
57 conf.Settings["footer-enum"] = lint.RuleSetting{
58 Argument: []string{"Signed-off-by", "Refs", "Trace"},
59 }
60 conf.Settings["footer-type-enum"] = lint.RuleSetting{
61 Argument: []interface{}{
62 map[interface{}]interface{}{
63 "token": "Refs",
64 "types": []string{"feat"},
65 "values": []string{"#"},
66 },
67 },
68 }
69 conf.Settings["trailer-exists"] = lint.RuleSetting{Argument: "Trace"}
70 linter, err := config.NewLinter(conf)
71 if err != nil {
72 t.Fatal(err)
73 }
74
75 passMsg := "feat: expose records\n\nTrace: ok\nSigned-off-by: Sam\nRefs: #9"
76 res, err := linter.ParseAndLint(passMsg)
77 if err != nil {
78 t.Fatal(err)
79 }
80 if len(res.Issues()) != 0 {
81 t.Fatalf("unexpected issues: %v", res.Issues())
82 }
83
84 failMsg := "feat: expose records\n\nUnknown: x\nRefs: bad"
85 res, err = linter.ParseAndLint(failMsg)
86 if err != nil {
87 t.Fatal(err)
88 }
89 if len(res.Issues()) != 4 {
90 t.Fatalf("got %d issues, want 4: %v", len(res.Issues()), res.Issues())
91 }
92}

Callers

nothing calls this directly

Calls 4

ParseAndLintMethod · 0.95
NewDefaultFunction · 0.92
NewLinterFunction · 0.92
IssuesMethod · 0.80

Tested by

no test coverage detected