Add test for reports without properties

This commit is contained in:
Joël Stemmer
2022-09-27 21:27:34 +01:00
parent 3445b88cb1
commit 9b4f5520f7
4 changed files with 21 additions and 5 deletions

4
testdata/039-no-properties.txt vendored Normal file
View File

@ -0,0 +1,4 @@
=== RUN TestPass
--- PASS: TestPass (0.06s)
PASS
ok package/pass 0.160s

6
testdata/039-report.xml vendored Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites tests="1">
<testsuite name="package/pass" tests="1" failures="0" errors="0" id="0" hostname="hostname" time="0.160" timestamp="2022-01-01T00:00:00Z">
<testcase name="TestPass" classname="package/pass" time="0.060"></testcase>
</testsuite>
</testsuites>

View File

@ -20,6 +20,7 @@ var configs = map[string]gojunitreport.Config{
"005-no-xml-header.txt": {SkipXMLHeader: true},
"006-mixed.txt": {SkipXMLHeader: true},
"007-compiled_test.txt": {PackageName: "test/package"},
"039-no-properties.txt": {Properties: make(map[string]string)},
}
func main() {
@ -104,7 +105,9 @@ func createReportFromInput(inputFile, outputFile string, write bool) error {
config.TimestampFunc = func() time.Time {
return time.Date(2022, 1, 1, 0, 0, 0, 0, time.UTC)
}
config.Properties = map[string]string{"go.version": "1.0"}
if config.Properties == nil {
config.Properties = map[string]string{"go.version": "1.0"}
}
_, err = config.Run(in, out)
return err