Skip to content

Commit

Permalink
Fix test to expect parsing errors for testdata/*/bad_*.sql
Browse files Browse the repository at this point in the history
  • Loading branch information
makenowjust committed Dec 18, 2024
1 parent 68088ef commit 1150604
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"log"
"os"
"path/filepath"
"strings"
"testing"

"github.com/cloudspannerecosystem/memefish"
Expand Down Expand Up @@ -40,6 +41,7 @@ func testParser(t *testing.T, inputPath, resultPath string, parse func(p *memefi

for _, in := range inputs {
in := in
bad := strings.HasPrefix(in.Name(), "bad_")
t.Run(in.Name(), func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -68,9 +70,17 @@ func testParser(t *testing.T, inputPath, resultPath string, parse func(p *memefi
fmt.Fprintln(&buf)

if err != nil {
fmt.Fprintln(&buf, "--- Error")
fmt.Fprint(&buf, err)
fmt.Fprintln(&buf)
if bad {
fmt.Fprintln(&buf, "--- Error")
fmt.Fprint(&buf, err)
fmt.Fprintln(&buf)
} else {
t.Errorf("unexpected error: %v", err)
}
} else {
if bad {
t.Errorf("error is expected, but parsing succeeded")
}
}

fmt.Fprintf(&buf, "--- AST\n")
Expand Down

0 comments on commit 1150604

Please sign in to comment.