Skip to content

Commit bce15c9

Browse files
authored
[core-lro] Add a test case for retrieving partial results after cancellation (Azure#22220)
1 parent 3ebe1f6 commit bce15c9

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

sdk/core/core-lro/test/engine.spec.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2123,5 +2123,37 @@ describe("Lro Engine", function () {
21232123
assert.isTrue(run);
21242124
assert.isUndefined(poller.getOperationState().isCancelled);
21252125
});
2126+
2127+
it("cancelled poller gives access to partial results", async () => {
2128+
const pollingPath = "/LROPostDoubleHeadersFinalAzureHeaderGetDefault/asyncOperationUrl";
2129+
const poller = createPoller({
2130+
routes: [
2131+
{
2132+
method: "POST",
2133+
path: `/LROPostDoubleHeadersFinalAzureHeaderGetDefault`,
2134+
status: 202,
2135+
body: "",
2136+
headers: {
2137+
"Operation-Location": pollingPath,
2138+
},
2139+
},
2140+
{
2141+
method: "GET",
2142+
path: pollingPath,
2143+
status: 200,
2144+
body: `{ "status": "running"}`,
2145+
},
2146+
{
2147+
method: "GET",
2148+
path: pollingPath,
2149+
status: 200,
2150+
body: `{ "status": "canceled", "results": [1,2] }`,
2151+
},
2152+
],
2153+
});
2154+
await assertError(poller.pollUntilDone(), { messagePattern: /Poller cancelled/ });
2155+
const result = poller.getResult();
2156+
assert.deepEqual(result!.results, [1, 2]);
2157+
});
21262158
});
21272159
});

0 commit comments

Comments
 (0)