File tree Expand file tree Collapse file tree 1 file changed +14
-21
lines changed
crates/pgls_splinter/tests Expand file tree Collapse file tree 1 file changed +14
-21
lines changed Original file line number Diff line number Diff line change 11use pgls_console:: fmt:: { Formatter , HTML } ;
22use pgls_diagnostics:: { Diagnostic , LogCategory , Visit } ;
3- use pgls_splinter:: { SplinterParams , run_splinter } ;
3+ use pgls_splinter:: { run_splinter , SplinterParams } ;
44use sqlx:: PgPool ;
55use std:: fmt:: Write ;
66use std:: io;
@@ -52,26 +52,19 @@ struct TestSetup<'a> {
5252impl TestSetup < ' _ > {
5353 async fn test ( self ) {
5454 // Create Supabase-specific roles that splinter expects
55- sqlx:: raw_sql (
56- r#"
57- do $$
58- begin
59- if not exists (select from pg_roles where rolname = 'anon') then
60- create role anon nologin;
61- end if;
62- if not exists (select from pg_roles where rolname = 'authenticated') then
63- create role authenticated nologin;
64- end if;
65- if not exists (select from pg_roles where rolname = 'service_role') then
66- create role service_role nologin;
67- end if;
68- end
69- $$;
70- "# ,
71- )
72- . execute ( self . test_db )
73- . await
74- . expect ( "Failed to create Supabase roles" ) ;
55+ for role in [ "anon" , "authenticated" , "service_role" ] {
56+ let result = sqlx:: query ( & format ! ( "CREATE ROLE {role} NOLOGIN" ) )
57+ . execute ( self . test_db )
58+ . await ;
59+
60+ // Ignore duplicate role errors
61+ if let Err ( sqlx:: Error :: Database ( db_err) ) = & result {
62+ let code = db_err. code ( ) ;
63+ if code. as_deref ( ) != Some ( "23505" ) && code. as_deref ( ) != Some ( "42710" ) {
64+ result. expect ( "Failed to create Supabase roles" ) ;
65+ }
66+ }
67+ }
7568
7669 // Run setup SQL
7770 sqlx:: raw_sql ( self . setup )
You can’t perform that action at this time.
0 commit comments