update teloxide-macros

Former-commit-id: 44e134c47e
This commit is contained in:
Maybe Waffle 2022-08-28 15:19:38 +04:00
parent c6bfe682df
commit 4c4797d85e
3 changed files with 11 additions and 70 deletions

View file

@ -58,7 +58,7 @@ full = [
[dependencies]
teloxide-core = { version = "0.7.0", default-features = false }
teloxide-macros = { version = "0.6.3", optional = true }
#teloxide-macros = { version = "0.6.3", optional = true }
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
@ -67,7 +67,7 @@ dptree = "0.3.0"
# These lines are used only for development.
# teloxide-core = { git = "https://github.com/teloxide/teloxide-core", rev = "b13393d", default-features = false }
# teloxide-macros = { git = "https://github.com/teloxide/teloxide-macros", rev = "44d91c5", optional = true }
teloxide-macros = { git = "https://github.com/teloxide/teloxide-macros", rev = "c851482", optional = true }
# dptree = { git = "https://github.com/teloxide/dptree", rev = "df578e4" }
tokio = { version = "1.8", features = ["fs"] }

View file

@ -233,8 +233,8 @@ fn rename_rules() {
GggGgg,
#[command(rename = "SCREAMING-KEBAB-CASE")]
HhhHhh,
#[command(rename = "Bar")]
Foo,
//#[command(rename = "Bar")]
//Foo,
}
assert_eq!(DefaultCommands::AaaAaa, DefaultCommands::parse("/aaaaaa", "").unwrap());
@ -245,10 +245,15 @@ fn rename_rules() {
assert_eq!(DefaultCommands::FffFff, DefaultCommands::parse("/FFF_FFF", "").unwrap());
assert_eq!(DefaultCommands::GggGgg, DefaultCommands::parse("/ggg-ggg", "").unwrap());
assert_eq!(DefaultCommands::HhhHhh, DefaultCommands::parse("/HHH-HHH", "").unwrap());
assert_eq!(DefaultCommands::Foo, DefaultCommands::parse("/Bar", "").unwrap());
//assert_eq!(DefaultCommands::Foo, DefaultCommands::parse("/Bar",
// "").unwrap());
// assert_eq!(
// "/aaaaaa\n/BBBBBB\n/CccCcc\n/dddDdd\n/eee_eee\n/FFF_FFF\n/ggg-ggg\n/
// HHH-HHH\n/Bar", DefaultCommands::descriptions().to_string()
// );
assert_eq!(
"/aaaaaa\n/BBBBBB\n/CccCcc\n/dddDdd\n/eee_eee\n/FFF_FFF\n/ggg-ggg\n/HHH-HHH\n/Bar",
"/aaaaaa\n/BBBBBB\n/CccCcc\n/dddDdd\n/eee_eee\n/FFF_FFF\n/ggg-ggg\n/HHH-HHH",
DefaultCommands::descriptions().to_string()
);
}

View file

@ -1,64 +0,0 @@
#![allow(deprecated)]
#[cfg(feature = "macros")]
use teloxide::macros::DialogueState;
// We put tests here because macro expand in unit tests in the crate was a
// failure
#[test]
#[cfg(feature = "macros")]
fn compile_test() {
#[allow(dead_code)]
#[derive(DialogueState, Clone)]
#[handler_out(Result<(), teloxide::RequestError>)]
enum State {
#[handler(handle_start)]
Start,
#[handler(handle_have_data)]
HaveData(String),
}
impl Default for State {
fn default() -> Self {
Self::Start
}
}
async fn handle_start() -> Result<(), teloxide::RequestError> {
Ok(())
}
async fn handle_have_data() -> Result<(), teloxide::RequestError> {
Ok(())
}
}
#[test]
#[cfg(feature = "macros")]
fn compile_test_generics() {
#[allow(dead_code)]
#[derive(DialogueState, Clone)]
#[handler_out(Result<(), teloxide::RequestError>)]
enum State<X: Clone + Send + Sync + 'static> {
#[handler(handle_start)]
Start,
#[handler(handle_have_data)]
HaveData(X),
}
impl<X: Clone + Send + Sync + 'static> Default for State<X> {
fn default() -> Self {
Self::Start
}
}
async fn handle_start() -> Result<(), teloxide::RequestError> {
Ok(())
}
async fn handle_have_data() -> Result<(), teloxide::RequestError> {
Ok(())
}
}