-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsuite.go
107 lines (84 loc) · 2.73 KB
/
suite.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
package testcases
import (
"testing"
"github.com/makasim/flowstate"
)
type TestingT interface {
Helper()
Error(...interface{})
Errorf(format string, args ...interface{})
Fatalf(format string, args ...any)
FailNow()
Cleanup(f func())
}
type Suite struct {
SetUp func(t TestingT) (flowstate.Doer, FlowRegistry)
cases map[string]func(t TestingT, d flowstate.Doer, fr FlowRegistry)
}
func (s *Suite) Test(main *testing.T) {
for name, fn := range s.cases {
main.Run(name, func(t *testing.T) {
if fn == nil {
t.SkipNow()
}
d, fr := s.SetUp(t)
fn(t, d, fr)
})
}
}
func (s *Suite) Skip(t *testing.T, name string) {
if _, ok := s.cases[name]; !ok {
t.Fatal("unknown test case: ", name)
}
s.cases[name] = nil
}
func Get(setUp func(t TestingT) (flowstate.Doer, FlowRegistry)) *Suite {
return &Suite{
SetUp: setUp,
cases: map[string]func(t TestingT, d flowstate.Doer, fr FlowRegistry){
"Actor": Actor,
"CallFlow": CallFlow,
"CallFlowWithCommit": CallFlowWithCommit,
"CallFlowWithWatch": CallFlowWithWatch,
"Condition": Condition,
"DataFlowConfig": DataFlowConfig,
"DataStoreGet": DataStoreGet,
"DataStoreGetWithCommit": DataStoreGetWithCommit,
"DelayDelayedWinWithCommit": Delay_DelayedWin_WithCommit,
"DelayEngineDo": Delay_EngineDo,
"DelayPaused": Delay_Paused,
"DelayPausedWithCommit": Delay_PausedWithCommit,
"DelayReturn": Delay_Return,
"DelayTransitedWinWithCommit": Delay_TransitedWin_WithCommit,
"Fork": Fork,
"ForkJoinFirstWins": ForkJoin_FirstWins,
"ForkJoinLastWins": ForkJoin_LastWins,
"ForkWithCommit": Fork_WithCommit,
"GetOneByIDAndRev": GetOneByIDAndRev,
"GetOneLatestByID": GetOneLatestByID,
"GetOneLatestByLabel": GetOneLatestByLabel,
"GetOneNotFound": GetOneNotFound,
"GetManyLabels": GetManyLabels,
"GetManyOrLabels": GetManyORLabels,
"GetManySinceLatest": GetManySinceLatest,
"GetManySinceRev": GetManySinceRev,
"GetManySinceTime": GetManySinceTime,
"GetManyLatestOnly": GetManyLatestOnly,
"Mutex": Mutex,
"Queue": Queue,
"RateLimit": RateLimit,
"RecoveryAlwaysFail": RecoveryAlwaysFail,
"RecoveryFirstAttemptFail": RecoveryFirstAttemptFail,
"SingleNode": SingleNode,
"ThreeConsequentNodes": ThreeConsequentNodes,
"TwoConsequentNodes": TwoConsequentNodes,
"TwoConsequentNodesWithCommit": TwoConsequentNodesWithCommit,
"WatchLabels": WatchLabels,
"WatchOrLabels": WatchORLabels,
"WatchSinceLatest": WatchSinceLatest,
"WatchSinceRev": WatchSinceRev,
"WatchSinceTime": WatchSinceTime,
"Cron": Cron,
},
}
}