forked from goss-org/goss
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rspecish.go
48 lines (41 loc) · 1006 Bytes
/
rspecish.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
package outputs
import (
"fmt"
"time"
"github.com/aelsabbahy/goss/resource"
"github.com/fatih/color"
)
type Rspecish struct{}
func (r Rspecish) Output(results <-chan []resource.TestResult, startTime time.Time) (exitCode int) {
testCount := 0
var failed []resource.TestResult
for resultGroup := range results {
for _, testResult := range resultGroup {
if testResult.Successful {
fmt.Printf(green("."))
} else {
fmt.Printf(red("F"))
failed = append(failed, testResult)
}
testCount++
}
}
fmt.Print("\n\n")
if len(failed) > 0 {
color.Red("Failures:")
for _, testResult := range failed {
fmt.Println(humanizeResult(testResult))
}
fmt.Print("\n")
}
fmt.Printf("Total Duration: %.3fs\n", time.Since(startTime).Seconds())
if len(failed) > 0 {
color.Red("Count: %d, Failed: %d\n", testCount, len(failed))
return 1
}
color.Green("Count: %d, Failed: %d\n", testCount, len(failed))
return 0
}
func init() {
RegisterOutputer("rspecish", &Rspecish{})
}