fix(images): bound external runtime processing
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import type { ModuleStorage } from "@ekklesia/module-sdk";
|
||||
import sharp from "sharp";
|
||||
import { beforeEach, describe, expect, it } from "vitest";
|
||||
import { SignageError } from "../src/server/errors.js";
|
||||
@@ -372,6 +373,30 @@ describe("native image ingest", () => {
|
||||
expect(store.images.size).toBe(0);
|
||||
});
|
||||
|
||||
it("recognizes a sanitized storage failure from the host's separate SDK copy", async () => {
|
||||
const bucket = storage.bucket("native-images");
|
||||
const externalError = Object.assign(new Error("The storage service could not be reached."), {
|
||||
code: "STORAGE_PROVIDER_UNAVAILABLE",
|
||||
name: "ModuleStorageError",
|
||||
});
|
||||
const externalStorage: ModuleStorage = {
|
||||
bucket: () => ({ ...bucket, put: () => Promise.reject(externalError) }),
|
||||
buckets: () => ["native-images"],
|
||||
};
|
||||
|
||||
await expectSignageCode(
|
||||
ingestNativeImage({
|
||||
bytes: await makeImage({ format: "png", height: 360, width: 640 }),
|
||||
displayName: "welcome.png",
|
||||
expiresAt: null,
|
||||
filename: "welcome.png",
|
||||
storage: externalStorage,
|
||||
store,
|
||||
}),
|
||||
"SIGNAGE_STORAGE_UNAVAILABLE",
|
||||
);
|
||||
});
|
||||
|
||||
it("treats a race with an identical upload as a success rather than a failure", async () => {
|
||||
const bytes = await makeImage({ format: "png", height: 1080, width: 1920 });
|
||||
const first = await ingest(bytes);
|
||||
|
||||
Reference in New Issue
Block a user