Skip to content

Commit d8eadac

Browse files
committed
Fix lint
1 parent 9db9de6 commit d8eadac

11 files changed

Lines changed: 1722 additions & 1676 deletions

File tree

crates/vespertide-cli/src/commands/revision.rs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ fn parse_fill_with_args(args: &[String]) -> HashMap<(String, String), String> {
3030

3131
/// Format the type info string for display.
3232
fn format_type_info(column_type: Option<&String>) -> String {
33-
column_type
34-
.map(|t| format!(" ({})", t))
35-
.unwrap_or_default()
33+
column_type.map(|t| format!(" ({})", t)).unwrap_or_default()
3634
}
3735

3836
/// Format a single fill_with item for display.
@@ -757,12 +755,8 @@ mod tests {
757755

758756
#[test]
759757
fn test_print_fill_with_item_and_get_prompt_no_type() {
760-
let prompt = print_fill_with_item_and_get_prompt(
761-
"orders",
762-
"status",
763-
None,
764-
"ModifyColumnNullable",
765-
);
758+
let prompt =
759+
print_fill_with_item_and_get_prompt("orders", "status", None, "ModifyColumnNullable");
766760
assert!(prompt.contains("Enter fill value for"));
767761
assert!(prompt.contains("orders"));
768762
assert!(prompt.contains("status"));
@@ -795,7 +789,8 @@ mod tests {
795789
let mut fill_values = HashMap::new();
796790

797791
// Mock prompt function that returns a fixed value
798-
let mock_prompt = |_prompt: &str| -> Result<String> { Ok("'test@example.com'".to_string()) };
792+
let mock_prompt =
793+
|_prompt: &str| -> Result<String> { Ok("'test@example.com'".to_string()) };
799794

800795
let result = collect_fill_with_values(&missing, &mut fill_values, mock_prompt);
801796
assert!(result.is_ok());
@@ -932,7 +927,8 @@ mod tests {
932927
let mut fill_values = HashMap::new();
933928

934929
// Mock prompt function
935-
let mock_prompt = |_prompt: &str| -> Result<String> { Ok("'test@example.com'".to_string()) };
930+
let mock_prompt =
931+
|_prompt: &str| -> Result<String> { Ok("'test@example.com'".to_string()) };
936932

937933
let result = handle_missing_fill_with(&mut plan, &mut fill_values, mock_prompt);
938934
assert!(result.is_ok());
@@ -1018,7 +1014,8 @@ mod tests {
10181014
let mut fill_values = HashMap::new();
10191015

10201016
// Mock prompt that returns an error
1021-
let mock_prompt = |_prompt: &str| -> Result<String> { Err(anyhow::anyhow!("user cancelled")) };
1017+
let mock_prompt =
1018+
|_prompt: &str| -> Result<String> { Err(anyhow::anyhow!("user cancelled")) };
10221019

10231020
let result = handle_missing_fill_with(&mut plan, &mut fill_values, mock_prompt);
10241021
assert!(result.is_err());

crates/vespertide-core/src/action.rs

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,23 @@ impl fmt::Display for MigrationAction {
108108
..
109109
} => {
110110
let nullability = if *nullable { "NULL" } else { "NOT NULL" };
111-
write!(f, "ModifyColumnNullable: {}.{} -> {}", table, column, nullability)
111+
write!(
112+
f,
113+
"ModifyColumnNullable: {}.{} -> {}",
114+
table, column, nullability
115+
)
112116
}
113117
MigrationAction::ModifyColumnDefault {
114118
table,
115119
column,
116120
new_default,
117121
} => {
118122
if let Some(default) = new_default {
119-
write!(f, "ModifyColumnDefault: {}.{} -> {}", table, column, default)
123+
write!(
124+
f,
125+
"ModifyColumnDefault: {}.{} -> {}",
126+
table, column, default
127+
)
120128
} else {
121129
write!(f, "ModifyColumnDefault: {}.{} -> (none)", table, column)
122130
}
@@ -132,7 +140,11 @@ impl fmt::Display for MigrationAction {
132140
} else {
133141
comment.clone()
134142
};
135-
write!(f, "ModifyColumnComment: {}.{} -> '{}'", table, column, display)
143+
write!(
144+
f,
145+
"ModifyColumnComment: {}.{} -> '{}'",
146+
table, column, display
147+
)
136148
} else {
137149
write!(f, "ModifyColumnComment: {}.{} -> (none)", table, column)
138150
}
@@ -537,10 +549,7 @@ mod tests {
537549
},
538550
"ModifyColumnDefault: users.status -> (none)"
539551
)]
540-
fn test_display_modify_column_default(
541-
#[case] action: MigrationAction,
542-
#[case] expected: &str,
543-
) {
552+
fn test_display_modify_column_default(#[case] action: MigrationAction, #[case] expected: &str) {
544553
assert_eq!(action.to_string(), expected);
545554
}
546555

@@ -561,10 +570,7 @@ mod tests {
561570
},
562571
"ModifyColumnComment: users.email -> (none)"
563572
)]
564-
fn test_display_modify_column_comment(
565-
#[case] action: MigrationAction,
566-
#[case] expected: &str,
567-
) {
573+
fn test_display_modify_column_comment(#[case] action: MigrationAction, #[case] expected: &str) {
568574
assert_eq!(action.to_string(), expected);
569575
}
570576

crates/vespertide-planner/src/diff.rs

Lines changed: 57 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1815,7 +1815,10 @@ mod tests {
18151815
} if table == "users" && columns == &vec!["id".to_string(), "tenant_id".to_string()]
18161816
)
18171817
});
1818-
assert!(has_remove, "Should have RemoveConstraint for old composite PK");
1818+
assert!(
1819+
has_remove,
1820+
"Should have RemoveConstraint for old composite PK"
1821+
);
18191822

18201823
let has_add = plan.actions.iter().any(|a| {
18211824
matches!(
@@ -1826,7 +1829,10 @@ mod tests {
18261829
} if table == "users" && columns == &vec!["id".to_string()]
18271830
)
18281831
});
1829-
assert!(has_add, "Should have AddConstraint for new single-column PK");
1832+
assert!(
1833+
has_add,
1834+
"Should have AddConstraint for new single-column PK"
1835+
);
18301836
}
18311837

