-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes_test.go
More file actions
52 lines (44 loc) · 1.15 KB
/
types_test.go
File metadata and controls
52 lines (44 loc) · 1.15 KB
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 statekit
import "testing"
func TestState_Matches(t *testing.T) {
t.Parallel()
state := State[struct{}]{
Value: "green",
}
if !state.Matches("green") {
t.Error("expected state to match 'green'")
}
if state.Matches("red") {
t.Error("expected state not to match 'red'")
}
}
func TestStateType_ReExports(t *testing.T) {
t.Parallel()
// Verify constants are properly re-exported
if StateTypeAtomic.String() != "atomic" {
t.Errorf("expected 'atomic', got %v", StateTypeAtomic.String())
}
if StateTypeCompound.String() != "compound" {
t.Errorf("expected 'compound', got %v", StateTypeCompound.String())
}
if StateTypeFinal.String() != "final" {
t.Errorf("expected 'final', got %v", StateTypeFinal.String())
}
}
func TestEvent_Creation(t *testing.T) {
t.Parallel()
event := Event{
Type: "TIMER",
Payload: map[string]int{"count": 1},
}
if event.Type != "TIMER" {
t.Errorf("expected event type 'TIMER', got %v", event.Type)
}
payload, ok := event.Payload.(map[string]int)
if !ok {
t.Fatal("expected payload to be map[string]int")
}
if payload["count"] != 1 {
t.Errorf("expected count 1, got %v", payload["count"])
}
}