Skip to content

Commit 532922b

Browse files
committed
chore: cargo fmt fixes
1 parent 8e655be commit 532922b

File tree

7 files changed

+197
-188
lines changed

7 files changed

+197
-188
lines changed

tests/sqlx/tests/config_tests.rs

Lines changed: 45 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

tests/sqlx/tests/constraint_tests.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,9 @@ async fn foreign_key_constraint_with_encrypted(pool: PgPool) -> Result<()> {
184184

185185
// Successfully insert child record with FK to same deterministic value
186186
// This SUCCEEDS because create_encrypted_json(1, 'hm') returns identical bytes each time
187-
sqlx::query(
188-
"INSERT INTO child (id, parent_id) VALUES (1, create_encrypted_json(1, 'hm'))",
189-
)
190-
.execute(&pool)
191-
.await?;
187+
sqlx::query("INSERT INTO child (id, parent_id) VALUES (1, create_encrypted_json(1, 'hm'))")
188+
.execute(&pool)
189+
.await?;
192190

193191
// Verify child record was inserted
194192
let child_count: i64 = sqlx::query_scalar("SELECT COUNT(*) FROM child")
@@ -201,11 +199,10 @@ async fn foreign_key_constraint_with_encrypted(pool: PgPool) -> Result<()> {
201199
);
202200

203201
// Attempt to insert child with different encrypted value (should fail FK check)
204-
let different_insert_result = sqlx::query(
205-
"INSERT INTO child (id, parent_id) VALUES (2, create_encrypted_json(2, 'hm'))",
206-
)
207-
.execute(&pool)
208-
.await;
202+
let different_insert_result =
203+
sqlx::query("INSERT INTO child (id, parent_id) VALUES (2, create_encrypted_json(2, 'hm'))")
204+
.execute(&pool)
205+
.await;
209206

210207
assert!(
211208
different_insert_result.is_err(),
@@ -217,7 +214,10 @@ async fn foreign_key_constraint_with_encrypted(pool: PgPool) -> Result<()> {
217214
.fetch_one(&pool)
218215
.await?;
219216

220-
assert_eq!(final_count, 1, "FK violation should prevent second child insert");
217+
assert_eq!(
218+
final_count, 1,
219+
"FK violation should prevent second child insert"
220+
);
221221

222222
Ok(())
223223
}

0 commit comments

Comments
 (0)