-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsequence_test.go
58 lines (56 loc) · 1.14 KB
/
sequence_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
package flash
import (
"context"
"testing"
)
func TestSequence_Execute(t *testing.T) {
type fields struct {
executables []Executable
completion bool
}
tests := []struct {
name string
fields fields
wantErr bool
}{
{
name: "success - Work 10 tasks - expect complete",
fields: fields{
executables: nTasks(10),
completion: true,
},
wantErr: false,
},
{
name: "success - work all tasks - expect incomplete",
fields: fields{executables: []Executable{
&testTask{
ID: 1,
Fail: true,
Delay: "2s",
}, &testTask{
ID: 2,
Fail: false,
Delay: "100ms",
},
},
completion: false,
},
wantErr: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
s := NewSequence(context.TODO())
for _, task := range tt.fields.executables {
s.Add(task)
}
if err := s.Execute(); (err != nil) != tt.wantErr {
t.Errorf("Execute() error = %v, wantErr %v", err, tt.wantErr)
}
if tt.fields.completion != s.IsCompleted() {
t.Errorf("Execute() tasks expected to be completed but incomplete %+v", tt.fields.executables)
}
})
}
}