mirror of
https://github.com/teloxide/teloxide.git
synced 2025-03-22 06:45:37 +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::{
|
use std::{
|
||||||
fmt::{Debug, Display},
|
fmt::{Debug, Display},
|
||||||
|
fs,
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
};
|
};
|
||||||
use teloxide::dispatching::dialogue::{Serializer, SqliteStorage, SqliteStorageError, Storage};
|
use teloxide::dispatching::dialogue::{Serializer, SqliteStorage, SqliteStorageError, Storage};
|
||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread")]
|
#[tokio::test(flavor = "multi_thread")]
|
||||||
async fn test_sqlite_json() {
|
async fn test_sqlite_json() {
|
||||||
let storage =
|
fs::create_dir("./test_db1").unwrap();
|
||||||
SqliteStorage::open("./test_db1.sqlite", teloxide::dispatching::dialogue::serializer::Json)
|
let storage = SqliteStorage::open(
|
||||||
|
"./test_db1/test_db1.sqlite",
|
||||||
|
teloxide::dispatching::dialogue::serializer::Json,
|
||||||
|
)
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
test_sqlite(storage).await;
|
test_sqlite(storage).await;
|
||||||
|
fs::remove_dir_all("./test_db1").unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread")]
|
#[tokio::test(flavor = "multi_thread")]
|
||||||
async fn test_sqlite_bincode() {
|
async fn test_sqlite_bincode() {
|
||||||
|
fs::create_dir("./test_db2").unwrap();
|
||||||
let storage = SqliteStorage::open(
|
let storage = SqliteStorage::open(
|
||||||
"./test_db2.sqlite",
|
"./test_db2/test_db2.sqlite",
|
||||||
teloxide::dispatching::dialogue::serializer::Bincode,
|
teloxide::dispatching::dialogue::serializer::Bincode,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
test_sqlite(storage).await;
|
test_sqlite(storage).await;
|
||||||
|
fs::remove_dir_all("./test_db2").unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread")]
|
#[tokio::test(flavor = "multi_thread")]
|
||||||
async fn test_sqlite_cbor() {
|
async fn test_sqlite_cbor() {
|
||||||
let storage =
|
fs::create_dir("./test_db3").unwrap();
|
||||||
SqliteStorage::open("./test_db3.sqlite", teloxide::dispatching::dialogue::serializer::Cbor)
|
let storage = SqliteStorage::open(
|
||||||
|
"./test_db3/test_db3.sqlite",
|
||||||
|
teloxide::dispatching::dialogue::serializer::Cbor,
|
||||||
|
)
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
test_sqlite(storage).await;
|
test_sqlite(storage).await;
|
||||||
|
fs::remove_dir_all("./test_db3").unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
type Dialogue = String;
|
type Dialogue = String;
|
||||||
|
|
Loading…
Add table
Reference in a new issue