-
Notifications
You must be signed in to change notification settings - Fork 88
Expand file tree
/
Copy pathcommands.workflow_show_test.go
More file actions
148 lines (142 loc) · 4.87 KB
/
commands.workflow_show_test.go
File metadata and controls
148 lines (142 loc) · 4.87 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
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
package temporalcli
import (
"testing"
"github.com/stretchr/testify/require"
"go.temporal.io/api/enums/v1"
historypb "go.temporal.io/api/history/v1"
)
func TestSystemNexusOpDisplayName(t *testing.T) {
const op = "SignalWithStartWorkflowExecution"
// priorScheduled returns an iter that has already seen a __temporal_system scheduled event at ID 5.
priorScheduled := func() *structuredHistoryIter {
s := &structuredHistoryIter{}
s.systemNexusOpDisplayName(&historypb.HistoryEvent{
EventId: 5,
EventType: enums.EVENT_TYPE_NEXUS_OPERATION_SCHEDULED,
Attributes: &historypb.HistoryEvent_NexusOperationScheduledEventAttributes{
NexusOperationScheduledEventAttributes: &historypb.NexusOperationScheduledEventAttributes{
Endpoint: temporalSystemNexusEndpoint, Operation: op,
},
},
})
return s
}
tests := []struct {
name string
setup func() *structuredHistoryIter
event *historypb.HistoryEvent
wantName string // expected suffix after op, or exact value if wantEmpty
wantEmpty bool
}{
{
name: "scheduled system endpoint records op and returns name",
setup: func() *structuredHistoryIter { return &structuredHistoryIter{} },
event: &historypb.HistoryEvent{
EventId: 5,
EventType: enums.EVENT_TYPE_NEXUS_OPERATION_SCHEDULED,
Attributes: &historypb.HistoryEvent_NexusOperationScheduledEventAttributes{
NexusOperationScheduledEventAttributes: &historypb.NexusOperationScheduledEventAttributes{
Endpoint: temporalSystemNexusEndpoint, Operation: op,
},
},
},
wantName: op + "Scheduled",
},
{
name: "scheduled non-system endpoint returns empty",
setup: func() *structuredHistoryIter { return &structuredHistoryIter{} },
event: &historypb.HistoryEvent{
EventId: 7,
EventType: enums.EVENT_TYPE_NEXUS_OPERATION_SCHEDULED,
Attributes: &historypb.HistoryEvent_NexusOperationScheduledEventAttributes{
NexusOperationScheduledEventAttributes: &historypb.NexusOperationScheduledEventAttributes{
Endpoint: "some-other-endpoint", Operation: op,
},
},
},
wantEmpty: true,
},
{
name: "started after system scheduled",
setup: priorScheduled,
event: &historypb.HistoryEvent{
EventId: 6,
EventType: enums.EVENT_TYPE_NEXUS_OPERATION_STARTED,
Attributes: &historypb.HistoryEvent_NexusOperationStartedEventAttributes{
NexusOperationStartedEventAttributes: &historypb.NexusOperationStartedEventAttributes{ScheduledEventId: 5},
},
},
wantName: op + "Started",
},
{
name: "completed after system scheduled",
setup: priorScheduled,
event: &historypb.HistoryEvent{
EventId: 6,
EventType: enums.EVENT_TYPE_NEXUS_OPERATION_COMPLETED,
Attributes: &historypb.HistoryEvent_NexusOperationCompletedEventAttributes{
NexusOperationCompletedEventAttributes: &historypb.NexusOperationCompletedEventAttributes{ScheduledEventId: 5},
},
},
wantName: op + "Completed",
},
{
name: "completed with no prior scheduled returns empty",
setup: func() *structuredHistoryIter { return &structuredHistoryIter{} },
event: &historypb.HistoryEvent{
EventId: 6,
EventType: enums.EVENT_TYPE_NEXUS_OPERATION_COMPLETED,
Attributes: &historypb.HistoryEvent_NexusOperationCompletedEventAttributes{
NexusOperationCompletedEventAttributes: &historypb.NexusOperationCompletedEventAttributes{ScheduledEventId: 5},
},
},
wantEmpty: true,
},
{
name: "failed after system scheduled",
setup: priorScheduled,
event: &historypb.HistoryEvent{
EventId: 6,
EventType: enums.EVENT_TYPE_NEXUS_OPERATION_FAILED,
Attributes: &historypb.HistoryEvent_NexusOperationFailedEventAttributes{
NexusOperationFailedEventAttributes: &historypb.NexusOperationFailedEventAttributes{ScheduledEventId: 5},
},
},
wantName: op + "Failed",
},
{
name: "timed out after system scheduled",
setup: priorScheduled,
event: &historypb.HistoryEvent{
EventId: 6,
EventType: enums.EVENT_TYPE_NEXUS_OPERATION_TIMED_OUT,
Attributes: &historypb.HistoryEvent_NexusOperationTimedOutEventAttributes{
NexusOperationTimedOutEventAttributes: &historypb.NexusOperationTimedOutEventAttributes{ScheduledEventId: 5},
},
},
wantName: op + "TimedOut",
},
{
name: "canceled after system scheduled",
setup: priorScheduled,
event: &historypb.HistoryEvent{
EventId: 6,
EventType: enums.EVENT_TYPE_NEXUS_OPERATION_CANCELED,
Attributes: &historypb.HistoryEvent_NexusOperationCanceledEventAttributes{
NexusOperationCanceledEventAttributes: &historypb.NexusOperationCanceledEventAttributes{ScheduledEventId: 5},
},
},
wantName: op + "Canceled",
},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
name := tc.setup().systemNexusOpDisplayName(tc.event)
if tc.wantEmpty {
require.Empty(t, name)
} else {
require.Equal(t, tc.wantName, name)
}
})
}
}