mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-22 06:25:10 +01:00
Test that all possible updates are specified in Kind::full_set()
This commit is contained in:
parent
ae88d56e0d
commit
ccdeb3f2b0
1 changed files with 42 additions and 1 deletions
|
@ -95,10 +95,12 @@ mod tests {
|
|||
#[cfg(feature = "macros")]
|
||||
use crate::{
|
||||
self as teloxide, // fixup for the `BotCommands` macro
|
||||
dispatching::{HandlerExt, UpdateFilterExt},
|
||||
dispatching::{handler_description::Kind, HandlerExt, UpdateFilterExt},
|
||||
types::{AllowedUpdate::*, Update},
|
||||
utils::command::BotCommands,
|
||||
};
|
||||
#[cfg(feature = "macros")]
|
||||
use dptree::description::EventKind;
|
||||
|
||||
#[cfg(feature = "macros")]
|
||||
#[derive(BotCommands, Clone)]
|
||||
|
@ -132,4 +134,43 @@ mod tests {
|
|||
fn discussion_648() {
|
||||
panic!("this test requires `macros` feature")
|
||||
}
|
||||
|
||||
// Test that all possible updates are specified in `Kind::full_set()`
|
||||
#[test]
|
||||
#[cfg(feature = "macros")]
|
||||
fn allowed_updates_full_set() {
|
||||
let full_set = Kind::full_set();
|
||||
let allowed_updates_reference = vec![
|
||||
Message,
|
||||
EditedMessage,
|
||||
ChannelPost,
|
||||
EditedChannelPost,
|
||||
MessageReaction,
|
||||
MessageReactionCount,
|
||||
InlineQuery,
|
||||
ChosenInlineResult,
|
||||
CallbackQuery,
|
||||
ShippingQuery,
|
||||
PreCheckoutQuery,
|
||||
Poll,
|
||||
PollAnswer,
|
||||
MyChatMember,
|
||||
ChatMember,
|
||||
ChatJoinRequest,
|
||||
ChatBoost,
|
||||
RemovedChatBoost,
|
||||
];
|
||||
|
||||
for update in allowed_updates_reference {
|
||||
match update {
|
||||
// CAUTION: Don't forget to add new `UpdateKind` to `allowed_updates_reference`!
|
||||
Message | EditedMessage | ChannelPost | EditedChannelPost | MessageReaction
|
||||
| MessageReactionCount | InlineQuery | ChosenInlineResult | CallbackQuery
|
||||
| ShippingQuery | PreCheckoutQuery | Poll | PollAnswer | MyChatMember
|
||||
| ChatMember | ChatJoinRequest | ChatBoost | RemovedChatBoost => {
|
||||
assert!(full_set.contains(&Kind(update)))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue