@@ -76,12 +76,33 @@ mod tests {
7676 "Failed to insert into test_expected table"
7777 ) ;
7878
79- // copy to stdout
79+ // create a dummy role
80+ let role = "dummy" ;
81+ let output = Command :: new ( "psql" )
82+ . arg ( "-p" )
83+ . arg ( test_port. clone ( ) )
84+ . arg ( "-h" )
85+ . arg ( "localhost" )
86+ . arg ( "-d" )
87+ . arg ( "pgrx_tests" )
88+ . arg ( "-c" )
89+ . arg ( format ! (
90+ "CREATE ROLE {role} LOGIN;
91+ GRANT SELECT, INSERT, UPDATE, DELETE ON test_expected TO {role};
92+ GRANT SELECT, INSERT, UPDATE, DELETE ON test_result TO {role};"
93+ ) )
94+ . output ( )
95+ . expect ( "failed to execute process" ) ;
96+ assert ! ( output. status. success( ) , "Failed to create role {role}" ) ;
97+
98+ // copy to stdout with dummy role
8099 let mut copy_to = Command :: new ( "psql" )
81100 . arg ( "-p" )
82101 . arg ( test_port. clone ( ) )
83102 . arg ( "-h" )
84103 . arg ( "localhost" )
104+ . arg ( "-U" )
105+ . arg ( role)
85106 . arg ( "-d" )
86107 . arg ( "pgrx_tests" )
87108 . arg ( "-c" )
@@ -101,12 +122,14 @@ mod tests {
101122 assert ! ( status. success( ) , "psql COPY TO process did not succeed" ) ;
102123 }
103124
104- // copy from stdin
125+ // copy from stdin with dummy role
105126 let mut copy_from = Command :: new ( "psql" )
106127 . arg ( "-p" )
107128 . arg ( test_port. clone ( ) )
108129 . arg ( "-h" )
109130 . arg ( "localhost" )
131+ . arg ( "-U" )
132+ . arg ( role)
110133 . arg ( "-d" )
111134 . arg ( "pgrx_tests" )
112135 . arg ( "-c" )
@@ -178,7 +201,7 @@ mod tests {
178201 ]
179202 ) ;
180203
181- // drop test_expected
204+ // drop tables and role
182205 let output = Command :: new ( "psql" )
183206 . arg ( "-p" )
184207 . arg ( test_port. clone ( ) )
@@ -187,26 +210,11 @@ mod tests {
187210 . arg ( "-d" )
188211 . arg ( "pgrx_tests" )
189212 . arg ( "-c" )
190- . arg ( "DROP TABLE test_expected;" )
191- . output ( )
192- . expect ( "failed to execute process" ) ;
193- assert ! (
194- output. status. success( ) ,
195- "Failed to drop test_expected table"
196- ) ;
197-
198- // drop test_result
199- let output = Command :: new ( "psql" )
200- . arg ( "-p" )
201- . arg ( test_port. clone ( ) )
202- . arg ( "-h" )
203- . arg ( "localhost" )
204- . arg ( "-d" )
205- . arg ( "pgrx_tests" )
206- . arg ( "-c" )
207- . arg ( "DROP TABLE test_result;" )
213+ . arg ( format ! (
214+ "DROP TABLE test_expected, test_result; DROP ROLE {role};"
215+ ) )
208216 . output ( )
209217 . expect ( "failed to execute process" ) ;
210- assert ! ( output. status. success( ) , "Failed to drop test_result table " ) ;
218+ assert ! ( output. status. success( ) , "Failed to clean up " ) ;
211219 }
212220}
0 commit comments