From cbe1d06b4863c3f8f8c8e9bd534c3cc8eec0e70d Mon Sep 17 00:00:00 2001 From: ccoVeille <3875889+ccoVeille@users.noreply.github.com> Date: Sat, 13 Apr 2024 16:47:58 +0200 Subject: [PATCH] Fix typo in exported sentinel Error This change could lead to errors in code that may be using tparse as a lib. --- main.go | 2 +- parse/process.go | 8 ++++---- tests/follow_test.go | 2 +- tests/prescan_test.go | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/main.go b/main.go index fa0dcf9..b843bc9 100644 --- a/main.go +++ b/main.go @@ -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) diff --git a/parse/process.go b/parse/process.go index 123b959..6a06772 100644 --- a/parse/process.go +++ b/parse/process.go @@ -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. @@ -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. @@ -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 diff --git a/tests/follow_test.go b/tests/follow_test.go index 2ba59a9..8d0c181 100644 --- a/tests/follow_test.go +++ b/tests/follow_test.go @@ -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}, } diff --git a/tests/prescan_test.go b/tests/prescan_test.go index b530d6c..55d0ef8 100644 --- a/tests/prescan_test.go +++ b/tests/prescan_test.go @@ -20,11 +20,11 @@ func TestPrescan(t *testing.T) { err error }{ {"test_01.txt", "want 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 {