Add a test for UpdateCredentials::build

master
Paul Woolcock 6 years ago
parent 989d9a5965
commit 375e4af286
  1. 4
      src/entities/account.rs
  2. 19
      src/requests/update_credentials.rs

@ -81,7 +81,7 @@ fn string_or_bool<'de, D: Deserializer<'de>>(val: D) -> ::std::result::Result<bo
})
}
#[derive(Debug, Default, Clone, Copy, Serialize)]
#[derive(Debug, Default, Clone, Copy, Serialize, PartialEq)]
pub(crate) struct UpdateSource {
#[serde(skip_serializing_if = "Option::is_none")]
pub(crate) privacy: Option<status_builder::Visibility>,
@ -89,7 +89,7 @@ pub(crate) struct UpdateSource {
pub(crate) sensitive: Option<bool>,
}
#[derive(Debug, Default, Serialize)]
#[derive(Debug, Default, Serialize, PartialEq)]
pub(crate) struct Credentials {
#[serde(skip_serializing_if = "Option::is_none")]
pub(crate) display_name: Option<String>,

@ -183,6 +183,7 @@ impl UpdateCredsRequest {
#[cfg(test)]
mod tests {
use super::*;
use entities::account::{Credentials, UpdateSource};
use status_builder::Visibility;
#[test]
@ -273,4 +274,22 @@ mod tests {
}
);
}
#[test]
fn test_update_creds_request_build() {
let mut builder = UpdateCredsRequest::new();
builder.display_name("test").note("a note");
let creds = builder.build().expect("Couldn't build Credentials");
assert_eq!(
creds,
Credentials {
display_name: Some("test".into()),
note: Some("a note".into()),
source: Some(UpdateSource {
..Default::default()
}),
..Default::default()
}
);
}
}

Loading…
Cancel
Save