Files
zerobyte/app/test/helpers/volume.ts
Nico a0a813ed09 refactor: short id branded type (#552)
* refactor: short id branded type

* chore: pr feedbacks
2026-02-21 11:16:15 +01:00

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];
};