@@ -157,13 +157,23 @@ mod test {
157
157
use primitives:: event_submission:: { RateLimit , Rule } ;
158
158
use primitives:: sentry:: Event ;
159
159
use primitives:: util:: tests:: prep_db:: DUMMY_CHANNEL ;
160
- use primitives:: { Channel , EventSubmission } ;
160
+ use primitives:: { Channel , EventSubmission , Config } ;
161
161
162
162
use crate :: db:: redis_connection;
163
163
use crate :: Session ;
164
164
165
165
use super :: * ;
166
166
167
+ async fn setup ( ) -> ( Config , SharedConnection ) {
168
+ let mut redis = redis_connection ( ) . await . expect ( "Couldn't connect to Redis" ) ;
169
+ let config = configuration ( "development" , None ) . expect ( "Failed to get dev configuration" ) ;
170
+
171
+ // run `FLUSHALL` to clean any leftovers of other tests
172
+ let _ = redis:: cmd ( "FLUSHALL" ) . query_async :: < _ , String > ( & mut redis) . await ;
173
+
174
+ ( config, redis)
175
+ }
176
+
167
177
fn get_channel ( with_rule : Rule ) -> Channel {
168
178
let mut channel = DUMMY_CHANNEL . clone ( ) ;
169
179
@@ -184,8 +194,7 @@ mod test {
184
194
185
195
#[ tokio:: test]
186
196
async fn session_uid_rate_limit ( ) {
187
- let redis = redis_connection ( ) . await . expect ( "Couldn't connect to Redis" ) ;
188
- let config = configuration ( "development" , None ) . expect ( "Failed to get dev configuration" ) ;
197
+ let ( config, redis) = setup ( ) . await ;
189
198
190
199
let session = Session {
191
200
era : 0 ,
@@ -219,8 +228,7 @@ mod test {
219
228
220
229
#[ tokio:: test]
221
230
async fn ip_rate_limit ( ) {
222
- let redis = redis_connection ( ) . await . expect ( "Couldn't connect to Redis" ) ;
223
- let config = configuration ( "development" , None ) . expect ( "Failed to get dev configuration" ) ;
231
+ let ( config, redis) = setup ( ) . await ;
224
232
225
233
let session = Session {
226
234
era : 0 ,
0 commit comments