File tree Expand file tree Collapse file tree
packages/supabase-test/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import { PgTestClient } from 'pgsql-test' ;
2+
3+ /**
4+ * Helper function to insert a new user into auth.users
5+ * @param client - The PgTestClient to use (pg or db)
6+ * @param email - The user's email address
7+ * @param id - Optional user ID (UUID). If not provided, a random UUID will be generated.
8+ * @returns The inserted user object with id and email
9+ */
10+ export async function insertUser (
11+ client : PgTestClient ,
12+ email : string ,
13+ id ?: string
14+ ) : Promise < { id : string ; email : string } > {
15+ if ( id ) {
16+ return await client . one (
17+ `INSERT INTO auth.users (id, email)
18+ VALUES ($1, $2)
19+ RETURNING id, email` ,
20+ [ id , email ]
21+ ) ;
22+ } else {
23+ return await client . one (
24+ `INSERT INTO auth.users (id, email)
25+ VALUES (gen_random_uuid(), $1)
26+ RETURNING id, email` ,
27+ [ email ]
28+ ) ;
29+ }
30+ }
Original file line number Diff line number Diff line change 11// Re-export everything from pgsql-test
22export * from 'pgsql-test' ;
33
4+ // Re-export everything from helpers.ts
5+ export * from './helpers' ;
6+
47// Export Supabase-specific getConnections with defaults baked in
58export { getConnections } from './connect' ;
69export type { GetConnectionOpts , GetConnectionResult } from './connect' ;
You can’t perform that action at this time.
0 commit comments