-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathstep_states_test.go
61 lines (57 loc) · 1.4 KB
/
step_states_test.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
60
61
package main
import (
"bytes"
"testing"
"time"
)
func testRefTime() time.Time {
return time.Date(2022, 1, 1, 12, 30, 0, 0, time.UTC)
}
func Test_printStepsStates(t *testing.T) {
tests := []struct {
name string
stepIDToStepStates map[string]stepStates
currentTime time.Time
}{
{
name: "",
stepIDToStepStates: map[string]stepStates{
"ID_1": {
name: "iOS Tests",
stateToStartTime: map[string]time.Time{
"pending": testRefTime(),
"inProgress": testRefTime().Add(60 * time.Second),
"complete": testRefTime().Add(90 * time.Second),
},
},
"ID_2": {
name: "iOS Unit Tests",
stateToStartTime: map[string]time.Time{
"pending": testRefTime(),
"inProgress": testRefTime().Add(40 * time.Second),
"complete": testRefTime().Add(90 * time.Second),
},
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
var b bytes.Buffer
printStepsStates(tt.stepIDToStepStates, testRefTime().Add(90*time.Second), &b)
actual := b.String()
expected := `iOS Tests
- time spent in pending state: ~1m0s
- time spent in inProgress state: ~30s
- time spent in complete state: ~0s
iOS Unit Tests
- time spent in pending state: ~40s
- time spent in inProgress state: ~50s
- time spent in complete state: ~0s
`
if actual != expected {
t.Fatalf("%s != %s", actual, expected)
}
})
}
}