summaryrefslogtreecommitdiff
path: root/cli/tests/unit/cron_test.ts
diff options
context:
space:
mode:
authorAsher Gomez <ashersaupingomez@gmail.com>2024-01-23 23:07:54 +1100
committerGitHub <noreply@github.com>2024-01-23 17:37:54 +0530
commitd6d437c4dce9beb6b304c481812e65d6751cbeb7 (patch)
tree5284d5b294a39204005b3aad8a752d10fc3dec67 /cli/tests/unit/cron_test.ts
parent6238b0a4579539a627d192e0ce2c4a10993aeb8c (diff)
BREAKING(unstable): remove `Deno.cron()` overload (#22035)
This change removes the currently deprecated `Deno.cron()` overload with `options` as a potential last argument. This might be fine to do now, in a major release, as `Deno.cron()` is an unstable API. I thought of doing this while working on #22021. If this is not ready to remove, I can instead set the removal version of this overload for Deno v2. Note: this overload was deprecated in Deno v1.38.2 (#21225). So it's been deprecated for over 2 months.
Diffstat (limited to 'cli/tests/unit/cron_test.ts')
-rw-r--r--cli/tests/unit/cron_test.ts19
1 files changed, 15 insertions, 4 deletions
diff --git a/cli/tests/unit/cron_test.ts b/cli/tests/unit/cron_test.ts
index 8408acf45..ed4500624 100644
--- a/cli/tests/unit/cron_test.ts
+++ b/cli/tests/unit/cron_test.ts
@@ -297,13 +297,13 @@ Deno.test(async function retriesWithBackoffScheduleOldApi() {
let count = 0;
const ac = new AbortController();
- const c = Deno.cron("abc2", "*/20 * * * *", async () => {
+ const c = Deno.cron("abc2", "*/20 * * * *", {
+ signal: ac.signal,
+ backoffSchedule: [10, 20],
+ }, async () => {
count += 1;
await sleep(10);
throw new TypeError("cron error");
- }, {
- signal: ac.signal,
- backoffSchedule: [10, 20],
});
try {
@@ -380,3 +380,14 @@ Deno.test("Parse schedule to string - string", () => {
const result = parseScheduleToString("* * * * *");
assertEquals(result, "* * * * *");
});
+
+Deno.test("error on two handlers", () => {
+ assertThrows(
+ () => {
+ // @ts-ignore test
+ Deno.cron("abc", "* * * * *", () => {}, () => {});
+ },
+ TypeError,
+ "Deno.cron requires a single handler",
+ );
+});