Skip to content

Commit 7afd48a

Browse files
committed
Fix fmt
1 parent 4084014 commit 7afd48a

File tree

7 files changed

+492
-169
lines changed

7 files changed

+492
-169
lines changed

crates/vespertide-core/src/action.rs

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,7 @@ mod tests {
247247
},
248248
"RenameTable: old_table -> new_table"
249249
)]
250-
fn test_display_basic_actions(
251-
#[case] action: MigrationAction,
252-
#[case] expected: &str,
253-
) {
250+
fn test_display_basic_actions(#[case] action: MigrationAction, #[case] expected: &str) {
254251
assert_eq!(action.to_string(), expected);
255252
}
256253

@@ -323,10 +320,7 @@ mod tests {
323320
},
324321
"AddConstraint: users.chk_age (CHECK)"
325322
)]
326-
fn test_display_add_constraint(
327-
#[case] action: MigrationAction,
328-
#[case] expected: &str,
329-
) {
323+
fn test_display_add_constraint(#[case] action: MigrationAction, #[case] expected: &str) {
330324
assert_eq!(action.to_string(), expected);
331325
}
332326

@@ -399,10 +393,7 @@ mod tests {
399393
},
400394
"RemoveConstraint: users.chk_age (CHECK)"
401395
)]
402-
fn test_display_remove_constraint(
403-
#[case] action: MigrationAction,
404-
#[case] expected: &str,
405-
) {
396+
fn test_display_remove_constraint(#[case] action: MigrationAction, #[case] expected: &str) {
406397
assert_eq!(action.to_string(), expected);
407398
}
408399

@@ -413,17 +404,16 @@ mod tests {
413404
},
414405
"RawSql: SELECT 1"
415406
)]
416-
fn test_display_raw_sql_short(
417-
#[case] action: MigrationAction,
418-
#[case] expected: &str,
419-
) {
407+
fn test_display_raw_sql_short(#[case] action: MigrationAction, #[case] expected: &str) {
420408
assert_eq!(action.to_string(), expected);
421409
}
422410

423411
#[test]
424412
fn test_display_raw_sql_long() {
425413
let action = MigrationAction::RawSql {
426-
sql: "SELECT * FROM users WHERE id = 1 AND name = 'test' AND email = 'test@example.com'".into(),
414+
sql:
415+
"SELECT * FROM users WHERE id = 1 AND name = 'test' AND email = 'test@example.com'"
416+
.into(),
427417
};
428418
let result = action.to_string();
429419
assert!(result.starts_with("RawSql: "));

crates/vespertide-loader/src/migrations.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ pub fn load_migrations_from_dir(
8181
if path.is_file() {
8282
let ext = path.extension().and_then(|s| s.to_str());
8383
if ext == Some("json") || ext == Some("yaml") || ext == Some("yml") {
84-
let content = fs::read_to_string(&path).context(format!("Failed to read migration file {}", path.display()))?;
84+
let content = fs::read_to_string(&path)
85+
.context(format!("Failed to read migration file {}", path.display()))?;
8586

8687
let plan: MigrationPlan = if ext == Some("json") {
8788
serde_json::from_str(&content).map_err(|e| {
@@ -299,7 +300,7 @@ actions:
299300

300301
let file_path = migrations_dir.join("0001_test.json");
301302
fs::write(&file_path, r#"{"version": 1, "actions": []}"#).unwrap();
302-
303+
303304
let result = load_migrations_from_dir(Some(temp_dir.path().to_path_buf()));
304305
assert!(result.is_ok());
305306
}
@@ -316,7 +317,7 @@ actions:
316317

317318
let file_path = migrations_dir.join("0001_test.json");
318319
fs::write(&file_path, r#"{"version": 1, "actions": []}"#).unwrap();
319-
320+
320321
let result = load_migrations_from_dir(Some(temp_dir.path().to_path_buf()));
321322
assert!(result.is_ok());
322323
}
@@ -326,19 +327,19 @@ actions:
326327
fn test_load_migrations_from_dir_without_project_root() {
327328
// Save the original value
328329
let original = env::var("CARGO_MANIFEST_DIR").ok();
329-
330+
330331
// Remove CARGO_MANIFEST_DIR to test the error path
331332
// Note: remove_var is unsafe in multi-threaded environments,
332333
// but serial_test ensures tests run sequentially
333334
unsafe {
334335
env::remove_var("CARGO_MANIFEST_DIR");
335336
}
336-
337+
337338
let result = load_migrations_from_dir(None);
338339
assert!(result.is_err());
339340
let err_msg = result.unwrap_err().to_string();
340341
assert!(err_msg.contains("CARGO_MANIFEST_DIR environment variable not set"));
341-
342+
342343
// Restore the original value if it existed
343344
// Note: In a test environment, we don't restore to avoid affecting other tests
344345
// The serial_test ensures tests run sequentially

0 commit comments

Comments
 (0)