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
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()

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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.

View File

@ -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)