From d2fd9fb93a77bf059ca5ee497d360c57d5dc499a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D1=8B=D1=80=D1=86=D0=B5=D0=B2=20=D0=92=D0=B0=D0=B4?= =?UTF-8?q?=D0=B8=D0=BC=20=D0=98=D0=B3=D0=BE=D1=80=D0=B5=D0=B2=D0=B8=D1=87?= Date: Mon, 22 Jul 2024 08:50:52 +0300 Subject: [PATCH] Add tests to issue #1107 --- crates/teloxide-core/src/types/update.rs | 99 ++++++++++++++++++++++++ 1 file changed, 99 insertions(+) diff --git a/crates/teloxide-core/src/types/update.rs b/crates/teloxide-core/src/types/update.rs index 850ea763..cd08a326 100644 --- a/crates/teloxide-core/src/types/update.rs +++ b/crates/teloxide-core/src/types/update.rs @@ -476,6 +476,105 @@ mod test { assert_eq!(expected, actual); } + #[test] + fn issue_1107() { + let update = r#"{ + "message": { + "chat": { + "id": -1001293752024, + "title": "CryptoInside Chat", + "type": "supergroup", + "username": "cryptoinside_talk" + }, + "date": 1721592028, + "from": { + "first_name": "Wert", + "id": 6962620676, + "is_bot": false, + "username": "WertCrypto" + }, + "message_id": 134545, + "story": { + "chat": { + "id": -1002149282975, + "title": "TON Spin", + "type": "channel", + "username": "TONSpinChannel" + }, + "id": 2 + } + }, + "update_id": 439432599 + }"#; + + let Update { kind, .. } = serde_json::from_str::(update).unwrap(); + match kind { + UpdateKind::Message(_) => {} + _ => panic!("Expected `Message`"), + } + + let update = r#"{ + "message": { + "chat": { + "id": -1001293752024, + "title": "CryptoInside Chat", + "type": "supergroup", + "username": "cryptoinside_talk" + }, + "date": 1721592580, + "entities": [ + { + "length": 7, + "offset": 0, + "type": "bot_command" + } + ], + "from": { + "first_name": "the Cable Guy", + "id": 5964236329, + "is_bot": false, + "language_code":"en", + "username": "spacewhaleblues" + }, + "message_id": 134546, + "message_thread_id": 134545, + "reply_to_message": { + "chat": { + "id": -1001293752024, + "title": "CryptoInside Chat", + "type": "supergroup", + "username": "cryptoinside_talk" + }, + "date": 1721592028, + "from": { + "first_name": "Wert", + "id": 6962620676, + "is_bot": false, + "username": "WertCrypto" + }, + "message_id": 134545, + "story": { + "chat": { + "id": -1002149282975, + "title": "TON Spin", + "type": "channel", + "username": "TONSpinChannel" + }, + "id": 2 + } + }, + "text": "/report" + }, + "update_id": 439432600 + }"#; + + let Update { kind, .. } = serde_json::from_str::(update).unwrap(); + match kind { + UpdateKind::Message(_) => {} + _ => panic!("Expected `Message`"), + } + } + #[test] fn de_private_chat_text_message() { let text = r#"