Files
zerobyte/app/test/helpers/repository.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

26 lines
834 B
TypeScript

import { db } from "~/server/db/db";
import { faker } from "@faker-js/faker";
import { repositoriesTable, type RepositoryInsert } from "~/server/db/schema";
import { ensureTestOrganization, TEST_ORG_ID } from "./organization";
import { generateShortId } from "~/server/utils/id";
export const createTestRepository = async (overrides: Partial<RepositoryInsert> = {}) => {
await ensureTestOrganization();
const repository: RepositoryInsert = {
id: faker.string.alphanumeric(6),
name: faker.string.alphanumeric(10),
shortId: generateShortId(),
config: {
path: `/var/lib/zerobyte/repositories/${faker.string.alphanumeric(8)}`,
backend: "local",
},
type: "local",
organizationId: TEST_ORG_ID,
...overrides,
};
const data = await db.insert(repositoriesTable).values(repository).returning();
return data[0];
};