| 41 | } |
| 42 | |
| 43 | func 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 | |
| 63 | func TestSyntaxAdapterWithoutNotes(t *testing.T) { |
| 64 | c, err := commit.NewParser().Parse("feat: expose records\n") |