zerobyte/app/test/helpers/repository.ts
Nico 61dc07b36b
Controllers tests (#187)
* test: backups service

* refactor: create hono app in a separate file

To avoid side effects like db migration or startup scripts when testing

test(backups): add security tests to the backups controller

* ci: run typechecks, build and tests on PR

* test: controllers security tests

* chore: update lock file

* refactor: pr feedbacks
2025-12-19 19:25:21 +01:00

20 lines
604 B
TypeScript

import { db } from "~/server/db/db";
import { faker } from "@faker-js/faker";
import { repositoriesTable, type RepositoryInsert } from "~/server/db/schema";
export const createTestRepository = async (overrides: Partial<RepositoryInsert> = {}) => {
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",
...overrides,
};
const data = await db.insert(repositoriesTable).values(repository).returning();
return data[0];
};