zerobyte/app/test/helpers/repository.ts
Nico 1017f1a38b
feat: edit repository form (#507)
* feat: edit repository form

* refactor: local repo path concat as a code migration

* refactor: server constants

* chore: fix lint issue in test file

* refactor: add auth to getServerConstants
2026-02-14 11:49:33 +01:00

24 lines
792 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: {
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];
};