(opts: CreateTestUserOptions = {})
| 32 | }; |
| 33 | |
| 34 | export async function createTestUser(opts: CreateTestUserOptions = {}) { |
| 35 | const db = drizzle(env.DB); |
| 36 | const userId = opts.id ?? `test-user-${crypto.randomUUID()}`; |
| 37 | |
| 38 | await db.insert(userTable).values({ |
| 39 | id: userId, |
| 40 | name: opts.name ?? "Test User", |
| 41 | email: opts.email ?? `${userId}@test.local`, |
| 42 | emailVerified: true, |
| 43 | image: null, |
| 44 | tier: opts.tier ?? "flower", |
| 45 | tierBalance: opts.tierBalance ?? 1000, |
| 46 | packBalance: opts.packBalance ?? 0, |
| 47 | githubId: opts.githubId ?? null, |
| 48 | githubUsername: opts.githubUsername ?? null, |
| 49 | createdAt: new Date(), |
| 50 | updatedAt: new Date(), |
| 51 | }); |
| 52 | |
| 53 | return userId; |
| 54 | } |
| 55 | |
| 56 | export async function createTestApiKey(opts: CreateTestApiKeyOptions = {}) { |
| 57 | const userId = opts.userId ?? (await createTestUser(opts.user)); |
no test coverage detected