mirror of
https://github.com/jstemmer/go-junit-report.git
synced 2025-04-04 20:50:14 -05:00
parser/gotest: rename New/NewJSON -> NewParser/NewJSONParser
This commit is contained in:
parent
c289a62ec0
commit
7b21e70768
@ -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()
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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.
|
||||
|
4
testdata/generate-golden.go
vendored
4
testdata/generate-golden.go
vendored
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user