surrealpatch/lib/tests/api/backup.rs
Rushmore Mushambi 2d19ac9f7a
Add live query API (#2919)
Co-authored-by: Emmanuel Keller <keller.emmanuel@gmail.com>
2023-11-13 17:19:47 +00:00

25 lines
621 B
Rust

// Tests for exporting and importing data
// Supported by the storage engines and the HTTP protocol
use tokio::fs::remove_file;
#[test_log::test(tokio::test)]
async fn export_import() {
let (permit, db) = new_db().await;
let db_name = Ulid::new().to_string();
db.use_ns(NS).use_db(&db_name).await.unwrap();
for i in 0..10 {
let _: Vec<RecordId> = db
.create("user")
.content(Record {
name: &format!("User {i}"),
})
.await
.unwrap();
}
drop(permit);
let file = format!("{db_name}.sql");
db.export(&file).await.unwrap();
db.import(&file).await.unwrap();
remove_file(file).await.unwrap();
}