forked from goss-org/goss
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tap.go
47 lines (36 loc) · 873 Bytes
/
tap.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
package outputs
import (
"fmt"
"strconv"
"time"
"github.com/aelsabbahy/goss/resource"
)
type Tap struct{}
func (r Tap) Output(results <-chan []resource.TestResult, startTime time.Time) (exitCode int) {
testCount := 0
failed := 0
var summary map[int]string
summary = make(map[int]string)
for resultGroup := range results {
for _, testResult := range resultGroup {
if testResult.Successful {
summary[testCount] = "ok " + strconv.Itoa(testCount+1) + " - " + humanizeResult2(testResult) + "\n"
} else {
summary[testCount] = "not ok " + strconv.Itoa(testCount+1) + " - " + humanizeResult2(testResult) + "\n"
failed++
}
testCount++
}
}
fmt.Printf("1..%d\n", testCount)
for i := 0; i < testCount; i++ {
fmt.Printf("%s", summary[i])
}
if failed > 0 {
return 1
}
return 0
}
func init() {
RegisterOutputer("tap", &Tap{})
}