Self-host compose stack and production stability fixes
这个提交包含在:
40
server/storage.test.ts
普通文件
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",
|
||||
});
|
||||
});
|
||||
});
|
||||
在新工单中引用
屏蔽一个用户