@@ -32,6 +32,7 @@ import (
32
32
"k8s.io/apimachinery/pkg/labels"
33
33
34
34
scorecardannotations "github.com/operator-framework/operator-sdk/internal/annotations/scorecard"
35
+ xunit "github.com/operator-framework/operator-sdk/internal/cmd/operator-sdk/scorecard/xunit"
35
36
"github.com/operator-framework/operator-sdk/internal/flags"
36
37
registryutil "github.com/operator-framework/operator-sdk/internal/registry"
37
38
"github.com/operator-framework/operator-sdk/internal/scorecard"
@@ -117,63 +118,8 @@ func (c *scorecardCmd) printOutput(output v1alpha3.TestList) error {
117
118
return nil
118
119
}
119
120
120
- type TestCase struct {
121
- // Name is the name of the test
122
- Name string `json:"name,omitempty"`
123
- Time string `json:"time,omitempty"`
124
- Classname string `json:"classname,omitempty"`
125
- Group string `json:"group,omitempty"`
126
- Failures []xUnitComplexFailure `json:"failure,omitempty"`
127
- Errors []xUnitComplexError `json:"error,omitempty"`
128
- Skipped []xUnitComplexSkipped `json:"skipped,omitempty"`
129
- }
130
-
131
- type TestSuite struct {
132
- // Name is the name of the test
133
- Name string `json:"name,omitempty"`
134
- Tests string `json:"tests,omitempty"`
135
- Failures string `json:"failures,omitempty"`
136
- Errors string `json:"errors,omitempty"`
137
- Group string `json:"group,omitempty"`
138
- Skipped string `json:"skipped,omitempty"`
139
- Timestamp string `json:"timestamp,omitempty"`
140
- Hostname string `json:"hostnames,omitempty"`
141
- ID string `json:"id,omitempty"`
142
- Package string `json:"package,omitempty"`
143
- File string `json:"file,omitempty"`
144
- Log string `json:"log,omitempty"`
145
- URL string `json:"url,omitempty"`
146
- Version string `json:"version,omitempty"`
147
- TestSuites []TestSuite `json:"testsuite,omitempty"`
148
- TestCases []TestCase `json:"testcase,omitempty"`
149
- }
150
-
151
- type TestSuites struct {
152
- // Name is the name of the test
153
- Name string `json:"name,omitempty"`
154
- Tests string `json:"tests,omitempty"`
155
- Failures string `json:"failures,omitempty"`
156
- Errors string `json:"errors,omitempty"`
157
- TestSuite []TestSuite `json:"testsuite,omitempty"`
158
- }
159
-
160
- type xUnitComplexError struct {
161
- Type string `json:"type,omitempty"`
162
- Message string `json:"message,omitempty"`
163
- }
164
-
165
- type xUnitComplexFailure struct {
166
- Type string `json:"type,omitempty"`
167
- Message string `json:"message,omitempty"`
168
- }
169
-
170
- type xUnitComplexSkipped struct {
171
- Type string `json:"type,omitempty"`
172
- Message string `json:"message,omitempty"`
173
- }
174
-
175
- func (c * scorecardCmd ) convertXunit (output v1alpha3.TestList ) TestSuites {
176
- var resultSuite TestSuites
121
+ func (c * scorecardCmd ) convertXunit (output v1alpha3.TestList ) xunit.TestSuites {
122
+ var resultSuite xunit.TestSuites
177
123
resultSuite .Name = "scorecard"
178
124
resultSuite .Tests = ""
179
125
resultSuite .Failures = ""
@@ -183,15 +129,15 @@ func (c *scorecardCmd) convertXunit(output v1alpha3.TestList) TestSuites {
183
129
for _ , item := range jsonTestItems {
184
130
tempResults := item .Status .Results
185
131
for _ , res := range tempResults {
186
- var tCase TestCase
187
- var tSuite TestSuite
132
+ var tCase xunit. TestCase
133
+ var tSuite xunit. TestSuite
188
134
tSuite .Name = res .Name
189
135
tCase .Name = res .Name
190
136
if res .State == v1alpha3 .ErrorState {
191
- tCase .Errors = append (tCase .Errors , xUnitComplexError { "Error" , strings .Join (res .Errors , "," )})
137
+ tCase .Errors = append (tCase .Errors , xunit. XUnitComplexError { Type : "Error" , Message : strings .Join (res .Errors , "," )})
192
138
tSuite .Errors = strings .Join (res .Errors , "," )
193
139
} else if res .State == v1alpha3 .FailState {
194
- tCase .Failures = append (tCase .Failures , xUnitComplexFailure { "Failure" , res .Log })
140
+ tCase .Failures = append (tCase .Failures , xunit. XUnitComplexFailure { Type : "Failure" , Message : res .Log })
195
141
tSuite .Failures = res .Log
196
142
}
197
143
tSuite .TestCases = append (tSuite .TestCases , tCase )
0 commit comments