zerobyte/app/test/helpers/repository.ts
2026-01-17 21:36:53 +01:00

24 lines
739 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";
export const createTestRepository = async (overrides: Partial<RepositoryInsert> = {}) => {
await ensureTestOrganization();
const repository: RepositoryInsert = {
id: faker.string.alphanumeric(6),
name: faker.string.alphanumeric(10),
shortId: faker.string.alphanumeric(6),
config: {
name: "test-repo",
backend: "local",
},
type: "local",
organizationId: TEST_ORG_ID,
...overrides,
};
const data = await db.insert(repositoriesTable).values(repository).returning();
return data[0];
};