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

Function TestSyntaxAdapterErrors

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

Source from the content-addressed store, hash-verified

41}
42
43func TestSyntaxAdapterErrors(t *testing.T) {
44 p := commit.NewParser()
45 for _, tt := range []struct {
46 input string
47 code syntax.ErrorCode
48 offset int
49 }{
50 {" feat: expose records", syntax.InvalidType, 0},
51 {"feat:expose records", syntax.InvalidSeparator, 5},
52 {"feat: expose records\nbody", syntax.InvalidSectionSeparator, 21},
53 {"feat: expose records\n\nRefs #9\nEmpty: ", syntax.InvalidFooterValue, 37},
54 } {
55 c, err := p.Parse(tt.input)
56 var pe *syntax.ParseError
57 if c != nil || !errors.As(err, &pe) || pe.Code != tt.code || pe.Offset != tt.offset {
58 t.Fatalf("input %q: result=%v error=%v", tt.input, c, err)
59 }
60 }
61}
62
63func TestSyntaxAdapterWithoutNotes(t *testing.T) {
64 c, err := commit.NewParser().Parse("feat: expose records\n")

Callers

nothing calls this directly

Calls 2

ParseMethod · 0.95
NewParserFunction · 0.92

Tested by

no test coverage detected