mirror of
https://github.com/nicotsx/zerobyte.git
synced 2026-04-18 05:47:31 -04:00
27 lines
785 B
TypeScript
27 lines
785 B
TypeScript
import { db } from "~/server/db/db";
|
|
import { faker } from "@faker-js/faker";
|
|
import { volumesTable, type VolumeInsert } from "~/server/db/schema";
|
|
import { ensureTestOrganization, TEST_ORG_ID } from "./organization";
|
|
import { generateShortId } from "~/server/utils/id";
|
|
|
|
export const createTestVolume = async (overrides: Partial<VolumeInsert> = {}) => {
|
|
await ensureTestOrganization();
|
|
|
|
const volume: VolumeInsert = {
|
|
name: faker.system.fileName(),
|
|
config: {
|
|
backend: "directory",
|
|
path: `/mnt/volumes/${faker.system.fileName()}`,
|
|
},
|
|
status: "mounted",
|
|
autoRemount: true,
|
|
shortId: generateShortId(),
|
|
type: "directory",
|
|
organizationId: TEST_ORG_ID,
|
|
...overrides,
|
|
};
|
|
|
|
const data = await db.insert(volumesTable).values(volume).returning();
|
|
return data[0];
|
|
};
|