Add test to Connection::backup/restore

This commit is contained in:
gwenn 2024-03-23 19:22:21 +01:00
parent 64fe11ee37
commit 67bce659d0

View File

@ -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()?;