@@ -5,6 +5,7 @@ import nock = require("nock");
5
5
import url = require( "url" ) ;
6
6
import {
7
7
DurableOrchestrationClient ,
8
+ DurableOrchestrationStatus ,
8
9
EntityId ,
9
10
EntityStateResponse ,
10
11
HttpManagementPayload ,
@@ -244,6 +245,64 @@ describe("Durable client RPC endpoint", () => {
244
245
expect ( scope . isDone ( ) ) . to . be . equal ( true ) ;
245
246
expect ( result ) . to . be . an ( "array" ) ;
246
247
} ) ;
248
+
249
+ it ( "uses continuation header" , async ( ) => {
250
+ const input = JSON . parse ( durableClientBindingInputJson ) as OrchestrationClientInputData ;
251
+ const client = new DurableOrchestrationClient ( input ) ;
252
+
253
+ // The getStatusBy() method should do a GET to http://127.0.0.1:17071/durabletask/instances/?createdTimeFrom=2020-01-01T00:00:00Z&createdTimeTo=2020-01-01T23:59:59Z&runtimeStatus=Pending,Running,Completed,Terminated,Failed
254
+ const expectedUrl = new URL ( `${ testRpcOrigin } /durabletask/instances/` ) ;
255
+ const createdTimeFrom = "2020-01-01T00:00:00.000Z" ;
256
+ const createdTimeTo = "2020-01-01T23:59:59.000Z" ;
257
+ const runtimeStatus = "Pending,Running,Completed,Terminated,Failed" ;
258
+
259
+ // create dummy orchestration status for response
260
+ const dummyDate = new Date ( ) ;
261
+ const dummyStatus = new DurableOrchestrationStatus (
262
+ "dummyOrchestrationStatus" ,
263
+ "123456" ,
264
+ dummyDate ,
265
+ dummyDate ,
266
+ "myInput" ,
267
+ "myOutput" ,
268
+ OrchestrationRuntimeStatus . Completed
269
+ ) ;
270
+ const dummyStatusJSON = JSON . stringify ( dummyStatus ) ;
271
+
272
+ const scopeWithTokenResponse = nock ( expectedUrl . origin )
273
+ . get ( expectedUrl . pathname )
274
+ . query ( { createdTimeFrom, createdTimeTo, runtimeStatus } )
275
+ . reply ( 200 , [ dummyStatusJSON , dummyStatusJSON ] , {
276
+ "x-ms-continuation-token" : "myToken" ,
277
+ } ) ;
278
+
279
+ const scopeNoTokenResponse = nock ( expectedUrl . origin , {
280
+ reqheaders : {
281
+ "x-ms-continuation-token" : "myToken" ,
282
+ } ,
283
+ } )
284
+ . get ( expectedUrl . pathname )
285
+ . query ( { createdTimeFrom, createdTimeTo, runtimeStatus } )
286
+ . reply ( 200 , [ dummyStatusJSON ] ) ;
287
+
288
+ const statusList = runtimeStatus
289
+ . split ( "," )
290
+ . map (
291
+ ( status ) =>
292
+ OrchestrationRuntimeStatus [
293
+ status as keyof typeof OrchestrationRuntimeStatus
294
+ ]
295
+ ) ;
296
+ const result = await client . getStatusBy (
297
+ new Date ( createdTimeFrom ) ,
298
+ new Date ( createdTimeTo ) ,
299
+ statusList
300
+ ) ;
301
+ expect ( scopeWithTokenResponse . isDone ( ) ) . to . be . equal ( true ) ;
302
+ expect ( scopeNoTokenResponse . isDone ( ) ) . to . be . equal ( true ) ;
303
+ expect ( result ) . to . be . an ( "array" ) ;
304
+ expect ( result ) . to . be . of . length ( 3 ) ;
305
+ } ) ;
247
306
} ) ;
248
307
249
308
describe ( "terminate()" , ( ) => {
0 commit comments