mirror of
https://github.com/jstemmer/go-junit-report.git
synced 2025-04-05 05:00:15 -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
|
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()
|
||||||
|
@ -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)
|
||||||
|
@ -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)
|
||||||
|
@ -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)
|
||||||
|
@ -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.
|
||||||
|
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
|
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)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user