(r *Report)
| 222 | var efs embed.FS |
| 223 | |
| 224 | func generateTextReport(r *Report) ([]byte, error) { |
| 225 | // Prepare some template input |
| 226 | // Calculate totals for the test report structure |
| 227 | var successes, failures, warnings int |
| 228 | for _, input := range r.FilePaths { |
| 229 | successes += input.SuccessCount |
| 230 | failures += len(input.Violations) |
| 231 | warnings += len(input.Warnings) |
| 232 | } |
| 233 | |
| 234 | result := "SUCCESS" |
| 235 | if failures > 0 { |
| 236 | result = "FAILURE" |
| 237 | } else if warnings > 0 { |
| 238 | result = "WARNING" |
| 239 | } |
| 240 | |
| 241 | testReport := TestReport{ |
| 242 | Timestamp: r.created.Format(time.RFC3339), |
| 243 | Namespace: "", |
| 244 | Successes: successes, |
| 245 | Failures: failures, |
| 246 | Warnings: warnings, |
| 247 | Result: result, |
| 248 | } |
| 249 | |
| 250 | input := struct { |
| 251 | Report *Report |
| 252 | TestReport TestReport |
| 253 | }{ |
| 254 | Report: r, |
| 255 | TestReport: testReport, |
| 256 | } |
| 257 | |
| 258 | return utils.RenderFromTemplatesWithMain(input, "text_report.tmpl", efs) |
| 259 | } |
no test coverage detected