Fix sticker tests

This commit is contained in:
Maybe Waffle 2022-09-25 21:07:37 +04:00
parent 7550af9a25
commit 8cad09498c
2 changed files with 43 additions and 42 deletions

View file

@ -1435,42 +1435,43 @@ mod tests {
#[test]
fn de_sticker() {
let json = r#"{
"message_id": 199787,
"from": {
"id": 250918540,
"is_bot": false,
"first_name": "Андрей",
"last_name": "Власов",
"username": "aka_dude",
"language_code": "en"
},
"chat": {
"id": 250918540,
"first_name": "Андрей",
"last_name": "Власов",
"username": "aka_dude",
"type": "private"
},
"date": 1568290188,
"sticker": {
"width": 512,
"height": 512,
"emoji": "😡",
"set_name": "AdvenTimeAnim",
"is_animated": true,
"is_video": false,
"thumb": {
"file_id": "AAQCAAMjAAOw0PgMaabKAcaXKCBLubkPAAQBAAdtAAPGKwACFgQ",
"file_unique_id":"",
"file_size": 4118,
"width": 128,
"height": 128
},
"file_id": "CAADAgADIwADsND4DGmmygHGlyggFgQ",
"file_unique_id":"",
"file_size": 16639
}
}"#;
"message_id": 199787,
"from": {
"id": 250918540,
"is_bot": false,
"first_name": "Андрей",
"last_name": "Власов",
"username": "aka_dude",
"language_code": "en"
},
"chat": {
"id": 250918540,
"first_name": "Андрей",
"last_name": "Власов",
"username": "aka_dude",
"type": "private"
},
"date": 1568290188,
"sticker": {
"width": 512,
"height": 512,
"emoji": "😡",
"set_name": "AdvenTimeAnim",
"is_animated": true,
"is_video": false,
"type": "regular",
"thumb": {
"file_id": "AAMCAgADGQEAARIt0GMwiZ6n4nRbxdpM3pL8vPX6PVAhAAIjAAOw0PgMaabKAcaXKCABAAdtAAMpBA",
"file_unique_id": "AQADIwADsND4DHI",
"file_size": 4118,
"width": 128,
"height": 128
},
"file_id": "CAACAgIAAxkBAAESLdBjMImep-J0W8XaTN6S_Lz1-j1QIQACIwADsND4DGmmygHGlyggKQQ",
"file_unique_id": "AgADIwADsND4DA",
"file_size": 16639
}
}"#;
from_str::<Message>(json).unwrap();
}

View file

@ -119,8 +119,8 @@ pub enum StickerFormat {
/// let _ = sticker.is_regular();
/// let _ = sticker.kind.is_regular();
///
/// let _ sticker.mask_position();
/// let _ sticker.kind.mask_position();
/// let _ = sticker.mask_position();
/// let _ = sticker.kind.mask_position();
/// ```
impl Deref for Sticker {
type Target = StickerKind;
@ -418,7 +418,7 @@ mod tests {
#[test]
fn sticker_format_serde() {
{
let json = r#"{"is_animation":false,"is_video":false}"#;
let json = r#"{"is_animated":false,"is_video":false}"#;
let fmt: StickerFormat = serde_json::from_str(json).unwrap();
assert_eq!(fmt, StickerFormat::Raster);
@ -426,7 +426,7 @@ mod tests {
assert_eq!(json, json2);
}
{
let json = r#"{"is_animation":true,"is_video":false}"#;
let json = r#"{"is_animated":true,"is_video":false}"#;
let fmt: StickerFormat = serde_json::from_str(json).unwrap();
assert_eq!(fmt, StickerFormat::Animated);
@ -434,7 +434,7 @@ mod tests {
assert_eq!(json, json2);
}
{
let json = r#"{"is_animation":false,"is_video":true}"#;
let json = r#"{"is_animated":false,"is_video":true}"#;
let fmt: StickerFormat = serde_json::from_str(json).unwrap();
assert_eq!(fmt, StickerFormat::Video);
@ -442,7 +442,7 @@ mod tests {
assert_eq!(json, json2);
}
{
let json = r#"{"is_animation":true,"is_video":true}"#;
let json = r#"{"is_animated":true,"is_video":true}"#;
let fmt: Result<StickerFormat, _> = serde_json::from_str(json);
assert!(fmt.is_err());
}