add test for user language being blank

This commit is contained in:
Paul Campbell 2023-12-16 16:41:59 +00:00
parent c9c35bed2b
commit 0662c07417
2 changed files with 55 additions and 0 deletions

View file

@ -113,4 +113,36 @@ mod tests {
};
assert_eq!(user, expected);
}
#[test]
fn deserialize_works_with_blank_language() {
let data = include_str!("../../../test_data/example_user_blank_language.json");
let user: User = serde_json::from_str(data).unwrap();
let expected = User {
active: IsActive::Yes,
avatar_url: OptionalUrl::Some(
Url::from_str("https://codeberg.org/avatars/foo-bar").unwrap(),
),
created: DateTime::from_str("2022-11-04T14:41:29Z").unwrap(),
description: String::from(""),
email: Email::from_str("example@mail.com").unwrap(),
followers_count: 2,
following_count: 1,
full_name: String::from(""),
id: 12345,
is_admin: IsAdmin::No,
language: Locale::None,
last_login: DateTime::from_str("2023-07-26T19:38:27Z").unwrap(),
location: String::from(""),
login: String::from("ExampleUser"),
login_name: String::from(""),
prohibit_login: ProhibitLogin::No,
restricted: IsRestricted::No,
starred_repos_count: 0,
username: String::from("ExampleUser"),
visibility: Visibility::Public,
website: OptionalUrl::Some(Url::from_str("https://example.com").unwrap()),
};
assert_eq!(user, expected);
}
}

View file

@ -0,0 +1,23 @@
{
"active": true,
"avatar_url": "https://codeberg.org/avatars/foo-bar",
"created": "2022-11-04T14:41:29Z",
"description": "",
"email": "example@mail.com",
"followers_count": 2,
"following_count": 1,
"full_name": "",
"id": 12345,
"is_admin": false,
"language": "",
"last_login": "2023-07-26T19:38:27Z",
"location": "",
"login": "ExampleUser",
"login_name": "",
"prohibit_login": false,
"restricted": false,
"starred_repos_count": 0,
"username": "ExampleUser",
"visibility": "public",
"website": "https://example.com"
}