mirror of
https://github.com/teloxide/teloxide.git
synced 2025-01-03 09:49:07 +01:00
Cleanup files when testing sqlite storage
This commit is contained in:
parent
8ae3222409
commit
3c97ed83f4
1 changed files with 20 additions and 9 deletions
|
@ -1,36 +1,47 @@
|
|||
use std::{
|
||||
fmt::{Debug, Display},
|
||||
fs,
|
||||
sync::Arc,
|
||||
};
|
||||
use teloxide::dispatching::dialogue::{Serializer, SqliteStorage, SqliteStorageError, Storage};
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn test_sqlite_json() {
|
||||
let storage =
|
||||
SqliteStorage::open("./test_db1.sqlite", teloxide::dispatching::dialogue::serializer::Json)
|
||||
fs::create_dir("./test_db1").unwrap();
|
||||
let storage = SqliteStorage::open(
|
||||
"./test_db1/test_db1.sqlite",
|
||||
teloxide::dispatching::dialogue::serializer::Json,
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
test_sqlite(storage).await;
|
||||
fs::remove_dir_all("./test_db1").unwrap();
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn test_sqlite_bincode() {
|
||||
fs::create_dir("./test_db2").unwrap();
|
||||
let storage = SqliteStorage::open(
|
||||
"./test_db2.sqlite",
|
||||
"./test_db2/test_db2.sqlite",
|
||||
teloxide::dispatching::dialogue::serializer::Bincode,
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
test_sqlite(storage).await;
|
||||
fs::remove_dir_all("./test_db2").unwrap();
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn test_sqlite_cbor() {
|
||||
let storage =
|
||||
SqliteStorage::open("./test_db3.sqlite", teloxide::dispatching::dialogue::serializer::Cbor)
|
||||
fs::create_dir("./test_db3").unwrap();
|
||||
let storage = SqliteStorage::open(
|
||||
"./test_db3/test_db3.sqlite",
|
||||
teloxide::dispatching::dialogue::serializer::Cbor,
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
test_sqlite(storage).await;
|
||||
fs::remove_dir_all("./test_db3").unwrap();
|
||||
}
|
||||
|
||||
type Dialogue = String;
|
||||
|
|
Loading…
Reference in a new issue