Fix the tests

This commit is contained in:
Temirkhan Myrzamadi 2021-03-13 23:05:50 +06:00 committed by Eric S. Londres
parent 0391542214
commit 8b1c3b8101
4 changed files with 14 additions and 13 deletions

View file

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

View file

@ -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 {

View file

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

View file

@ -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,