parser/gotest: rename New/NewJSON -> NewParser/NewJSONParser

This commit is contained in:
Joël Stemmer 2022-04-04 23:54:04 +01:00
parent c289a62ec0
commit 7b21e70768
6 changed files with 13 additions and 13 deletions

View File

@ -80,9 +80,9 @@ func main() {
var parser Parser var parser Parser
switch *inputParser { switch *inputParser {
case "gotest": case "gotest":
parser = gotest.New(gotest.PackageName(*packageName)) parser = gotest.NewParser(gotest.PackageName(*packageName))
case "gojson": case "gojson":
parser = gotest.NewJSON(gotest.PackageName(*packageName)) parser = gotest.NewJSONParser(gotest.PackageName(*packageName))
default: default:
fmt.Fprintf(os.Stderr, "invalid parser: %s\n", *inputParser) fmt.Fprintf(os.Stderr, "invalid parser: %s\n", *inputParser)
flag.Usage() flag.Usage()

View File

@ -81,9 +81,9 @@ func testRun(inputFile, reportFile string, config TestConfig, t *testing.T) {
var parser Parser var parser Parser
if strings.HasSuffix(inputFile, ".gojson.txt") { if strings.HasSuffix(inputFile, ".gojson.txt") {
parser = gotest.NewJSON(options...) parser = gotest.NewJSONParser(options...)
} else { } else {
parser = gotest.New(options...) parser = gotest.NewParser(options...)
} }
report, err := parser.Parse(input) report, err := parser.Parse(input)

View File

@ -57,8 +57,8 @@ func TimestampFunc(f func() time.Time) Option {
} }
} }
// New returns a new Go test output parser. // NewParser returns a new Go test output parser.
func New(options ...Option) *Parser { func NewParser(options ...Option) *Parser {
p := &Parser{} p := &Parser{}
for _, option := range options { for _, option := range options {
option(p) option(p)

View File

@ -204,7 +204,7 @@ func TestParseLine(t *testing.T) {
name := fmt.Sprintf("%d %s", i+1, strings.Join(types, ",")) name := fmt.Sprintf("%d %s", i+1, strings.Join(types, ","))
t.Run(name, func(t *testing.T) { t.Run(name, func(t *testing.T) {
parser := New() parser := NewParser()
parser.parseLine(test.input) parser.parseLine(test.input)
got := parser.events got := parser.events
if diff := cmp.Diff(got, want); diff != "" { 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) actual := parser.report(events)
if diff := cmp.Diff(actual, expected); diff != "" { if diff := cmp.Diff(actual, expected); diff != "" {
t.Errorf("FromEvents report incorrect, diff (-want, +got):\n%v", diff) t.Errorf("FromEvents report incorrect, diff (-want, +got):\n%v", diff)

View File

@ -9,9 +9,9 @@ import (
"github.com/jstemmer/go-junit-report/v2/pkg/gtr" "github.com/jstemmer/go-junit-report/v2/pkg/gtr"
) )
// New returns a new Go test json output parser. // NewJSONParser returns a new Go test json output parser.
func NewJSON(options ...Option) *JSONParser { func NewJSONParser(options ...Option) *JSONParser {
return &JSONParser{gp: New(options...)} return &JSONParser{gp: NewParser(options...)}
} }
// Parser is a Go test json output Parser. // Parser is a Go test json output Parser.

View File

@ -113,9 +113,9 @@ func createReportFromInput(inputFile, outputFile string, write bool) error {
var parser Parser var parser Parser
if strings.HasSuffix(inputFile, ".gojson.txt") { if strings.HasSuffix(inputFile, ".gojson.txt") {
parser = gotest.NewJSON(options...) parser = gotest.NewJSONParser(options...)
} else { } else {
parser = gotest.New(options...) parser = gotest.NewParser(options...)
} }
report, err := parser.Parse(in) report, err := parser.Parse(in)