From d6d437c4dce9beb6b304c481812e65d6751cbeb7 Mon Sep 17 00:00:00 2001 From: Asher Gomez Date: Tue, 23 Jan 2024 23:07:54 +1100 Subject: 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. --- cli/tests/unit/cron_test.ts | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'cli/tests/unit') 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", + ); +}); -- cgit v1.2.3