Fix the tests

This commit is contained in:
Temirkhan Myrzamadi 2021-03-13 23:05:50 +06:00
parent 1af0bfdcbc
commit 5f96da0a5f
4 changed files with 14 additions and 13 deletions

View file

@ -75,7 +75,7 @@ smart-default = "0.6.0"
rand = "0.8.3" rand = "0.8.3"
pretty_env_logger = "0.4.0" pretty_env_logger = "0.4.0"
lazy_static = "1.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] [package.metadata.docs.rs]
all-features = true all-features = true

View file

@ -185,14 +185,14 @@ mod tests {
time::Duration, time::Duration,
}; };
#[tokio::test(flavor = "multi_thread")] #[tokio::test]
#[allow(deprecated)] #[allow(deprecated)]
async fn updates_from_same_chat_executed_sequentially() { async fn updates_from_same_chat_executed_sequentially() {
#[derive(Debug)] #[derive(Debug)]
struct MyUpdate { struct MyUpdate {
chat_id: i64, chat_id: i64,
unique_number: u32, unique_number: u32,
}; }
impl MyUpdate { impl MyUpdate {
fn new(chat_id: i64, unique_number: u32) -> Self { fn new(chat_id: i64, unique_number: u32) -> Self {

View file

@ -9,10 +9,11 @@
//! //!
//! ``` //! ```
//! use teloxide::prelude::*; //! use teloxide::prelude::*;
//! use tokio_stream::wrappers::UnboundedReceiverStream;
//! //!
//! async fn handle_messages(rx: DispatcherHandlerRx<Message>) { //! async fn handle_messages(rx: DispatcherHandlerRx<AutoSend<Bot>, Message>) {
//! rx.for_each_concurrent(None, |message| async move { //! UnboundedReceiverStream::new(rx).for_each_concurrent(None, |message| async move {
//! dbg!(message); //! dbg!(message.update);
//! }) //! })
//! .await; //! .await;
//! } //! }

View file

@ -7,8 +7,8 @@ use teloxide::utils::command::{BotCommand, ParseError};
#[test] #[test]
#[cfg(feature = "macros")] #[cfg(feature = "macros")]
fn parse_command_with_args() { fn parse_command_with_args() {
#[command(rename = "lowercase")]
#[derive(BotCommand, Debug, PartialEq)] #[derive(BotCommand, Debug, PartialEq)]
#[command(rename = "lowercase")]
enum DefaultCommands { enum DefaultCommands {
Start(String), Start(String),
Help, Help,
@ -23,8 +23,8 @@ fn parse_command_with_args() {
#[test] #[test]
#[cfg(feature = "macros")] #[cfg(feature = "macros")]
fn parse_command_with_non_string_arg() { fn parse_command_with_non_string_arg() {
#[command(rename = "lowercase")]
#[derive(BotCommand, Debug, PartialEq)] #[derive(BotCommand, Debug, PartialEq)]
#[command(rename = "lowercase")]
enum DefaultCommands { enum DefaultCommands {
Start(i32), Start(i32),
Help, Help,
@ -39,8 +39,8 @@ fn parse_command_with_non_string_arg() {
#[test] #[test]
#[cfg(feature = "macros")] #[cfg(feature = "macros")]
fn attribute_prefix() { fn attribute_prefix() {
#[command(rename = "lowercase")]
#[derive(BotCommand, Debug, PartialEq)] #[derive(BotCommand, Debug, PartialEq)]
#[command(rename = "lowercase")]
enum DefaultCommands { enum DefaultCommands {
#[command(prefix = "!")] #[command(prefix = "!")]
Start(String), Start(String),
@ -121,9 +121,9 @@ fn parse_with_split() {
#[test] #[test]
#[cfg(feature = "macros")] #[cfg(feature = "macros")]
fn parse_with_split2() { fn parse_with_split2() {
#[derive(BotCommand, Debug, PartialEq)]
#[command(rename = "lowercase")] #[command(rename = "lowercase")]
#[command(parse_with = "split", separator = "|")] #[command(parse_with = "split", separator = "|")]
#[derive(BotCommand, Debug, PartialEq)]
enum DefaultCommands { enum DefaultCommands {
Start(u8, String), Start(u8, String),
Help, Help,
@ -149,8 +149,8 @@ fn parse_custom_parser() {
.map_err(|_| ParseError::Custom("First argument must be a integer!".to_owned().into())) .map_err(|_| ParseError::Custom("First argument must be a integer!".to_owned().into()))
} }
#[command(rename = "lowercase")]
#[derive(BotCommand, Debug, PartialEq)] #[derive(BotCommand, Debug, PartialEq)]
#[command(rename = "lowercase")]
enum DefaultCommands { enum DefaultCommands {
#[command(parse_with = "custom_parse_function")] #[command(parse_with = "custom_parse_function")]
Start(u8, String), Start(u8, String),
@ -166,9 +166,9 @@ fn parse_custom_parser() {
#[test] #[test]
#[cfg(feature = "macros")] #[cfg(feature = "macros")]
fn parse_named_fields() { fn parse_named_fields() {
#[derive(BotCommand, Debug, PartialEq)]
#[command(rename = "lowercase")] #[command(rename = "lowercase")]
#[command(parse_with = "split")] #[command(parse_with = "split")]
#[derive(BotCommand, Debug, PartialEq)]
enum DefaultCommands { enum DefaultCommands {
Start { num: u8, data: String }, Start { num: u8, data: String },
Help, Help,
@ -183,8 +183,8 @@ fn parse_named_fields() {
#[test] #[test]
#[cfg(feature = "macros")] #[cfg(feature = "macros")]
fn descriptions_off() { fn descriptions_off() {
#[command(rename = "lowercase")]
#[derive(BotCommand, Debug, PartialEq)] #[derive(BotCommand, Debug, PartialEq)]
#[command(rename = "lowercase")]
enum DefaultCommands { enum DefaultCommands {
#[command(description = "off")] #[command(description = "off")]
Start, Start,