@@ -2098,127 +2098,4 @@ describe("Lro Engine", function () {
20982098 assert . deepInclude ( result , { id : "200" , name : "foo" } ) ;
20992099 } ) ;
21002100 } ) ;
2101-
2102- describe ( "poller cancellation" , ( ) => {
2103- it ( "isCancel is set after the cancellation callback resolves" , async ( ) => {
2104- const resourceLocationPath = "/LROPostDoubleHeadersFinalAzureHeaderGetDefault/location" ;
2105- const pollingPath = "/LROPostDoubleHeadersFinalAzureHeaderGetDefault/asyncOperationUrl" ;
2106- let run = false ;
2107- const poller = createPoller ( {
2108- routes : [
2109- {
2110- method : "POST" ,
2111- status : 202 ,
2112- body : "" ,
2113- headers : {
2114- Location : resourceLocationPath ,
2115- "Operation-Location" : pollingPath ,
2116- } ,
2117- } ,
2118- {
2119- method : "GET" ,
2120- path : pollingPath ,
2121- status : 200 ,
2122- body : `{ "status": "running"}` ,
2123- } ,
2124- {
2125- method : "GET" ,
2126- path : pollingPath ,
2127- status : 200 ,
2128- body : `{ "status": "canceled" }` ,
2129- } ,
2130- ] ,
2131- cancel : async ( ) => {
2132- run = true ;
2133- } ,
2134- } ) ;
2135- assert . isUndefined ( poller . getOperationState ( ) . isCancelled ) ;
2136- await poller . poll ( ) ;
2137- assert . isUndefined ( poller . getOperationState ( ) . isCancelled ) ;
2138- await poller . cancelOperation ( ) ;
2139- assert . isTrue ( run ) ;
2140- assert . isUndefined ( poller . getOperationState ( ) . isCancelled ) ;
2141- await Promise . all ( [
2142- assertError ( poller . pollUntilDone ( ) , {
2143- messagePattern : / P o l l e r c a n c e l l e d / ,
2144- } ) ,
2145- assertError ( poller . poll ( ) , {
2146- messagePattern : / T h e l o n g - r u n n i n g o p e r a t i o n h a s b e e n c a n c e l e d ./ ,
2147- } ) ,
2148- ] ) ;
2149- assert . isTrue ( poller . getOperationState ( ) . isCancelled ) ;
2150- } ) ;
2151-
2152- it ( "isCancel is not set when the cancellation callback throws" , async ( ) => {
2153- const resourceLocationPath = "/LROPostDoubleHeadersFinalAzureHeaderGetDefault/location" ;
2154- const pollingPath = "/LROPostDoubleHeadersFinalAzureHeaderGetDefault/asyncOperationUrl" ;
2155- let run = false ;
2156- const poller = createPoller ( {
2157- routes : [
2158- {
2159- method : "POST" ,
2160- status : 202 ,
2161- body : "" ,
2162- headers : {
2163- Location : resourceLocationPath ,
2164- "Operation-Location" : pollingPath ,
2165- } ,
2166- } ,
2167- {
2168- method : "GET" ,
2169- path : pollingPath ,
2170- status : 200 ,
2171- body : `{ "status": "succeeded"}` ,
2172- } ,
2173- {
2174- method : "GET" ,
2175- path : resourceLocationPath ,
2176- status : 200 ,
2177- body : `{ "id": "100", "name": "foo" }` ,
2178- } ,
2179- ] ,
2180- cancel : async ( ) => {
2181- run = true ;
2182- throw new Error ( ) ;
2183- } ,
2184- } ) ;
2185- assert . isUndefined ( poller . getOperationState ( ) . isCancelled ) ;
2186- await poller . poll ( ) ;
2187- assert . isUndefined ( poller . getOperationState ( ) . isCancelled ) ;
2188- await assert . isRejected ( poller . cancelOperation ( ) ) ;
2189- assert . isTrue ( run ) ;
2190- assert . isUndefined ( poller . getOperationState ( ) . isCancelled ) ;
2191- } ) ;
2192-
2193- it ( "cancelled poller gives access to partial results" , async ( ) => {
2194- const pollingPath = "/LROPostDoubleHeadersFinalAzureHeaderGetDefault/asyncOperationUrl" ;
2195- const poller = createPoller ( {
2196- routes : [
2197- {
2198- method : "POST" ,
2199- status : 202 ,
2200- body : "" ,
2201- headers : {
2202- "Operation-Location" : pollingPath ,
2203- } ,
2204- } ,
2205- {
2206- method : "GET" ,
2207- path : pollingPath ,
2208- status : 200 ,
2209- body : `{ "status": "running"}` ,
2210- } ,
2211- {
2212- method : "GET" ,
2213- path : pollingPath ,
2214- status : 200 ,
2215- body : `{ "status": "canceled", "results": [1,2] }` ,
2216- } ,
2217- ] ,
2218- } ) ;
2219- await assertError ( poller . pollUntilDone ( ) , { messagePattern : / P o l l e r c a n c e l l e d / } ) ;
2220- const result = poller . getResult ( ) ;
2221- assert . deepEqual ( result ! . results , [ 1 , 2 ] ) ;
2222- } ) ;
2223- } ) ;
22242101} ) ;
0 commit comments