mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-22 22:46:39 +01:00
Add serialization tests for ChatId
This commit is contained in:
parent
e58d40a765
commit
4094c1ceb8
1 changed files with 21 additions and 0 deletions
|
@ -64,6 +64,27 @@ pub enum ChatId {
|
||||||
ChannelUsername(String),
|
ChannelUsername(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn chat_id_id_serialization() {
|
||||||
|
let expected_json = String::from(r#"123456"#);
|
||||||
|
let actual_json = serde_json::to_string(&ChatId::Id(123456)).unwrap();
|
||||||
|
|
||||||
|
assert_eq!(expected_json, actual_json)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn chat_id_channel_username_serialization() {
|
||||||
|
let expected_json = String::from(r#""@username""#);
|
||||||
|
let actual_json = serde_json::to_string(&ChatId::ChannelUsername(String::from("@username"))).unwrap();
|
||||||
|
|
||||||
|
assert_eq!(expected_json, actual_json)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub mod get_me;
|
pub mod get_me;
|
||||||
pub mod send_message;
|
pub mod send_message;
|
||||||
pub mod forward_message;
|
pub mod forward_message;
|
||||||
|
|
Loading…
Reference in a new issue