-
Notifications
You must be signed in to change notification settings - Fork 475
/
Copy pathdocumentation.go
59 lines (51 loc) · 1.4 KB
/
documentation.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package outputs
import (
"fmt"
"io"
"time"
"github.com/aelsabbahy/goss/resource"
"github.com/aelsabbahy/goss/util"
)
type Documentation struct{}
func (r Documentation) Output(w io.Writer, results <-chan []resource.TestResult,
startTime time.Time, outConfig util.OutputConfig) (exitCode int) {
testCount := 0
var failedOrSkipped [][]resource.TestResult
var skipped, failed int
for resultGroup := range results {
failedOrSkippedGroup := []resource.TestResult{}
first := resultGroup[0]
header := header(first)
if header != "" {
fmt.Fprint(w, header)
}
for _, testResult := range resultGroup {
switch testResult.Result {
case resource.SUCCESS:
fmt.Fprintln(w, humanizeResult(testResult))
case resource.SKIP:
fmt.Fprintln(w, humanizeResult(testResult))
failedOrSkippedGroup = append(failedOrSkippedGroup, testResult)
skipped++
case resource.FAIL:
fmt.Fprintln(w, humanizeResult(testResult))
failedOrSkippedGroup = append(failedOrSkippedGroup, testResult)
failed++
}
testCount++
}
if len(failedOrSkippedGroup) > 0 {
failedOrSkipped = append(failedOrSkipped, failedOrSkippedGroup)
}
}
fmt.Fprint(w, "\n\n")
fmt.Fprint(w, failedOrSkippedSummary(failedOrSkipped))
fmt.Fprint(w, summary(startTime, testCount, failed, skipped))
if failed > 0 {
return 1
}
return 0
}
func init() {
RegisterOutputer("documentation", &Documentation{}, []string{})
}