Compile tests/redis.rs only if all the features are satisfied

This commit is contained in:
Temirkhan Myrzamadi 2020-07-31 20:18:00 +06:00
parent 62a116dbc0
commit 0ce9c7a5b0

View file

@ -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;
} }