18321838
#[test]
@@ -1913,7 +1919,10 @@ mod tests {
19131919
} if table == "users" && columns == &vec!["id".to_string()]
19141920
)
19151921
});
1916-
assert!(has_remove, "Should have RemoveConstraint for old single-column PK");
1922+
assert!(
1923+
has_remove,
1924+
"Should have RemoveConstraint for old single-column PK"
1925+
);
19171926

19181927
let has_add = plan.actions.iter().any(|a| {
19191928
matches!(
@@ -1928,7 +1937,10 @@ mod tests {
19281937
]
19291938
)
19301939
});
1931-
assert!(has_add, "Should have AddConstraint for new 3-column composite PK");
1940+
assert!(
1941+
has_add,
1942+
"Should have AddConstraint for new 3-column composite PK"
1943+
);
19321944
}
19331945

19341946
#[test]
@@ -1971,7 +1983,10 @@ mod tests {
19711983
]
19721984
)
19731985
});
1974-
assert!(has_remove, "Should have RemoveConstraint for old 3-column composite PK");
1986+
assert!(
1987+
has_remove,
1988+
"Should have RemoveConstraint for old 3-column composite PK"
1989+
);
19751990

19761991
let has_add = plan.actions.iter().any(|a| {
19771992
matches!(
@@ -1982,7 +1997,10 @@ mod tests {
19821997
} if table == "users" && columns == &vec!["id".to_string()]
19831998
)
19841999
});
1985-
assert!(has_add, "Should have AddConstraint for new single-column PK");
2000+
assert!(
2001+
has_add,
2002+
"Should have AddConstraint for new single-column PK"
2003+
);
19862004
}
19872005

19882006
#[test]
@@ -2022,7 +2040,10 @@ mod tests {
20222040
} if table == "users" && columns == &vec!["id".to_string(), "tenant_id".to_string()]
20232041
)
20242042
});
2025-
assert!(has_remove, "Should have RemoveConstraint for old PK with tenant_id");
2043+
assert!(
2044+
has_remove,
2045+
"Should have RemoveConstraint for old PK with tenant_id"
2046+
);
20262047

20272048
let has_add = plan.actions.iter().any(|a| {
20282049
matches!(
@@ -2033,7 +2054,10 @@ mod tests {
20332054
} if table == "users" && columns == &vec!["id".to_string(), "region_id".to_string()]
20342055
)
20352056
});
2036-
assert!(has_add, "Should have AddConstraint for new PK with region_id");
2057+
assert!(
2058+
has_add,
2059+
"Should have AddConstraint for new PK with region_id"
2060+
);
20372061
}
20382062
}
20392063

