From 7b21e707680bacefdc888ee636e47a45fc8bde9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=ABl=20Stemmer?= Date: Mon, 4 Apr 2022 23:54:04 +0100 Subject: [PATCH] parser/gotest: rename New/NewJSON -> NewParser/NewJSONParser --- go-junit-report.go | 4 ++-- go-junit-report_test.go | 4 ++-- pkg/parser/gotest/gotest.go | 4 ++-- pkg/parser/gotest/gotest_test.go | 4 ++-- pkg/parser/gotest/json.go | 6 +++--- testdata/generate-golden.go | 4 ++-- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/go-junit-report.go b/go-junit-report.go index 3121552..447fbed 100644 --- a/go-junit-report.go +++ b/go-junit-report.go @@ -80,9 +80,9 @@ func main() { var parser Parser switch *inputParser { case "gotest": - parser = gotest.New(gotest.PackageName(*packageName)) + parser = gotest.NewParser(gotest.PackageName(*packageName)) case "gojson": - parser = gotest.NewJSON(gotest.PackageName(*packageName)) + parser = gotest.NewJSONParser(gotest.PackageName(*packageName)) default: fmt.Fprintf(os.Stderr, "invalid parser: %s\n", *inputParser) flag.Usage() diff --git a/go-junit-report_test.go b/go-junit-report_test.go index f783eee..1de43ea 100644 --- a/go-junit-report_test.go +++ b/go-junit-report_test.go @@ -81,9 +81,9 @@ func testRun(inputFile, reportFile string, config TestConfig, t *testing.T) { var parser Parser if strings.HasSuffix(inputFile, ".gojson.txt") { - parser = gotest.NewJSON(options...) + parser = gotest.NewJSONParser(options...) } else { - parser = gotest.New(options...) + parser = gotest.NewParser(options...) } report, err := parser.Parse(input) diff --git a/pkg/parser/gotest/gotest.go b/pkg/parser/gotest/gotest.go index dd95f1e..447e544 100644 --- a/pkg/parser/gotest/gotest.go +++ b/pkg/parser/gotest/gotest.go @@ -57,8 +57,8 @@ func TimestampFunc(f func() time.Time) Option { } } -// New returns a new Go test output parser. -func New(options ...Option) *Parser { +// NewParser returns a new Go test output parser. +func NewParser(options ...Option) *Parser { p := &Parser{} for _, option := range options { option(p) diff --git a/pkg/parser/gotest/gotest_test.go b/pkg/parser/gotest/gotest_test.go index 3cdd684..1090816 100644 --- a/pkg/parser/gotest/gotest_test.go +++ b/pkg/parser/gotest/gotest_test.go @@ -204,7 +204,7 @@ func TestParseLine(t *testing.T) { name := fmt.Sprintf("%d %s", i+1, strings.Join(types, ",")) t.Run(name, func(t *testing.T) { - parser := New() + parser := NewParser() parser.parseLine(test.input) got := parser.events if diff := cmp.Diff(got, want); diff != "" { @@ -307,7 +307,7 @@ func TestReport(t *testing.T) { }, } - parser := New(TimestampFunc(func() time.Time { return testTimestamp })) + parser := NewParser(TimestampFunc(func() time.Time { return testTimestamp })) actual := parser.report(events) if diff := cmp.Diff(actual, expected); diff != "" { t.Errorf("FromEvents report incorrect, diff (-want, +got):\n%v", diff) diff --git a/pkg/parser/gotest/json.go b/pkg/parser/gotest/json.go index af166a3..df5ddb2 100644 --- a/pkg/parser/gotest/json.go +++ b/pkg/parser/gotest/json.go @@ -9,9 +9,9 @@ import ( "github.com/jstemmer/go-junit-report/v2/pkg/gtr" ) -// New returns a new Go test json output parser. -func NewJSON(options ...Option) *JSONParser { - return &JSONParser{gp: New(options...)} +// NewJSONParser returns a new Go test json output parser. +func NewJSONParser(options ...Option) *JSONParser { + return &JSONParser{gp: NewParser(options...)} } // Parser is a Go test json output Parser. diff --git a/testdata/generate-golden.go b/testdata/generate-golden.go index cf976ac..c7363a7 100644 --- a/testdata/generate-golden.go +++ b/testdata/generate-golden.go @@ -113,9 +113,9 @@ func createReportFromInput(inputFile, outputFile string, write bool) error { var parser Parser if strings.HasSuffix(inputFile, ".gojson.txt") { - parser = gotest.NewJSON(options...) + parser = gotest.NewJSONParser(options...) } else { - parser = gotest.New(options...) + parser = gotest.NewParser(options...) } report, err := parser.Parse(in)