From 5f96da0a5fa43a8c7deb40402ff66957c6faeb43 Mon Sep 17 00:00:00 2001 From: Temirkhan Myrzamadi Date: Sat, 13 Mar 2021 23:05:50 +0600 Subject: [PATCH] Fix the tests --- Cargo.toml | 2 +- src/dispatching/dialogue/dialogue_dispatcher.rs | 4 ++-- src/dispatching/mod.rs | 7 ++++--- tests/command.rs | 14 +++++++------- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 5eae9a4f..40b0133b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -75,7 +75,7 @@ smart-default = "0.6.0" rand = "0.8.3" pretty_env_logger = "0.4.0" lazy_static = "1.4.0" -tokio = { version = "1.2.0", features = ["fs", "rt", "macros"] } +tokio = { version = "1.2.0", features = ["fs", "rt-multi-thread", "macros"] } [package.metadata.docs.rs] all-features = true diff --git a/src/dispatching/dialogue/dialogue_dispatcher.rs b/src/dispatching/dialogue/dialogue_dispatcher.rs index 4353debc..706cf952 100644 --- a/src/dispatching/dialogue/dialogue_dispatcher.rs +++ b/src/dispatching/dialogue/dialogue_dispatcher.rs @@ -185,14 +185,14 @@ mod tests { time::Duration, }; - #[tokio::test(flavor = "multi_thread")] + #[tokio::test] #[allow(deprecated)] async fn updates_from_same_chat_executed_sequentially() { #[derive(Debug)] struct MyUpdate { chat_id: i64, unique_number: u32, - }; + } impl MyUpdate { fn new(chat_id: i64, unique_number: u32) -> Self { diff --git a/src/dispatching/mod.rs b/src/dispatching/mod.rs index 373202f3..5c1e86c4 100644 --- a/src/dispatching/mod.rs +++ b/src/dispatching/mod.rs @@ -9,10 +9,11 @@ //! //! ``` //! use teloxide::prelude::*; +//! use tokio_stream::wrappers::UnboundedReceiverStream; //! -//! async fn handle_messages(rx: DispatcherHandlerRx) { -//! rx.for_each_concurrent(None, |message| async move { -//! dbg!(message); +//! async fn handle_messages(rx: DispatcherHandlerRx, Message>) { +//! UnboundedReceiverStream::new(rx).for_each_concurrent(None, |message| async move { +//! dbg!(message.update); //! }) //! .await; //! } diff --git a/tests/command.rs b/tests/command.rs index 4b059614..657bc98d 100644 --- a/tests/command.rs +++ b/tests/command.rs @@ -7,8 +7,8 @@ use teloxide::utils::command::{BotCommand, ParseError}; #[test] #[cfg(feature = "macros")] fn parse_command_with_args() { - #[command(rename = "lowercase")] #[derive(BotCommand, Debug, PartialEq)] + #[command(rename = "lowercase")] enum DefaultCommands { Start(String), Help, @@ -23,8 +23,8 @@ fn parse_command_with_args() { #[test] #[cfg(feature = "macros")] fn parse_command_with_non_string_arg() { - #[command(rename = "lowercase")] #[derive(BotCommand, Debug, PartialEq)] + #[command(rename = "lowercase")] enum DefaultCommands { Start(i32), Help, @@ -39,8 +39,8 @@ fn parse_command_with_non_string_arg() { #[test] #[cfg(feature = "macros")] fn attribute_prefix() { - #[command(rename = "lowercase")] #[derive(BotCommand, Debug, PartialEq)] + #[command(rename = "lowercase")] enum DefaultCommands { #[command(prefix = "!")] Start(String), @@ -121,9 +121,9 @@ fn parse_with_split() { #[test] #[cfg(feature = "macros")] fn parse_with_split2() { + #[derive(BotCommand, Debug, PartialEq)] #[command(rename = "lowercase")] #[command(parse_with = "split", separator = "|")] - #[derive(BotCommand, Debug, PartialEq)] enum DefaultCommands { Start(u8, String), Help, @@ -149,8 +149,8 @@ fn parse_custom_parser() { .map_err(|_| ParseError::Custom("First argument must be a integer!".to_owned().into())) } - #[command(rename = "lowercase")] #[derive(BotCommand, Debug, PartialEq)] + #[command(rename = "lowercase")] enum DefaultCommands { #[command(parse_with = "custom_parse_function")] Start(u8, String), @@ -166,9 +166,9 @@ fn parse_custom_parser() { #[test] #[cfg(feature = "macros")] fn parse_named_fields() { + #[derive(BotCommand, Debug, PartialEq)] #[command(rename = "lowercase")] #[command(parse_with = "split")] - #[derive(BotCommand, Debug, PartialEq)] enum DefaultCommands { Start { num: u8, data: String }, Help, @@ -183,8 +183,8 @@ fn parse_named_fields() { #[test] #[cfg(feature = "macros")] fn descriptions_off() { - #[command(rename = "lowercase")] #[derive(BotCommand, Debug, PartialEq)] + #[command(rename = "lowercase")] enum DefaultCommands { #[command(description = "off")] Start,