@@ -2577,32 +2601,26 @@ mod tests {
25772601
// Column changing both nullable and comment
25782602
let from = vec![table(
25792603
"users",
2580-
vec![
2581-
col("id", ColumnType::Simple(SimpleColumnType::Integer)),
2582-
{
2583-
let mut c =
2584-
col_with_comment("email", ColumnType::Simple(SimpleColumnType::Text), None);
2585-
c.nullable = true;
2586-
c
2587-
},
2588-
],
2604+
vec![col("id", ColumnType::Simple(SimpleColumnType::Integer)), {
2605+
let mut c =
2606+
col_with_comment("email", ColumnType::Simple(SimpleColumnType::Text), None);
2607+
c.nullable = true;
2608+
c
2609+
}],
25892610
vec![],
25902611
)];
25912612

25922613
let to = vec![table(
25932614
"users",
2594-
vec![
2595-
col("id", ColumnType::Simple(SimpleColumnType::Integer)),
2596-
{
2597-
let mut c = col_with_comment(
2598-
"email",
2599-
ColumnType::Simple(SimpleColumnType::Text),
2600-
Some("Required email"),
2601-
);
2602-
c.nullable = false;
2603-
c
2604-
},
2605-
],
2615+
vec![col("id", ColumnType::Simple(SimpleColumnType::Integer)), {
2616+
let mut c = col_with_comment(
2617+
"email",
2618+
ColumnType::Simple(SimpleColumnType::Text),
2619+
Some("Required email"),
2620+
);
2621+
c.nullable = false;
2622+
c
2623+
}],
26062624
vec![],
26072625
)];
26082626

@@ -2744,8 +2762,8 @@ mod tests {
27442762
vec![
27452763
col("id", ColumnType::Simple(SimpleColumnType::Integer)),
27462764
col_nullable("email", ColumnType::Simple(SimpleColumnType::Text), false), // nullable -> non-nullable
2747-
col_nullable("name", ColumnType::Simple(SimpleColumnType::Text), true), // non-nullable -> nullable
2748-
col_nullable("phone", ColumnType::Simple(SimpleColumnType::Text), true), // no change
2765+
col_nullable("name", ColumnType::Simple(SimpleColumnType::Text), true), // non-nullable -> nullable
2766+
col_nullable("phone", ColumnType::Simple(SimpleColumnType::Text), true), // no change
27492767
],
27502768
vec![],
27512769
)];
@@ -2765,7 +2783,10 @@ mod tests {
27652783
} if table == "users" && column == "email"
27662784
)
27672785
});
2768-
assert!(has_email_change, "Should detect email nullable -> non-nullable");
2786+
assert!(
2787+
has_email_change,
2788+
"Should detect email nullable -> non-nullable"
2789+
);
27692790

27702791
let has_name_change = plan.actions.iter().any(|a| {
27712792
matches!(
@@ -2778,7 +2799,10 @@ mod tests {
27782799
} if table == "users" && column == "name"
27792800
)
27802801
});
2781-
assert!(has_name_change, "Should detect name non-nullable -> nullable");
2802+
assert!(
2803+
has_name_change,
2804+
"Should detect name non-nullable -> nullable"
2805+
);
27822806
}
27832807

27842808
#[test]

crates/vespertide-planner/src/error.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ pub enum PlannerError {
3939
}
4040

4141
#[derive(Debug, Error)]
42-
#[error("enum '{enum_name}' in column '{table_name}.{column_name}' has invalid {value_type} value '{value}': not in allowed values [{allowed}]")]
42+
#[error(
43+
"enum '{enum_name}' in column '{table_name}.{column_name}' has invalid {value_type} value '{value}': not in allowed values [{allowed}]"
44+
)]
4345
pub struct InvalidEnumDefaultError {
4446
pub enum_name: String,
4547
pub table_name: String,
Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
pub mod apply;
2-
pub mod diff;
3-
pub mod error;
4-
pub mod plan;
5-
pub mod schema;
6-
pub mod validate;
7-
8-
pub use apply::apply_action;
9-
pub use diff::diff_schemas;
10-
pub use error::PlannerError;
11-
pub use plan::{plan_next_migration, plan_next_migration_with_baseline};
12-
pub use schema::schema_from_plans;
13-
pub use validate::{find_missing_fill_with, validate_migration_plan, validate_schema, FillWithRequired};
1+
pub mod apply;
2+
pub mod diff;
3+
pub mod error;
4+
pub mod plan;
5+
pub mod schema;
6+
pub mod validate;
7+
8+
pub use apply::apply_action;
9+
pub use diff::diff_schemas;
10+
pub use error::PlannerError;
11+
pub use plan::{plan_next_migration, plan_next_migration_with_baseline};
12+
pub use schema::schema_from_plans;
13+
pub use validate::{
14+
FillWithRequired, find_missing_fill_with, validate_migration_plan, validate_schema,
15+
};

0 commit comments

Comments
 (0)