Skip to content

Commit 8ca1256

Browse files
committed
Add macro case
1 parent 1ec480e commit 8ca1256

File tree

1 file changed

+29
-2
lines changed
  • crates/vespertide-macro/src

1 file changed

+29
-2
lines changed

crates/vespertide-macro/src/lib.rs

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,6 @@ mod tests {
308308
"Unexpected output: {}",
309309
output_str
310310
);
311-
// Print for debugging coverage
312-
eprintln!("Output contains 'async': {}", output_str.contains("async"));
313311
}
314312

315313
#[test]
@@ -649,4 +647,33 @@ mod tests {
649647
let err = result.unwrap_err();
650648
assert!(err.contains("Failed to build queries for migration version 1"));
651649
}
650+
651+
#[test]
652+
fn test_vespertide_migration_impl_loading_error() {
653+
// Save original CARGO_MANIFEST_DIR
654+
let original = std::env::var("CARGO_MANIFEST_DIR").ok();
655+
656+
// Remove CARGO_MANIFEST_DIR to trigger loading error
657+
unsafe {
658+
std::env::remove_var("CARGO_MANIFEST_DIR");
659+
}
660+
661+
let input: proc_macro2::TokenStream = "pool".parse().unwrap();
662+
let output = vespertide_migration_impl(input);
663+
let output_str = output.to_string();
664+
665+
// Should contain error about failed loading
666+
assert!(
667+
output_str.contains("Failed to load migrations at compile time"),
668+
"Expected loading error, got: {}",
669+
output_str
670+
);
671+
672+
// Restore CARGO_MANIFEST_DIR
673+
if let Some(val) = original {
674+
unsafe {
675+
std::env::set_var("CARGO_MANIFEST_DIR", val);
676+
}
677+
}
678+
}
652679
}

0 commit comments

Comments
 (0)