test(memory): cover shared batch output and error helpers
This commit is contained in:
26
src/memory/batch-error-utils.test.ts
Normal file
26
src/memory/batch-error-utils.test.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { extractBatchErrorMessage, formatUnavailableBatchError } from "./batch-error-utils.js";
|
||||
|
||||
describe("extractBatchErrorMessage", () => {
|
||||
it("returns the first top-level error message", () => {
|
||||
expect(
|
||||
extractBatchErrorMessage([
|
||||
{ response: { body: { error: { message: "nested" } } } },
|
||||
{ error: { message: "top-level" } },
|
||||
]),
|
||||
).toBe("nested");
|
||||
});
|
||||
|
||||
it("falls back to nested response error message", () => {
|
||||
expect(
|
||||
extractBatchErrorMessage([{ response: { body: { error: { message: "nested-only" } } } }, {}]),
|
||||
).toBe("nested-only");
|
||||
});
|
||||
});
|
||||
|
||||
describe("formatUnavailableBatchError", () => {
|
||||
it("formats errors and non-error values", () => {
|
||||
expect(formatUnavailableBatchError(new Error("boom"))).toBe("error file unavailable: boom");
|
||||
expect(formatUnavailableBatchError("unreachable")).toBe("error file unavailable: unreachable");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user