Conversation
mbj
commented
Mar 27, 2025
- Before any errors would silently be ignored.
- And the DB would be partially initialized.
- This created very hard to debug states.
* Before any errors would silently be ignored. * And the DB would be partially initialized. * This created very hard to debug states.
|
Hi! Thanks for the contribution, and for using pgtemp! Could you add a test for this? You can copy and paste the setup from I also wonder if:
but I doubt adding this will break any clients so that can happen later unless you feel like doing it now. |
|
@mbj do you want help adding a test for this? |
I'm to busy ATM to get back to that sorry. I do not need help, I need time ;) If you wanted to spend the time feel free to just close tis PR and take my single line change as a base. |
I just wrote a test for it, feel free to add it to your PR. If you don't have time for that, I can also fork your code. (this test fails on main, but succeeds on your branch) #[tokio::test]
/// make sure that we correctly error on bad database dumps.
#[should_panic(expected = "syntax error at or near \\\"INVALID\\")]
async fn panic_on_load_error() {
let temp = tempfile::tempdir().unwrap();
let db_dump_path = temp.path().join("dump.sql");
// Create some bad database dumps
let mut f = std::fs::File::create(&db_dump_path).unwrap();
f.write_all(b"INVALID SQL").unwrap();
f.flush().expect("Failed to flush file");
// Try to load it (it should fail)
PgTempDB::builder()
.load_database(&db_dump_path)
.start_async()
.await;
} |
|
That test looks good, can @mbj confirm that's the expected error message they see with their corrupted files? Thanks both of you for the contributions! |
I think its good enough. |
|
Fixed in #25 , thanks everyone! |