mirror of
https://github.com/teloxide/teloxide.git
synced 2025-03-22 06:45:37 +01:00
Compile tests/redis.rs only if all the features are satisfied
This commit is contained in:
parent
62a116dbc0
commit
0ce9c7a5b0
1 changed files with 24 additions and 7 deletions
|
@ -1,28 +1,45 @@
|
||||||
|
#![cfg(feature = "redis_storage")]
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
fmt::{Debug, Display},
|
fmt::{Debug, Display},
|
||||||
future::Future,
|
future::Future,
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
};
|
};
|
||||||
use teloxide::dispatching::dialogue::{
|
use teloxide::dispatching::dialogue::{RedisStorage, Serializer, Storage};
|
||||||
serializer::{Bincode, CBOR, JSON},
|
|
||||||
RedisStorage, Serializer, Storage,
|
|
||||||
};
|
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
|
#[cfg(feature = "redis_storage")]
|
||||||
async fn test_redis_json() {
|
async fn test_redis_json() {
|
||||||
let storage = RedisStorage::open("redis://127.0.0.1:7777", JSON).await.unwrap();
|
let storage = RedisStorage::open(
|
||||||
|
"redis://127.0.0.1:7777",
|
||||||
|
teloxide::dispatching::dialogue::serializer::JSON,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
test_redis(storage).await;
|
test_redis(storage).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "bincode_serializer")]
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_redis_bincode() {
|
async fn test_redis_bincode() {
|
||||||
let storage = RedisStorage::open("redis://127.0.0.1:7778", Bincode).await.unwrap();
|
let storage = RedisStorage::open(
|
||||||
|
"redis://127.0.0.1:7778",
|
||||||
|
teloxide::dispatching::dialogue::serializer::Bincode,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
test_redis(storage).await;
|
test_redis(storage).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "cbor_serializer")]
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_redis_cbor() {
|
async fn test_redis_cbor() {
|
||||||
let storage = RedisStorage::open("redis://127.0.0.1:7779", CBOR).await.unwrap();
|
let storage = RedisStorage::open(
|
||||||
|
"redis://127.0.0.1:7779",
|
||||||
|
teloxide::dispatching::dialogue::serializer::CBOR,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
test_redis(storage).await;
|
test_redis(storage).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue