Self-host compose stack and production stability fixes

这个提交包含在:
cryptocommuniums-afk
2026-03-14 22:25:19 +08:00
父节点 f5ad0449a8
当前提交 8df0f91db7
修改 19 个文件,包含 329 行新增54 行删除

40
server/storage.test.ts 普通文件
查看文件

@@ -0,0 +1,40 @@
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { mkdtemp, rm } from "node:fs/promises";
import os from "node:os";
import path from "node:path";
const ORIGINAL_ENV = { ...process.env };
describe("storage fallback", () => {
let tempDir: string;
beforeEach(async () => {
vi.resetModules();
process.env = { ...ORIGINAL_ENV };
delete process.env.BUILT_IN_FORGE_API_URL;
delete process.env.BUILT_IN_FORGE_API_KEY;
tempDir = await mkdtemp(path.join(os.tmpdir(), "tennis-storage-"));
process.env.LOCAL_STORAGE_DIR = tempDir;
});
afterEach(async () => {
process.env = { ...ORIGINAL_ENV };
await rm(tempDir, { recursive: true, force: true });
});
it("stores files locally when remote storage is not configured", async () => {
const { storagePut, storageGet } = await import("./storage");
const stored = await storagePut("videos/test/sample.webm", Buffer.from("demo"));
const loaded = await storageGet("videos/test/sample.webm");
expect(stored).toEqual({
key: "videos/test/sample.webm",
url: "/uploads/videos/test/sample.webm",
});
expect(loaded).toEqual({
key: "videos/test/sample.webm",
url: "/uploads/videos/test/sample.webm",
});
});
});