Add test for retry policy falling back to defaults for invalid values#306
Add test for retry policy falling back to defaults for invalid values#306jamescmartinez merged 1 commit intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a test case to verify that the resolveRetryPolicy function falls back to default values when invalid runtime values are provided. The test checks behavior for invalid inputs including NaN, negative numbers, and invalid duration strings.
Changes:
- Added a test case
"falls back to defaults for invalid runtime values"to verify validation behavior
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| test("falls back to defaults for invalid runtime values", () => { | ||
| const result = resolveRetryPolicy({ | ||
| maximumAttempts: Number.NaN, | ||
| backoffCoefficient: -1, | ||
| initialInterval: "-1s" as "1s", | ||
| maximumInterval: "invalid" as "1s", | ||
| }); | ||
|
|
||
| expect(result).toEqual(DEFAULT_WORKFLOW_RETRY_POLICY); | ||
| }); |
There was a problem hiding this comment.
This test expects resolveRetryPolicy to validate and reject invalid runtime values (NaN, negative numbers, invalid duration strings), but the current implementation (worker.ts:324-329) simply spreads the partial object over defaults without validation. This means invalid values like Number.NaN, -1, "-1s", and "invalid" will be included in the result, causing the test to fail. The implementation needs to be updated to validate each field and fall back to defaults for invalid values, or this test should be removed/modified to match the actual behavior.
| test("falls back to defaults for invalid runtime values", () => { | |
| const result = resolveRetryPolicy({ | |
| maximumAttempts: Number.NaN, | |
| backoffCoefficient: -1, | |
| initialInterval: "-1s" as "1s", | |
| maximumInterval: "invalid" as "1s", | |
| }); | |
| expect(result).toEqual(DEFAULT_WORKFLOW_RETRY_POLICY); | |
| }); |
No description provided.