mirror of
https://github.com/isar/rusqlite.git
synced 2025-03-31 19:12:58 +08:00
Add test to Connection::backup/restore
This commit is contained in:
parent
64fe11ee37
commit
67bce659d0
@ -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()?;
|
||||
|
Loading…
x
Reference in New Issue
Block a user