-
Notifications
You must be signed in to change notification settings - Fork 8
/
state_internal_test.go
52 lines (39 loc) · 1.08 KB
/
state_internal_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
package workflow
import (
"context"
"testing"
"github.com/stretchr/testify/require"
)
func TestUpdateState(t *testing.T) {
b := NewBuilder[string, testStatus]("example")
b.AddStep(statusStart, func(ctx context.Context, r *Run[string, testStatus]) (testStatus, error) {
return statusEnd, nil
}, statusEnd)
w := Workflow[string, testStatus]{
internalState: make(map[string]State),
}
require.Equal(t, map[string]State{}, w.States())
w.updateState("start-consumer-1-of-1", StateIdle)
require.Equal(t, map[string]State{
"start-consumer-1-of-1": StateIdle,
}, w.States())
w.updateState("start-consumer-1-of-1", StateRunning)
require.Equal(t, map[string]State{
"start-consumer-1-of-1": StateRunning,
}, w.States())
w.updateState("start-consumer-1-of-1", StateShutdown)
require.Equal(t, map[string]State{
"start-consumer-1-of-1": StateShutdown,
}, w.States())
}
func TestStateString(t *testing.T) {
states := []State{
StateUnknown,
StateShutdown,
StateRunning,
StateIdle,
}
for _, state := range states {
require.Equal(t, stateStrings[state], state.String())
}
}