An update will be applied December 9th, between 12PM and 1:00PM EST (UTC -5:00). The site may be slow during that time.

Commit ad876a3e authored by Ben Boeckel's avatar Ben Boeckel
Browse files

tests: add deserialization test for UserBasic

parent d5f4216b
{
"username": "ben.boeckel",
"web_url": "https://gitlab.example.com/u/ben.boeckel",
"name": "Ben Boeckel",
"state": "active",
"avatar_url": "https://example.com/avatar.png",
"id": 13
}
......@@ -15,3 +15,6 @@ mod types;
pub use error::Error;
pub use gitlab::Gitlab;
pub use types::*;
#[cfg(test)]
mod test;
extern crate serde;
use self::serde::Deserialize;
extern crate serde_json;
use self::serde_json::from_reader;
use super::types::*;
use std::fs::File;
fn read_test_file<T: Deserialize>(name: &str) -> T {
let fin = File::open(format!(concat!(env!("CARGO_MANIFEST_DIR"), "/data/{}.json"), name)).unwrap();
from_reader::<File, T>(fin).unwrap()
}
#[test]
fn test_read_user_basic() {
let user_basic: UserBasic = read_test_file("user_basic");
assert_eq!(user_basic.username, "ben.boeckel");
assert_eq!(user_basic.name, "Ben Boeckel");
assert_eq!(user_basic.id, UserId::new(13));
assert_eq!(user_basic.state, UserState::Active);
assert_eq!(user_basic.avatar_url, "https://example.com/avatar.png");
assert_eq!(user_basic.web_url, "https://gitlab.example.com/u/ben.boeckel");
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment