MCPcopy Create free account
hub / github.com/pollinations/pollinations / createTestUser

Function createTestUser

shared/test/fixtures/api-keys.ts:34–54  ·  view source on GitHub ↗
(opts: CreateTestUserOptions = {})

Source from the content-addressed store, hash-verified

32};
33
34export 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
56export async function createTestApiKey(opts: CreateTestApiKeyOptions = {}) {
57 const userId = opts.userId ?? (await createTestUser(opts.user));

Callers 2

createTestApiKeyFunction · 0.85

Calls 1

valuesMethod · 0.80

Tested by

no test coverage detected