Add regression test for WebhookInfo with an empty url

This commit is contained in:
Maybe Waffle 2022-02-01 18:31:04 +03:00
parent a36794c5d3
commit 16630133db

View file

@ -42,3 +42,25 @@ pub struct WebhookInfo {
/// types.
pub allowed_updates: Option<Vec<AllowedUpdate>>,
}
// Regression test for <https://github.com/teloxide/teloxide-core/pull/166>
#[test]
fn empty_url() {
let json = r#"{"url":"","has_custom_certificate":false,"pending_update_count":0,"allowed_updates":["message"]}"#;
let actual: WebhookInfo = serde_json::from_str(json).unwrap();
let expected = WebhookInfo {
url: None,
has_custom_certificate: false,
pending_update_count: 0,
ip_address: None,
last_error_date: None,
last_error_message: None,
max_connections: None,
allowed_updates: Some(vec![AllowedUpdate::Message]),
};
assert_eq!(actual, expected);
let json = r#"{"ok":true,"result":{"url":"","has_custom_certificate":false,"pending_update_count":0,"allowed_updates":["message"]}}"#;
serde_json::from_str::<crate::net::TelegramResponse<WebhookInfo>>(json).unwrap();
}