Skip to content

Commit

Permalink
Upgrade code to respect new conventions. (#111)
Browse files Browse the repository at this point in the history
  • Loading branch information
ccoVeille committed Apr 16, 2024
1 parent ba55829 commit 79399b4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
10 changes: 4 additions & 6 deletions parse/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,16 @@ func Process(r io.Reader, optionsFunc ...OptionsFunc) (*GoTestSummary, error) {

badLines++
if started || badLines > 50 {
switch err.(type) {
case *json.SyntaxError:
err = fmt.Errorf("line %d json error: %s: %w", badLines, err.Error(), ErrNotParseable)
var syntaxError *json.SyntaxError
if errors.As(err, &syntaxError) {
err = fmt.Errorf("line %d json error: %s: %w", badLines, syntaxError.Error(), ErrNotParseable)
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.
fmt.Fprintf(os.Stderr, "debug: %s", err.Error())
}
return nil, err
default:
return nil, err
}
return nil, err
}
if option.follow && option.w != nil {
fmt.Fprintf(option.w, "%s\n", sc.Bytes())
Expand Down
6 changes: 3 additions & 3 deletions tests/follow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package parsetest
import (
"bytes"
"errors"
"io/ioutil"
"os"
"path/filepath"
"testing"

Expand Down Expand Up @@ -46,7 +46,7 @@ func TestFollow(t *testing.T) {
}
check.Number(t, gotExitCode, tc.exitCode)
goldenFile := filepath.Join(base, tc.fileName+".golden")
want, err := ioutil.ReadFile(goldenFile)
want, err := os.ReadFile(goldenFile)
if err != nil {
t.Fatal(err)
}
Expand All @@ -56,7 +56,7 @@ func TestFollow(t *testing.T) {
"tests/"+goldenFile+".FAIL",
"tests/"+intputFile+".FAIL",
)
if err := ioutil.WriteFile(goldenFile+".FAIL", buf.Bytes(), 0644); err != nil {
if err := os.WriteFile(goldenFile+".FAIL", buf.Bytes(), 0644); err != nil {
t.Fatal(err)
}
}
Expand Down

0 comments on commit 79399b4

Please sign in to comment.