Skip to content

Commit 51a0b07

Browse files
stephanosclaude
andauthored
Use SDK in NexusWorkflowTestSuite (#9501)
## What changed? Replace manual RPCs with SDK client/worker in NexusWorkflowTestSuite. ## Why? SDK support wasn't available at the time. ## How did you test it? - [ ] built - [ ] run locally and tested manually - [x] covered by existing tests - [ ] added new unit test(s) - [ ] added new functional test(s) --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 145f109 commit 51a0b07

2 files changed

Lines changed: 330 additions & 834 deletions

File tree

common/testing/historyrequire/history_require.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"github.com/stretchr/testify/require"
1414
enumspb "go.temporal.io/api/enums/v1"
1515
historypb "go.temporal.io/api/history/v1"
16+
"go.temporal.io/server/common/util"
1617
"google.golang.org/protobuf/proto"
1718
)
1819

@@ -45,6 +46,43 @@ func New(t require.TestingT) HistoryRequire {
4546
// - oneof support
4647
// - enums as strings not as ints
4748

49+
func (h HistoryRequire) historyEvents(events []*historypb.HistoryEvent, eventType enumspb.EventType) []*historypb.HistoryEvent {
50+
if th, ok := h.t.(helper); ok {
51+
th.Helper()
52+
}
53+
return util.FilterSlice(events, func(e *historypb.HistoryEvent) bool { return e.EventType == eventType })
54+
}
55+
56+
// RequireHistoryEvent returns the single event matching the given event type.
57+
// It fails the test if no matching event is found or if more than one is found.
58+
func (h HistoryRequire) RequireHistoryEvent(events []*historypb.HistoryEvent, eventType enumspb.EventType) *historypb.HistoryEvent {
59+
if th, ok := h.t.(helper); ok {
60+
th.Helper()
61+
}
62+
matches := h.historyEvents(events, eventType)
63+
switch len(matches) {
64+
case 0:
65+
require.Failf(h.t, "missing history event", "expected %s event in history", eventType)
66+
return nil
67+
case 1:
68+
return matches[0]
69+
default:
70+
require.Failf(h.t, "too many history events", "expected one %s event in history, found %d", eventType, len(matches))
71+
return matches[0]
72+
}
73+
}
74+
75+
// RequireNoHistoryEvent fails the test if any event matches the given event type.
76+
func (h HistoryRequire) RequireNoHistoryEvent(events []*historypb.HistoryEvent, eventType enumspb.EventType) {
77+
if th, ok := h.t.(helper); ok {
78+
th.Helper()
79+
}
80+
matches := h.historyEvents(events, eventType)
81+
if len(matches) > 0 {
82+
require.Failf(h.t, "unexpected history event", "expected no %s event(s) in history, found %d", eventType, len(matches))
83+
}
84+
}
85+
4886
func (h HistoryRequire) EqualHistoryEvents(expectedHistory string, actualHistoryEvents []*historypb.HistoryEvent) {
4987
if th, ok := h.t.(helper); ok {
5088
th.Helper()

0 commit comments

Comments
 (0)