mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 16:28:26 +00:00
test(telegram): cover getFile file-too-big errors
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import type { Message } from "@grammyjs/types";
|
||||
import { GrammyError } from "grammy";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import type { TelegramContext } from "./types.js";
|
||||
|
||||
@@ -150,6 +151,21 @@ describe("resolveMedia getFile retry", () => {
|
||||
expect(result).toBeNull();
|
||||
});
|
||||
|
||||
it("does not retry 'file is too big' GrammyError instances and returns null", async () => {
|
||||
const fileTooBigError = new GrammyError(
|
||||
"Call to 'getFile' failed!",
|
||||
{ error_code: 400, description: "Bad Request: file is too big" },
|
||||
"getFile",
|
||||
{},
|
||||
);
|
||||
const getFile = vi.fn().mockRejectedValue(fileTooBigError);
|
||||
|
||||
const result = await resolveMedia(makeCtx("video", getFile), 10_000_000, "tok123");
|
||||
|
||||
expect(getFile).toHaveBeenCalledTimes(1);
|
||||
expect(result).toBeNull();
|
||||
});
|
||||
|
||||
it("returns null for audio when file is too big", async () => {
|
||||
const fileTooBigError = new Error(
|
||||
"GrammyError: Call to 'getFile' failed! (400: Bad Request: file is too big)",
|
||||
|
||||
Reference in New Issue
Block a user