* feat(db): add support for multiple users and organizations * feat: backfill entities with new organization id * refactor: filter all backend queries to surface only organization specific entities * refactor: each org has its own restic password * test: ensure organization is created * chore: pr feedbacks * refactor: filter by org id in all places * refactor: download restic password from stored db password * refactor(navigation): use volume id in urls instead of name * feat: disable registrations * refactor(auth): bubble up auth error to hono * refactor: use async local storage for cleaner context sharing * refactor: enable user registration vs disabling it * test: multi-org isolation * chore: final cleanup
24 lines
739 B
TypeScript
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];
|
|
};
|