Skip to content

Commit

Permalink
Fix typo in exported sentinel Error
Browse files Browse the repository at this point in the history
This change could lead to errors in code that may be using tparse as a lib.
  • Loading branch information
ccoVeille committed Apr 13, 2024
1 parent bd8156e commit cbe1d06
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func main() {
exitCode, err := app.Run(os.Stdout, options)
if err != nil {
msg := err.Error()
if errors.Is(err, parse.ErrNotParseable) {
if errors.Is(err, parse.ErrNotParsable) {
msg = "no parsable events: Make sure to run go test with -json flag"
}
fmt.Fprintln(os.Stderr, msg)
Expand Down
8 changes: 4 additions & 4 deletions parse/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
"strings"
)

// ErrNotParseable indicates the event line was not parsable.
var ErrNotParseable = errors.New("failed to parse")
// ErrNotParsable indicates the event line was not parsable.
var ErrNotParsable = errors.New("failed to parse")

// Process is the entry point to parse. It consumes a reader
// and parses go test output in JSON format until EOF.
Expand Down Expand Up @@ -45,7 +45,7 @@ func Process(r io.Reader, optionsFunc ...OptionsFunc) (*GoTestSummary, error) {
if started || badLines > 50 {
switch err.(type) {
case *json.SyntaxError:
err = fmt.Errorf("line %d JSON error: %s: %w", badLines, err.Error(), ErrNotParseable)
err = fmt.Errorf("line %d JSON error: %s: %w", badLines, err.Error(), ErrNotParsable)
if option.debug {
// In debug mode we can surface a more verbose error message which
// contains the current line number and exact JSON parsing error.
Expand Down Expand Up @@ -88,7 +88,7 @@ func Process(r io.Reader, optionsFunc ...OptionsFunc) (*GoTestSummary, error) {
}
// Entire input has been scanned and no go test JSON output was found.
if !started {
return nil, ErrNotParseable
return nil, ErrNotParsable
}

return summary, nil
Expand Down
2 changes: 1 addition & 1 deletion tests/follow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func TestFollow(t *testing.T) {
{"test_02", nil, 0},
{"test_03", nil, 0},
{"test_04", nil, 0},
{"test_05", parse.ErrNotParseable, 1},
{"test_05", parse.ErrNotParsable, 1},
// build failure in one package
{"test_06", nil, 2},
}
Expand Down
6 changes: 3 additions & 3 deletions tests/prescan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ func TestPrescan(t *testing.T) {
err error
}{
{"test_01.txt", "want <nil> err", nil},
{"test_02.txt", "want failure after reading >50 lines of non-parsable events", parse.ErrNotParseable},
{"test_02.txt", "want failure after reading >50 lines of non-parsable events", parse.ErrNotParsable},
// logic: unparsable event(s), good event(s), at least one event = fail.
// Once we get a good event, we expect only good events to follow until EOF.
{"test_03.txt", "want failure when stream contains a bad event(s) -> good event(s) -> bad event", parse.ErrNotParseable},
{"test_04.txt", "want failure reading <50 lines of non-parsable events", parse.ErrNotParseable},
{"test_03.txt", "want failure when stream contains a bad event(s) -> good event(s) -> bad event", parse.ErrNotParsable},
{"test_04.txt", "want failure reading <50 lines of non-parsable events", parse.ErrNotParsable},
}

for _, tc := range tt {
Expand Down

0 comments on commit cbe1d06

Please sign in to comment.