@@ -19,7 +19,7 @@ async fn search_config_exists(
1919 SELECT id FROM eql_v2_configuration c
2020 WHERE c.state = $1::eql_v2_configuration_state
2121 AND c.data #> array['tables', $2, $3, 'indexes'] ? $4
22- )"
22+ )" ,
2323 )
2424 . bind ( state)
2525 . bind ( table_name)
@@ -52,9 +52,11 @@ async fn add_and_remove_multiple_indexes(pool: PgPool) -> Result<()> {
5252 ) ;
5353
5454 // Add unique index with cast
55- sqlx:: query ( "SELECT eql_v2.add_search_config('users', 'name', 'unique', 'int', migrating => true)" )
56- . execute ( & pool)
57- . await ?;
55+ sqlx:: query (
56+ "SELECT eql_v2.add_search_config('users', 'name', 'unique', 'int', migrating => true)" ,
57+ )
58+ . execute ( & pool)
59+ . await ?;
5860
5961 assert ! (
6062 search_config_exists( & pool, "users" , "name" , "unique" , "pending" ) . await ?,
@@ -67,7 +69,7 @@ async fn add_and_remove_multiple_indexes(pool: PgPool) -> Result<()> {
6769 SELECT id FROM eql_v2_configuration c
6870 WHERE c.state = 'pending'
6971 AND c.data #> array['tables', 'users', 'name'] ? 'cast_as'
70- )"
72+ )" ,
7173 )
7274 . fetch_one ( & pool)
7375 . await ?;
@@ -93,7 +95,7 @@ async fn add_and_remove_multiple_indexes(pool: PgPool) -> Result<()> {
9395 let indexes_empty: bool = sqlx:: query_scalar (
9496 "SELECT data #> array['tables', 'users', 'name', 'indexes'] = '{}'
9597 FROM eql_v2_configuration c
96- WHERE c.state = 'pending'"
98+ WHERE c.state = 'pending'" ,
9799 )
98100 . fetch_one ( & pool)
99101 . await ?;
@@ -127,17 +129,19 @@ async fn add_and_remove_indexes_from_multiple_tables(pool: PgPool) -> Result<()>
127129 SELECT id FROM eql_v2_configuration c
128130 WHERE c.state = 'pending'
129131 AND c.data #> array['tables', 'users', 'name', 'indexes'] ? 'match'
130- )"
132+ )" ,
131133 )
132134 . fetch_one ( & pool)
133135 . await ?;
134136
135137 assert ! ( has_match, "users.name.indexes should contain match" ) ;
136138
137139 // Add index to blah table
138- sqlx:: query ( "SELECT eql_v2.add_search_config('blah', 'vtha', 'unique', 'int', migrating => true)" )
139- . execute ( & pool)
140- . await ?;
140+ sqlx:: query (
141+ "SELECT eql_v2.add_search_config('blah', 'vtha', 'unique', 'int', migrating => true)" ,
142+ )
143+ . execute ( & pool)
144+ . await ?;
141145
142146 assert ! (
143147 search_config_exists( & pool, "blah" , "vtha" , "unique" , "pending" ) . await ?,
@@ -155,7 +159,7 @@ async fn add_and_remove_indexes_from_multiple_tables(pool: PgPool) -> Result<()>
155159 SELECT id FROM eql_v2_configuration c
156160 WHERE c.state = 'pending'
157161 AND c.data #> array['tables', 'blah', 'vtha', 'indexes'] ? 'unique'
158- )"
162+ )" ,
159163 )
160164 . fetch_one ( & pool)
161165 . await ?;
@@ -184,7 +188,7 @@ async fn add_and_remove_indexes_from_multiple_tables(pool: PgPool) -> Result<()>
184188
185189 // Verify config still exists but indexes are empty
186190 let config_exists: bool = sqlx:: query_scalar (
187- "SELECT EXISTS (SELECT FROM eql_v2_configuration c WHERE c.state = 'pending')"
191+ "SELECT EXISTS (SELECT FROM eql_v2_configuration c WHERE c.state = 'pending')" ,
188192 )
189193 . fetch_one ( & pool)
190194 . await ?;
@@ -194,12 +198,15 @@ async fn add_and_remove_indexes_from_multiple_tables(pool: PgPool) -> Result<()>
194198 let blah_indexes_empty: bool = sqlx:: query_scalar (
195199 "SELECT data #> array['tables', 'blah', 'vtha', 'indexes'] = '{}'
196200 FROM eql_v2_configuration c
197- WHERE c.state = 'pending'"
201+ WHERE c.state = 'pending'" ,
198202 )
199203 . fetch_one ( & pool)
200204 . await ?;
201205
202- assert ! ( blah_indexes_empty, "blah.vtha.indexes should be empty object" ) ;
206+ assert ! (
207+ blah_indexes_empty,
208+ "blah.vtha.indexes should be empty object"
209+ ) ;
203210
204211 Ok ( ( ) )
205212}
@@ -236,7 +243,7 @@ async fn add_and_modify_index(pool: PgPool) -> Result<()> {
236243 SELECT id FROM eql_v2_configuration c
237244 WHERE c.state = 'pending'
238245 AND c.data #> array['tables', 'users', 'name', 'indexes', 'match'] ? 'option'
239- )"
246+ )" ,
240247 )
241248 . fetch_one ( & pool)
242249 . await ?;
@@ -249,7 +256,7 @@ async fn add_and_modify_index(pool: PgPool) -> Result<()> {
249256 SELECT id FROM eql_v2_configuration c
250257 WHERE c.state = 'pending'
251258 AND c.data #> array['tables', 'users', 'name'] ? 'cast_as'
252- )"
259+ )" ,
253260 )
254261 . fetch_one ( & pool)
255262 . await ?;
@@ -263,7 +270,7 @@ async fn add_and_modify_index(pool: PgPool) -> Result<()> {
263270
264271 // Verify config exists but indexes empty
265272 let config_exists: bool = sqlx:: query_scalar (
266- "SELECT EXISTS (SELECT FROM eql_v2_configuration c WHERE c.state = 'pending')"
273+ "SELECT EXISTS (SELECT FROM eql_v2_configuration c WHERE c.state = 'pending')" ,
267274 )
268275 . fetch_one ( & pool)
269276 . await ?;
@@ -273,7 +280,7 @@ async fn add_and_modify_index(pool: PgPool) -> Result<()> {
273280 let indexes_empty: bool = sqlx:: query_scalar (
274281 "SELECT data #> array['tables', 'users', 'name', 'indexes'] = '{}'
275282 FROM eql_v2_configuration c
276- WHERE c.state = 'pending'"
283+ WHERE c.state = 'pending'" ,
277284 )
278285 . fetch_one ( & pool)
279286 . await ?;
@@ -312,7 +319,7 @@ async fn add_index_with_existing_active_config(pool: PgPool) -> Result<()> {
312319 }
313320 }
314321 }'::jsonb
315- )"
322+ )" ,
316323 )
317324 . execute ( & pool)
318325 . await ?;
@@ -362,11 +369,9 @@ async fn add_column_to_nonexistent_table_fails(pool: PgPool) -> Result<()> {
362369 ) ;
363370
364371 // Verify no configuration was created
365- let config_count: i64 = sqlx:: query_scalar (
366- "SELECT COUNT(*) FROM eql_v2_configuration"
367- )
368- . fetch_one ( & pool)
369- . await ?;
372+ let config_count: i64 = sqlx:: query_scalar ( "SELECT COUNT(*) FROM eql_v2_configuration" )
373+ . fetch_one ( & pool)
374+ . await ?;
370375
371376 assert_eq ! ( config_count, 0 , "no configuration should be created" ) ;
372377
@@ -387,11 +392,10 @@ async fn add_and_remove_column(pool: PgPool) -> Result<()> {
387392 . await ?;
388393
389394 // Verify pending configuration was created
390- let pending_count: i64 = sqlx:: query_scalar (
391- "SELECT COUNT(*) FROM eql_v2_configuration c WHERE c.state = 'pending'"
392- )
393- . fetch_one ( & pool)
394- . await ?;
395+ let pending_count: i64 =
396+ sqlx:: query_scalar ( "SELECT COUNT(*) FROM eql_v2_configuration c WHERE c.state = 'pending'" )
397+ . fetch_one ( & pool)
398+ . await ?;
395399
396400 assert_eq ! ( pending_count, 1 , "pending configuration should be created" ) ;
397401
@@ -402,7 +406,7 @@ async fn add_and_remove_column(pool: PgPool) -> Result<()> {
402406
403407 // Verify pending configuration still exists but is empty
404408 let pending_exists: bool = sqlx:: query_scalar (
405- "SELECT EXISTS (SELECT FROM eql_v2_configuration c WHERE c.state = 'pending')"
409+ "SELECT EXISTS (SELECT FROM eql_v2_configuration c WHERE c.state = 'pending')" ,
406410 )
407411 . fetch_one ( & pool)
408412 . await ?;
@@ -413,7 +417,7 @@ async fn add_and_remove_column(pool: PgPool) -> Result<()> {
413417 let tables_empty: bool = sqlx:: query_scalar (
414418 "SELECT data #> array['tables'] = '{}'
415419 FROM eql_v2_configuration c
416- WHERE c.state = 'pending'"
420+ WHERE c.state = 'pending'" ,
417421 )
418422 . fetch_one ( & pool)
419423 . await ?;
@@ -443,7 +447,7 @@ async fn configuration_constraint_validation(pool: PgPool) -> Result<()> {
443447 }
444448 }
445449 }'::jsonb
446- )"
450+ )" ,
447451 )
448452 . execute ( & pool)
449453 . await ;
@@ -469,15 +473,12 @@ async fn configuration_constraint_validation(pool: PgPool) -> Result<()> {
469473 }
470474 }
471475 }'::jsonb
472- )"
476+ )" ,
473477 )
474478 . execute ( & pool)
475479 . await ;
476480
477- assert ! (
478- result3. is_err( ) ,
479- "insert with invalid cast should fail"
480- ) ;
481+ assert ! ( result3. is_err( ) , "insert with invalid cast should fail" ) ;
481482
482483 // Test 4: Invalid index - should fail
483484 let result4 = sqlx:: query (
@@ -494,24 +495,24 @@ async fn configuration_constraint_validation(pool: PgPool) -> Result<()> {
494495 }
495496 }
496497 }'::jsonb
497- )"
498+ )" ,
498499 )
499500 . execute ( & pool)
500501 . await ;
501502
502- assert ! (
503- result4. is_err( ) ,
504- "insert with invalid index should fail"
505- ) ;
503+ assert ! ( result4. is_err( ) , "insert with invalid index should fail" ) ;
506504
507505 // Verify no pending configuration was created
508506 let pending_exists: bool = sqlx:: query_scalar (
509- "SELECT EXISTS (SELECT FROM eql_v2_configuration c WHERE c.state = 'pending')"
507+ "SELECT EXISTS (SELECT FROM eql_v2_configuration c WHERE c.state = 'pending')" ,
510508 )
511509 . fetch_one ( & pool)
512510 . await ?;
513511
514- assert ! ( !pending_exists, "no pending configuration should be created" ) ;
512+ assert ! (
513+ !pending_exists,
514+ "no pending configuration should be created"
515+ ) ;
515516
516517 Ok ( ( ) )
517518}
0 commit comments