MCPcopy
hub / github.com/yannh/kubeconform / Flush

Method Flush

pkg/output/junit.go:140–185  ·  view source on GitHub ↗

Flush outputs the results as XML

()

Source from the content-addressed store, hash-verified

138
139// Flush outputs the results as XML
140func (o *junito) Flush() error {
141 runtime := time.Now().Sub(o.startTime)
142
143 totalValid := 0
144 totalInvalid := 0
145 totalErrors := 0
146 totalSkipped := 0
147
148 for _, suite := range o.suites {
149 for _, tCase := range suite.Cases {
150 if tCase.Error != nil {
151 totalErrors++
152 } else if tCase.Skipped != nil {
153 totalSkipped++
154 } else if len(tCase.Failure) > 0 {
155 totalInvalid++
156 } else {
157 totalValid++
158 }
159 }
160 }
161
162 root := TestSuiteCollection{
163 Name: "kubeconform",
164 Time: runtime.Seconds(),
165 Tests: totalValid + totalInvalid + totalErrors + totalSkipped,
166 Failures: totalInvalid,
167 Errors: totalErrors,
168 Disabled: totalSkipped,
169 Suites: o.suites,
170 }
171
172 // 2-space indentation
173 content, err := xml.MarshalIndent(root, "", " ")
174
175 if err != nil {
176 return err
177 }
178
179 writer := bufio.NewWriter(o.w)
180 writer.Write(content)
181 writer.WriteByte('\n')
182 writer.Flush()
183
184 return nil
185}

Callers

nothing calls this directly

Calls 2

WriteMethod · 0.65
FlushMethod · 0.65

Tested by

no test coverage detected