Add test for entities::Account

master
Paul Woolcock 6 years ago
parent 4ff27dd049
commit 0913926702
  1. 1
      Cargo.toml
  2. 83
      src/entities/account.rs
  3. 3
      src/lib.rs

@ -33,6 +33,7 @@ skeptic = "0.13.3"
[dev-dependencies] [dev-dependencies]
skeptic = "0.13.3" skeptic = "0.13.3"
tempfile = "3.0.3"
[package.metadata.docs.rs] [package.metadata.docs.rs]
features = ["all"] features = ["all"]

@ -122,3 +122,86 @@ impl<'a> CredentialsBuilder<'a> {
Ok(form) Ok(form)
} }
} }
#[cfg(test)]
mod tests {
use super::*;
use tempfile::NamedTempFile;
#[test]
fn test_credentials_builder_to_form() {
let avatar = NamedTempFile::new().expect("Couldn't make avatar file");
let header = NamedTempFile::new().expect("Couldn't make header file");
let tests = [
(None, None, None, None),
(Some("my-display-name"), None, None, None),
(None, Some("my-note"), None, None),
(None, None, Some(avatar.path().clone()), None),
(None, None, None, Some(header.path().clone())),
(Some("my-display-name"), Some("my-note"), None, None),
(
Some("my-display-name"),
None,
Some(avatar.path().clone()),
None,
),
(None, Some("my-note"), Some(avatar.path().clone()), None),
(None, Some("my-note"), None, Some(header.path().clone())),
(
None,
None,
Some(avatar.path().clone()),
Some(header.path().clone()),
),
(
Some("my-display-name"),
None,
None,
Some(header.path().clone()),
),
(
Some("my-display-name"),
Some("my-note"),
Some(avatar.path().clone()),
None,
),
(
Some("my-display-name"),
Some("my-note"),
None,
Some(header.path().clone()),
),
(
Some("my-display-name"),
None,
Some(avatar.path().clone()),
Some(header.path().clone()),
),
(
None,
Some("my-note"),
Some(avatar.path().clone()),
Some(header.path().clone()),
),
(
Some("my-display-name"),
Some("my-note"),
Some(avatar.path().clone()),
Some(header.path().clone()),
),
];
for test in tests.into_iter() {
let (display_name, note, avatar, header) = test;
let credentials_builder = CredentialsBuilder {
display_name: *display_name,
note: *note,
avatar: *avatar,
header: *header,
};
let _form = credentials_builder
.into_form()
.expect("could not create form");
}
}
}

@ -43,6 +43,9 @@ extern crate url;
#[cfg(feature = "toml")] #[cfg(feature = "toml")]
extern crate toml as tomlcrate; extern crate toml as tomlcrate;
#[cfg(test)]
extern crate tempfile;
use std::{borrow::Cow, ops}; use std::{borrow::Cow, ops};
use reqwest::{ use reqwest::{

Loading…
Cancel
Save