@@ -68,12 +68,8 @@ func TestEnqueue(t *testing.T) {
68
68
69
69
t .Run ("EnqueueAndGetResult" , func (t * testing.T ) {
70
70
// Client enqueues a task using the new Enqueue method
71
- handle , err := Enqueue [wfInput , string ](clientCtx , GenericEnqueueOptions [wfInput ]{
72
- WorkflowName : "ServerWorkflow" ,
73
- QueueName : queue .Name ,
74
- WorkflowInput : wfInput {Input : "test-input" },
75
- ApplicationVersion : serverCtx .GetApplicationVersion (),
76
- })
71
+ handle , err := Enqueue [wfInput , string ](clientCtx , queue .Name , "ServerWorkflow" , wfInput {Input : "test-input" },
72
+ WithEnqueueApplicationVersion (serverCtx .GetApplicationVersion ()))
77
73
require .NoError (t , err )
78
74
79
75
// Verify we got a polling handle
@@ -102,12 +98,8 @@ func TestEnqueue(t *testing.T) {
102
98
customWorkflowID := "custom-client-workflow-id"
103
99
104
100
// Client enqueues a task with a custom workflow ID
105
- _ , err := Enqueue [wfInput , string ](clientCtx , GenericEnqueueOptions [wfInput ]{
106
- WorkflowName : "ServerWorkflow" ,
107
- QueueName : queue .Name ,
108
- WorkflowID : customWorkflowID ,
109
- WorkflowInput : wfInput {Input : "test-input" },
110
- })
101
+ _ , err := Enqueue [wfInput , string ](clientCtx , queue .Name , "ServerWorkflow" , wfInput {Input : "test-input" },
102
+ WithEnqueueWorkflowID (customWorkflowID ))
111
103
require .NoError (t , err )
112
104
113
105
// Verify the workflow ID is what we set
@@ -123,12 +115,8 @@ func TestEnqueue(t *testing.T) {
123
115
})
124
116
125
117
t .Run ("EnqueueWithTimeout" , func (t * testing.T ) {
126
- handle , err := Enqueue [string , string ](clientCtx , GenericEnqueueOptions [string ]{
127
- WorkflowName : "BlockingWorkflow" ,
128
- QueueName : queue .Name ,
129
- WorkflowInput : "blocking-input" ,
130
- WorkflowTimeout : 500 * time .Millisecond ,
131
- })
118
+ handle , err := Enqueue [string , string ](clientCtx , queue .Name , "BlockingWorkflow" , "blocking-input" ,
119
+ WithEnqueueTimeout (500 * time .Millisecond ))
132
120
require .NoError (t , err )
133
121
134
122
// Should timeout when trying to get result
@@ -154,32 +142,20 @@ func TestEnqueue(t *testing.T) {
154
142
mu .Unlock ()
155
143
156
144
// Enqueue workflow without priority (will use default priority of 0)
157
- handle1 , err := Enqueue [string , string ](clientCtx , GenericEnqueueOptions [string ]{
158
- WorkflowName : "PriorityWorkflow" ,
159
- QueueName : priorityQueue .Name ,
160
- WorkflowInput : "abc" ,
161
- ApplicationVersion : serverCtx .GetApplicationVersion (),
162
- })
145
+ handle1 , err := Enqueue [string , string ](clientCtx , priorityQueue .Name , "PriorityWorkflow" , "abc" ,
146
+ WithEnqueueApplicationVersion (serverCtx .GetApplicationVersion ()))
163
147
require .NoError (t , err , "failed to enqueue workflow without priority" )
164
148
165
149
// Enqueue with a lower priority (higher number = lower priority)
166
- handle2 , err := Enqueue [string , string ](clientCtx , GenericEnqueueOptions [string ]{
167
- WorkflowName : "PriorityWorkflow" ,
168
- QueueName : priorityQueue .Name ,
169
- WorkflowInput : "def" ,
170
- Priority : 5 ,
171
- ApplicationVersion : serverCtx .GetApplicationVersion (),
172
- })
150
+ handle2 , err := Enqueue [string , string ](clientCtx , priorityQueue .Name , "PriorityWorkflow" , "def" ,
151
+ WithEnqueuePriority (5 ),
152
+ WithEnqueueApplicationVersion (serverCtx .GetApplicationVersion ()))
173
153
require .NoError (t , err , "failed to enqueue workflow with priority 5" )
174
154
175
155
// Enqueue with a higher priority (lower number = higher priority)
176
- handle3 , err := Enqueue [string , string ](clientCtx , GenericEnqueueOptions [string ]{
177
- WorkflowName : "PriorityWorkflow" ,
178
- QueueName : priorityQueue .Name ,
179
- WorkflowInput : "ghi" ,
180
- Priority : 1 ,
181
- ApplicationVersion : serverCtx .GetApplicationVersion (),
182
- })
156
+ handle3 , err := Enqueue [string , string ](clientCtx , priorityQueue .Name , "PriorityWorkflow" , "ghi" ,
157
+ WithEnqueuePriority (1 ),
158
+ WithEnqueueApplicationVersion (serverCtx .GetApplicationVersion ()))
183
159
require .NoError (t , err , "failed to enqueue workflow with priority 1" )
184
160
185
161
// Get results
@@ -212,25 +188,17 @@ func TestEnqueue(t *testing.T) {
212
188
wfid2 := "client-dedup-wf2"
213
189
214
190
// First workflow with deduplication ID - should succeed
215
- handle1 , err := Enqueue [wfInput , string ](clientCtx , GenericEnqueueOptions [wfInput ]{
216
- WorkflowName : "ServerWorkflow" ,
217
- QueueName : queue .Name ,
218
- WorkflowID : wfid1 ,
219
- DeduplicationID : dedupID ,
220
- WorkflowInput : wfInput {Input : "test-input" },
221
- ApplicationVersion : serverCtx .GetApplicationVersion (),
222
- })
191
+ handle1 , err := Enqueue [wfInput , string ](clientCtx , queue .Name , "ServerWorkflow" , wfInput {Input : "test-input" },
192
+ WithEnqueueWorkflowID (wfid1 ),
193
+ WithEnqueueDeduplicationID (dedupID ),
194
+ WithEnqueueApplicationVersion (serverCtx .GetApplicationVersion ()))
223
195
require .NoError (t , err , "failed to enqueue first workflow with deduplication ID" )
224
196
225
197
// Second workflow with same deduplication ID but different workflow ID - should fail
226
- _ , err = Enqueue [wfInput , string ](clientCtx , GenericEnqueueOptions [wfInput ]{
227
- WorkflowName : "ServerWorkflow" ,
228
- QueueName : queue .Name ,
229
- WorkflowID : wfid2 ,
230
- DeduplicationID : dedupID ,
231
- WorkflowInput : wfInput {Input : "test-input" },
232
- ApplicationVersion : serverCtx .GetApplicationVersion (),
233
- })
198
+ _ , err = Enqueue [wfInput , string ](clientCtx , queue .Name , "ServerWorkflow" , wfInput {Input : "test-input" },
199
+ WithEnqueueWorkflowID (wfid2 ),
200
+ WithEnqueueDeduplicationID (dedupID ),
201
+ WithEnqueueApplicationVersion (serverCtx .GetApplicationVersion ()))
234
202
require .Error (t , err , "expected error when enqueueing workflow with same deduplication ID" )
235
203
236
204
// Check that it's the correct error type and message
@@ -242,22 +210,14 @@ func TestEnqueue(t *testing.T) {
242
210
assert .Contains (t , err .Error (), expectedMsgPart , "expected error message to contain deduplication information" )
243
211
244
212
// Third workflow with different deduplication ID - should succeed
245
- handle3 , err := Enqueue [wfInput , string ](clientCtx , GenericEnqueueOptions [wfInput ]{
246
- WorkflowName : "ServerWorkflow" ,
247
- QueueName : queue .Name ,
248
- DeduplicationID : "different-dedup-id" ,
249
- WorkflowInput : wfInput {Input : "test-input" },
250
- ApplicationVersion : serverCtx .GetApplicationVersion (),
251
- })
213
+ handle3 , err := Enqueue [wfInput , string ](clientCtx , queue .Name , "ServerWorkflow" , wfInput {Input : "test-input" },
214
+ WithEnqueueDeduplicationID ("different-dedup-id" ),
215
+ WithEnqueueApplicationVersion (serverCtx .GetApplicationVersion ()))
252
216
require .NoError (t , err , "failed to enqueue workflow with different deduplication ID" )
253
217
254
218
// Fourth workflow without deduplication ID - should succeed
255
- handle4 , err := Enqueue [wfInput , string ](clientCtx , GenericEnqueueOptions [wfInput ]{
256
- WorkflowName : "ServerWorkflow" ,
257
- QueueName : queue .Name ,
258
- WorkflowInput : wfInput {Input : "test-input" },
259
- ApplicationVersion : serverCtx .GetApplicationVersion (),
260
- })
219
+ handle4 , err := Enqueue [wfInput , string ](clientCtx , queue .Name , "ServerWorkflow" , wfInput {Input : "test-input" },
220
+ WithEnqueueApplicationVersion (serverCtx .GetApplicationVersion ()))
261
221
require .NoError (t , err , "failed to enqueue workflow without deduplication ID" )
262
222
263
223
// Wait for all successful workflows to complete
@@ -274,14 +234,10 @@ func TestEnqueue(t *testing.T) {
274
234
assert .Equal (t , "processed: test-input" , result4 )
275
235
276
236
// After first workflow completes, we should be able to enqueue with same deduplication ID
277
- handle5 , err := Enqueue [wfInput , string ](clientCtx , GenericEnqueueOptions [wfInput ]{
278
- WorkflowName : "ServerWorkflow" ,
279
- QueueName : queue .Name ,
280
- WorkflowID : wfid2 , // Reuse the workflow ID that failed before
281
- DeduplicationID : dedupID , // Same deduplication ID as first workflow
282
- WorkflowInput : wfInput {Input : "test-input" },
283
- ApplicationVersion : serverCtx .GetApplicationVersion (),
284
- })
237
+ handle5 , err := Enqueue [wfInput , string ](clientCtx , queue .Name , "ServerWorkflow" , wfInput {Input : "test-input" },
238
+ WithEnqueueWorkflowID (wfid2 ), // Reuse the workflow ID that failed before
239
+ WithEnqueueDeduplicationID (dedupID ), // Same deduplication ID as first workflow
240
+ WithEnqueueApplicationVersion (serverCtx .GetApplicationVersion ()))
285
241
require .NoError (t , err , "failed to enqueue workflow with same dedup ID after completion" )
286
242
287
243
result5 , err := handle5 .GetResult ()
@@ -366,13 +322,9 @@ func TestCancelResume(t *testing.T) {
366
322
workflowID := "test-cancel-resume-workflow"
367
323
368
324
// Start the workflow - it will execute step one and then wait
369
- handle , err := Enqueue [int , int ](clientCtx , GenericEnqueueOptions [int ]{
370
- WorkflowName : "CancelResumeWorkflow" ,
371
- QueueName : queue .Name ,
372
- WorkflowID : workflowID ,
373
- WorkflowInput : input ,
374
- ApplicationVersion : serverCtx .GetApplicationVersion (),
375
- })
325
+ handle , err := Enqueue [int , int ](clientCtx , queue .Name , "CancelResumeWorkflow" , input ,
326
+ WithEnqueueWorkflowID (workflowID ),
327
+ WithEnqueueApplicationVersion (serverCtx .GetApplicationVersion ()))
376
328
require .NoError (t , err , "failed to enqueue workflow from client" )
377
329
378
330
// Wait for workflow to signal it has started and step one completed
@@ -435,14 +387,10 @@ func TestCancelResume(t *testing.T) {
435
387
workflowTimeout := 2 * time .Second
436
388
437
389
// Start the workflow with a 2-second timeout
438
- handle , err := Enqueue [string , string ](clientCtx , GenericEnqueueOptions [string ]{
439
- WorkflowName : "TimeoutBlockingWorkflow" ,
440
- QueueName : queue .Name ,
441
- WorkflowID : workflowID ,
442
- WorkflowInput : "timeout-test" ,
443
- WorkflowTimeout : workflowTimeout ,
444
- ApplicationVersion : serverCtx .GetApplicationVersion (),
445
- })
390
+ handle , err := Enqueue [string , string ](clientCtx , queue .Name , "TimeoutBlockingWorkflow" , "timeout-test" ,
391
+ WithEnqueueWorkflowID (workflowID ),
392
+ WithEnqueueTimeout (workflowTimeout ),
393
+ WithEnqueueApplicationVersion (serverCtx .GetApplicationVersion ()))
446
394
require .NoError (t , err , "failed to enqueue timeout blocking workflow" )
447
395
448
396
// Wait 500ms (well before the timeout expires)
@@ -615,13 +563,9 @@ func TestForkWorkflow(t *testing.T) {
615
563
originalWorkflowID := "original-workflow-fork-test"
616
564
617
565
// 1. Run the entire workflow first and check counters are 1
618
- handle , err := Enqueue [string , string ](clientCtx , GenericEnqueueOptions [string ]{
619
- WorkflowName : "ParentWorkflow" ,
620
- QueueName : queue .Name ,
621
- WorkflowID : originalWorkflowID ,
622
- WorkflowInput : "test" ,
623
- ApplicationVersion : serverCtx .GetApplicationVersion (),
624
- })
566
+ handle , err := Enqueue [string , string ](clientCtx , queue .Name , "ParentWorkflow" , "test" ,
567
+ WithEnqueueWorkflowID (originalWorkflowID ),
568
+ WithEnqueueApplicationVersion (serverCtx .GetApplicationVersion ()))
625
569
require .NoError (t , err , "failed to enqueue original workflow" )
626
570
627
571
// Wait for the original workflow to complete
@@ -758,27 +702,19 @@ func TestListWorkflows(t *testing.T) {
758
702
if i < 5 {
759
703
// First 5 workflows: use prefix "test-batch-" and succeed
760
704
workflowID = fmt .Sprintf ("test-batch-%d" , i )
761
- handle , err = Enqueue [testInput , string ](clientCtx , GenericEnqueueOptions [testInput ]{
762
- WorkflowName : "SimpleWorkflow" ,
763
- QueueName : queue .Name ,
764
- WorkflowID : workflowID ,
765
- WorkflowInput : testInput {Value : i , ID : fmt .Sprintf ("success-%d" , i )},
766
- ApplicationVersion : serverCtx .GetApplicationVersion (),
767
- })
705
+ handle , err = Enqueue [testInput , string ](clientCtx , queue .Name , "SimpleWorkflow" , testInput {Value : i , ID : fmt .Sprintf ("success-%d" , i )},
706
+ WithEnqueueWorkflowID (workflowID ),
707
+ WithEnqueueApplicationVersion (serverCtx .GetApplicationVersion ()))
768
708
} else {
769
709
// Last 5 workflows: use prefix "test-other-" and some will fail
770
710
workflowID = fmt .Sprintf ("test-other-%d" , i )
771
711
value := i
772
712
if i >= 8 {
773
713
value = - i // These will fail
774
714
}
775
- handle , err = Enqueue [testInput , string ](clientCtx , GenericEnqueueOptions [testInput ]{
776
- WorkflowName : "SimpleWorkflow" ,
777
- QueueName : queue .Name ,
778
- WorkflowID : workflowID ,
779
- WorkflowInput : testInput {Value : value , ID : fmt .Sprintf ("test-%d" , i )},
780
- ApplicationVersion : serverCtx .GetApplicationVersion (),
781
- })
715
+ handle , err = Enqueue [testInput , string ](clientCtx , queue .Name , "SimpleWorkflow" , testInput {Value : value , ID : fmt .Sprintf ("test-%d" , i )},
716
+ WithEnqueueWorkflowID (workflowID ),
717
+ WithEnqueueApplicationVersion (serverCtx .GetApplicationVersion ()))
782
718
}
783
719
784
720
require .NoError (t , err , "failed to enqueue workflow %d" , i )
0 commit comments