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

16 lines
532 B
TypeScript

import { db } from "~/server/db/db";
import { faker } from "@faker-js/faker";
import { backupSchedulesTable, type BackupScheduleInsert } from "~/server/db/schema";
export const createTestBackupSchedule = async (overrides: Partial<BackupScheduleInsert> = {}) => {
const backup: BackupScheduleInsert = {
name: faker.system.fileName(),
cronExpression: "0 0 * * *",
repositoryId: "repo_123",
volumeId: 1,
...overrides,
};
const data = await db.insert(backupSchedulesTable).values(backup).returning();
return data[0];
};