@@ -343,22 +343,51 @@ describe("Durable Functions", () => {
343
343
} , 31000 ) ;
344
344
345
345
it ( "should be able to run an single orchestration without activity" , async ( ) => {
346
- const sequence : TOrchestrator = async function * ( ctx : OrchestrationContext , startVal : number ) : any {
346
+ const orchestrator : TOrchestrator = async function * ( ctx : OrchestrationContext , startVal : number ) : any {
347
347
return startVal + 1 ;
348
348
} ;
349
349
350
- taskHubWorker . addOrchestrator ( sequence ) ;
350
+ taskHubWorker . addOrchestrator ( orchestrator ) ;
351
351
await taskHubWorker . start ( ) ;
352
352
353
- const id = await taskHubClient . scheduleNewOrchestration ( sequence , 15 ) ;
353
+ const id = await taskHubClient . scheduleNewOrchestration ( orchestrator , 15 ) ;
354
354
const state = await taskHubClient . waitForOrchestrationCompletion ( id , undefined , 30 ) ;
355
355
356
356
expect ( state ) ;
357
- expect ( state ?. name ) . toEqual ( getName ( sequence ) ) ;
357
+ expect ( state ?. name ) . toEqual ( getName ( orchestrator ) ) ;
358
358
expect ( state ?. instanceId ) . toEqual ( id ) ;
359
359
expect ( state ?. failureDetails ) . toBeUndefined ( ) ;
360
360
expect ( state ?. runtimeStatus ) . toEqual ( OrchestrationStatus . ORCHESTRATION_STATUS_COMPLETED ) ;
361
361
expect ( state ?. serializedInput ) . toEqual ( JSON . stringify ( 15 ) ) ;
362
362
expect ( state ?. serializedOutput ) . toEqual ( JSON . stringify ( 16 ) ) ;
363
363
} , 31000 ) ;
364
+
365
+ it ( "should be able purge orchestration" , async ( ) => {
366
+ const plusOne = async ( _ : ActivityContext , input : number ) => {
367
+ return input + 1 ;
368
+ } ;
369
+
370
+ const orchestrator : TOrchestrator = async function * ( ctx : OrchestrationContext , startVal : number ) : any {
371
+ return yield ctx . callActivity ( plusOne , startVal ) ;
372
+ } ;
373
+
374
+ taskHubWorker . addOrchestrator ( orchestrator ) ;
375
+ taskHubWorker . addActivity ( plusOne ) ;
376
+ await taskHubWorker . start ( ) ;
377
+
378
+ const id = await taskHubClient . scheduleNewOrchestration ( orchestrator , 1 ) ;
379
+ const state = await taskHubClient . waitForOrchestrationCompletion ( id , undefined , 30 ) ;
380
+
381
+ expect ( state ) ;
382
+ expect ( state ?. name ) . toEqual ( getName ( orchestrator ) ) ;
383
+ expect ( state ?. instanceId ) . toEqual ( id ) ;
384
+ expect ( state ?. failureDetails ) . toBeUndefined ( ) ;
385
+ expect ( state ?. runtimeStatus ) . toEqual ( OrchestrationStatus . ORCHESTRATION_STATUS_COMPLETED ) ;
386
+ expect ( state ?. serializedInput ) . toEqual ( JSON . stringify ( 1 ) ) ;
387
+ expect ( state ?. serializedOutput ) . toEqual ( JSON . stringify ( 2 ) ) ;
388
+
389
+ const purgeResult = await taskHubClient . purgeInstanceById ( id ) ;
390
+ expect ( purgeResult ) ;
391
+ expect ( purgeResult ?. deletedInstanceCount ) . toEqual ( 1 ) ;
392
+ } , 31000 ) ;
364
393
} ) ;
0 commit comments