Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8e31f27dff
|
||
|
|
f91069cded
|
||
|
|
8de38f204e
|
||
|
|
04eaa1dff1
|
+3
-22
@@ -56,7 +56,7 @@ pub struct UserProfile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn init_user_profile(usr: &User) -> UserProfile {
|
pub fn init_user_profile(usr: &User) -> UserProfile {
|
||||||
UserProfile {
|
let usr_profile = UserProfile {
|
||||||
user_id: usr.id,
|
user_id: usr.id,
|
||||||
phone_number: usr.phone_number.clone(),
|
phone_number: usr.phone_number.clone(),
|
||||||
username: usr.username.clone(),
|
username: usr.username.clone(),
|
||||||
@@ -64,26 +64,7 @@ pub fn init_user_profile(usr: &User) -> UserProfile {
|
|||||||
lastname: usr.lastname.clone(),
|
lastname: usr.lastname.clone(),
|
||||||
created: usr.created,
|
created: usr.created,
|
||||||
last_login: usr.last_login,
|
last_login: usr.last_login,
|
||||||
}
|
};
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
usr_profile
|
||||||
mod tests {
|
|
||||||
#[test]
|
|
||||||
fn test_init_user_profile() {
|
|
||||||
let usr = super::User {
|
|
||||||
id: uuid::Uuid::new_v4(),
|
|
||||||
phone_number: String::from("+12308438462"),
|
|
||||||
username: String::from("Cowboy99"),
|
|
||||||
password: String::from("238n7cyr2q89d3xhe2"),
|
|
||||||
firstname: String::from("BillyBob"),
|
|
||||||
lastname: String::from("Jones"),
|
|
||||||
created: Some(time::OffsetDateTime::now_utc()),
|
|
||||||
last_login: Some(time::OffsetDateTime::now_utc()),
|
|
||||||
..Default::default()
|
|
||||||
};
|
|
||||||
|
|
||||||
let profile = super::init_user_profile(&usr);
|
|
||||||
assert_eq!(usr.phone_number, profile.phone_number, "Phone numbers are not equal");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user