6
6
import assert from 'assert' ;
7
7
import { randomUUID } from 'crypto' ;
8
8
import asyncRetry from 'async-retry' ;
9
+ import { ExecutionContext } from 'ava' ;
9
10
import { Client } from '@temporalio/client' ;
10
11
import { toCanonicalString , WorkerDeploymentVersion } from '@temporalio/common' ;
11
12
import { temporal } from '@temporalio/proto' ;
12
13
import { Worker } from './helpers' ;
13
- import { makeTestFunction } from './helpers-integration' ;
14
+ import { Context , makeTestFunction } from './helpers-integration' ;
14
15
import { unblockSignal , versionQuery } from './workflows' ;
15
16
16
17
const test = makeTestFunction ( { workflowsPath : __filename } ) ;
@@ -242,7 +243,11 @@ test('Worker deployment based versioning with ramping', async (t) => {
242
243
t . pass ( ) ;
243
244
} ) ;
244
245
245
- test ( 'Worker deployment with dynamic workflow on run' , async ( t ) => {
246
+ async function testWorkerDeploymentWithDynamicBehavior (
247
+ t : ExecutionContext < Context > ,
248
+ workflowName : string ,
249
+ expectedResult : string
250
+ ) {
246
251
if ( t . context . env . supportsTimeSkipping ) {
247
252
t . pass ( "Test Server doesn't support worker deployments" ) ;
248
253
return ;
@@ -276,17 +281,15 @@ test('Worker deployment with dynamic workflow on run', async (t) => {
276
281
const describeResp = await waitUntilWorkerDeploymentVisible ( client , version ) ;
277
282
await setCurrentDeploymentVersion ( client , describeResp . conflictToken , version ) ;
278
283
279
- const wf = await client . workflow . start ( 'cooldynamicworkflow' , {
284
+ const wf = await client . workflow . start ( workflowName , {
280
285
taskQueue,
281
286
workflowId : 'dynamic-workflow-versioning-' + randomUUID ( ) ,
282
287
} ) ;
283
288
284
289
const result = await wf . result ( ) ;
285
- assert . equal ( result , 'dynamic' ) ;
290
+ assert . equal ( result , expectedResult ) ;
286
291
287
- // Check history for versioning behavior
288
292
const history = await wf . fetchHistory ( ) ;
289
-
290
293
const hasPinnedVersioningBehavior = history . events ! . some (
291
294
( event ) =>
292
295
event . workflowTaskCompletedEventAttributes &&
@@ -298,6 +301,14 @@ test('Worker deployment with dynamic workflow on run', async (t) => {
298
301
worker . shutdown ( ) ;
299
302
await workerPromise ;
300
303
t . pass ( ) ;
304
+ }
305
+
306
+ test ( 'Worker deployment with dynamic workflow static behavior' , async ( t ) => {
307
+ await testWorkerDeploymentWithDynamicBehavior ( t , 'cooldynamicworkflow' , 'dynamic' ) ;
308
+ } ) ;
309
+
310
+ test ( 'Worker deployment with behavior in getter' , async ( t ) => {
311
+ await testWorkerDeploymentWithDynamicBehavior ( t , 'usesGetter' , 'usesGetter' ) ;
301
312
} ) ;
302
313
303
314
test ( 'Workflows can use default versioning behavior' , async ( t ) => {
0 commit comments