diff --git a/src/backup.rs b/src/backup.rs index f28ae9a..216c62d 100644 --- a/src/backup.rs +++ b/src/backup.rs @@ -316,10 +316,28 @@ impl Drop for Backup<'_, '_> { #[cfg(test)] mod test { - use super::Backup; + use super::{Backup, Progress}; use crate::{Connection, DatabaseName, Result}; use std::time::Duration; + #[test] + fn backup_to_path() -> Result<()> { + let src = Connection::open_in_memory()?; + src.execute_batch("CREATE TABLE foo AS SELECT 42 AS x")?; + + let temp_dir = tempfile::tempdir().unwrap(); + let path = temp_dir.path().join("test.db3"); + + fn progress(_: Progress) {} + + src.backup(DatabaseName::Main, path.as_path(), Some(progress))?; + + let mut dst = Connection::open_in_memory()?; + dst.restore(DatabaseName::Main, path, Some(progress))?; + + Ok(()) + } + #[test] fn test_backup() -> Result<()> { let src = Connection::open_in_memory()?;