Skip to content

Commit 8ecfb2f

Browse files
committed
Format Rust sources
1 parent 98fd78e commit 8ecfb2f

6 files changed

Lines changed: 66 additions & 38 deletions

File tree

src/commands/init.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,9 @@ pub async fn init(
120120
&& !force_local
121121
{
122122
println!();
123-
tracing::info!("Tool version incompatible. Switching to SerenAI cloud execution...");
123+
tracing::info!(
124+
"Tool version incompatible. Switching to SerenAI cloud execution..."
125+
);
124126
// Return special error that main.rs catches to trigger remote
125127
bail!("PREFLIGHT_FALLBACK_TO_REMOTE");
126128
}

src/interactive.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,11 @@ pub async fn select_databases_and_tables(
9696

9797
let defaults: Vec<usize> = selected_db_indices.clone();
9898

99-
let selections = MultiSelect::new("Select databases to replicate:", db_names.clone())
100-
.with_default(&defaults)
101-
.with_help_message("↑↓ navigate, Space toggle, Enter confirm")
102-
.prompt();
99+
let selections =
100+
MultiSelect::new("Select databases to replicate:", db_names.clone())
101+
.with_default(&defaults)
102+
.with_help_message("↑↓ navigate, Space toggle, Enter confirm")
103+
.prompt();
103104

104105
match selections {
105106
Ok(selected) => {
@@ -183,7 +184,8 @@ pub async fn select_databases_and_tables(
183184
.iter()
184185
.filter_map(|t| {
185186
// Strip db name prefix to match display names
186-
let stripped = t.strip_prefix(&format!("{}.", db_name)).unwrap_or(t);
187+
let stripped =
188+
t.strip_prefix(&format!("{}.", db_name)).unwrap_or(t);
187189
table_display_names.iter().position(|n| n == stripped)
188190
})
189191
.collect()

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ async fn main() -> anyhow::Result<()> {
231231
no_interactive,
232232
table_rules,
233233
drop_existing,
234-
sync: _, // sync is the default behavior, no_sync overrides it
234+
sync: _, // sync is the default behavior, no_sync overrides it
235235
no_sync,
236236
no_resume,
237237
seren,

src/preflight.rs

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,10 @@ fn check_local_environment(result: &mut PreflightResult) {
225225
}
226226
Err(_) => {
227227
missing.push(tool);
228-
result
229-
.local_env
230-
.push(CheckResult::fail(tool, format!("{} not found in PATH", tool)));
228+
result.local_env.push(CheckResult::fail(
229+
tool,
230+
format!("{} not found in PATH", tool),
231+
));
231232
}
232233
}
233234
}
@@ -342,9 +343,10 @@ async fn check_source_permissions(result: &mut PreflightResult, source_url: &str
342343
match crate::postgres::check_source_privileges(&client).await {
343344
Ok(privs) => {
344345
if privs.has_replication || privs.is_superuser {
345-
result
346-
.source_permissions
347-
.push(CheckResult::pass("replication", "Has REPLICATION privilege"));
346+
result.source_permissions.push(CheckResult::pass(
347+
"replication",
348+
"Has REPLICATION privilege",
349+
));
348350
} else {
349351
result.source_permissions.push(CheckResult::fail(
350352
"replication",
@@ -376,7 +378,8 @@ async fn check_source_permissions(result: &mut PreflightResult, source_url: &str
376378
} else {
377379
let inaccessible = &perms.inaccessible_tables;
378380
let count = inaccessible.len();
379-
let preview: Vec<&str> = inaccessible.iter().take(5).map(|s| s.as_str()).collect();
381+
let preview: Vec<&str> =
382+
inaccessible.iter().take(5).map(|s| s.as_str()).collect();
380383
let details = if count > 5 {
381384
format!("{}, ... ({} more)", preview.join(", "), count - 5)
382385
} else {
@@ -389,12 +392,10 @@ async fn check_source_permissions(result: &mut PreflightResult, source_url: &str
389392
);
390393
result.issues.push(PreflightIssue {
391394
title: "Missing table permissions".to_string(),
392-
explanation: format!(
393-
"User needs SELECT on {} tables",
394-
count
395-
),
395+
explanation: format!("User needs SELECT on {} tables", count),
396396
fixes: vec![
397-
"Run: GRANT SELECT ON ALL TABLES IN SCHEMA public TO <username>;".to_string(),
397+
"Run: GRANT SELECT ON ALL TABLES IN SCHEMA public TO <username>;"
398+
.to_string(),
398399
],
399400
});
400401
}
@@ -429,9 +430,10 @@ async fn check_target_permissions(result: &mut PreflightResult, target_url: &str
429430
}
430431

431432
if privs.is_superuser || privs.has_replication {
432-
result
433-
.target_permissions
434-
.push(CheckResult::pass("subscription", "Can create subscriptions"));
433+
result.target_permissions.push(CheckResult::pass(
434+
"subscription",
435+
"Can create subscriptions",
436+
));
435437
} else {
436438
result.target_permissions.push(CheckResult::fail(
437439
"subscription",

src/utils.rs

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1617,20 +1617,14 @@ mod tests {
16171617
assert!(is_serendb_target(
16181618
"postgres://u:p@x.serendb.com:5432/db?sslmode=require"
16191619
));
1620-
assert!(is_serendb_target(
1621-
"postgresql://user:pass@serendb.com/mydb"
1622-
));
1620+
assert!(is_serendb_target("postgresql://user:pass@serendb.com/mydb"));
16231621

16241622
// Negative cases - not SerenDB
1625-
assert!(!is_serendb_target(
1626-
"postgresql://user:pass@localhost/mydb"
1627-
));
1623+
assert!(!is_serendb_target("postgresql://user:pass@localhost/mydb"));
16281624
assert!(!is_serendb_target(
16291625
"postgresql://user:pass@rds.amazonaws.com/mydb"
16301626
));
1631-
assert!(!is_serendb_target(
1632-
"postgresql://user:pass@neon.tech/mydb"
1633-
));
1627+
assert!(!is_serendb_target("postgresql://user:pass@neon.tech/mydb"));
16341628
// Domain spoofing attempt - should NOT match
16351629
assert!(!is_serendb_target(
16361630
"postgresql://user:pass@serendb.com.evil.com/mydb"
@@ -1646,10 +1640,8 @@ mod tests {
16461640
fn test_parse_pg_version_string() {
16471641
// Standard pg_dump output
16481642
assert_eq!(
1649-
parse_pg_version_string(
1650-
"pg_dump (PostgreSQL) 16.10 (Ubuntu 16.10-0ubuntu0.24.04.1)"
1651-
)
1652-
.unwrap(),
1643+
parse_pg_version_string("pg_dump (PostgreSQL) 16.10 (Ubuntu 16.10-0ubuntu0.24.04.1)")
1644+
.unwrap(),
16531645
16
16541646
);
16551647

tests/integration_test.rs

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,17 @@ async fn test_init_command_integration() {
4747

4848
// Skip confirmation for automated tests, disable sync to keep test simple
4949
let filter = database_replicator::filters::ReplicationFilter::empty();
50-
let result = commands::init(&source_url, &target_url, true, filter, false, false, true, false).await;
50+
let result = commands::init(
51+
&source_url,
52+
&target_url,
53+
true,
54+
filter,
55+
false,
56+
false,
57+
true,
58+
false,
59+
)
60+
.await;
5161

5262
match &result {
5363
Ok(_) => {
@@ -293,7 +303,17 @@ async fn test_init_with_database_filter() {
293303
.expect("Failed to create filter");
294304

295305
// Skip confirmation for automated tests, disable sync to keep test simple
296-
let result = commands::init(&source_url, &target_url, true, filter, false, false, true, false).await;
306+
let result = commands::init(
307+
&source_url,
308+
&target_url,
309+
true,
310+
filter,
311+
false,
312+
false,
313+
true,
314+
false,
315+
)
316+
.await;
297317

298318
match &result {
299319
Ok(_) => {
@@ -327,7 +347,17 @@ async fn test_init_with_table_filter() {
327347
.expect("Failed to create filter");
328348

329349
// Skip confirmation for automated tests, disable sync to keep test simple
330-
let result = commands::init(&source_url, &target_url, true, filter, false, false, true, false).await;
350+
let result = commands::init(
351+
&source_url,
352+
&target_url,
353+
true,
354+
filter,
355+
false,
356+
false,
357+
true,
358+
false,
359+
)
360+
.await;
331361

332362
match &result {
333363
Ok(_) => {

0 commit comments

Comments
 (0)