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

Function TestSyntaxInspectionAdapter

commit/parser_test.go:73–90  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

71}
72
73func TestSyntaxInspectionAdapter(t *testing.T) {
74 p := commit.NewParser()
75 input := "feat:expose records\nBody text."
76 c, diagnostics := commit.Inspect(input)
77 if c == nil || len(diagnostics) != 2 || c.Type() != "feat" || c.Body() != "Body text." {
78 t.Fatalf("result=%v diagnostics=%v", c, diagnostics)
79 }
80 var pe *syntax.ParseError
81 if !errors.As(diagnostics[0], &pe) || pe.Code != syntax.InvalidSeparator {
82 t.Fatal("typed diagnostic lost")
83 }
84 if strict, err := p.Parse(input); strict != nil || err == nil {
85 t.Fatal("strict parsing recovered invalid input")
86 }
87 if c, diagnostics := commit.Inspect("invalid header"); c != nil || len(diagnostics) != 1 {
88 t.Fatal("ambiguous header recovered")
89 }
90}
91
92func TestCommitHelpers(t *testing.T) {
93 parsed, err := commit.NewParser().Parse("feat!: drop v1\n\nBody text.\n\nBREAKING CHANGE: gone\nRefs #9")

Callers

nothing calls this directly

Calls 5

ParseMethod · 0.95
NewParserFunction · 0.92
InspectFunction · 0.92
TypeMethod · 0.65
BodyMethod · 0.65

Tested by

no test coverage detected