Skip to content

Commit 688a3c5

Browse files
authored
test: Add getRemainingTimeInMillis support to testing library (#396)
Closes #270 update context.lambdaContext to return 900_000 (15min) instead of throwing an error. --------- Signed-off-by: will Farrell <willfarrell@proton.me>
1 parent 631b557 commit 688a3c5

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

packages/aws-durable-execution-sdk-js-testing/src/test-runner/local/__tests__/integration/local-durable-test-runner.integration.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,8 @@ describe("LocalDurableTestRunner Integration", () => {
251251

252252
const handler = withDurableExecution(
253253
async (_event: unknown, context: DurableContext) => {
254+
expect(context.lambdaContext.getRemainingTimeInMillis()).toBe(900_000);
255+
254256
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
255257
const mock1: string = await context.step(() => mockedFunction());
256258

packages/aws-durable-execution-sdk-js-testing/src/test-runner/local/__tests__/invoke-handler.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ describe("invoke-handler", () => {
192192
logStreamName: "MyLogStreamName",
193193
});
194194
expect(typeof context.getRemainingTimeInMillis).toBe("function");
195+
expect(context.getRemainingTimeInMillis()).toBe(900_000);
195196
});
196197

197198
it("should merge custom context values with defaults", () => {

packages/aws-durable-execution-sdk-js-testing/src/test-runner/local/invoke-handler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export class InvokeHandler {
3535
logGroupName: "MyLogGroupName",
3636
logStreamName: "MyLogStreamName",
3737
getRemainingTimeInMillis: function (): number {
38-
throw new Error("Function not implemented.");
38+
return 900_000
3939
},
4040
done: function (): void {
4141
throw new Error("Function not implemented.");

0 commit comments

Comments
 (0)