use std::path::PathBuf;
use crate::command::{RegistryLogin, RegistryLogout};
use crate::options::Secret;
#[test]
fn registry_commands_build_what_the_literals_build() {
assert_builds! {
"login": RegistryLogin::builder("registry.example")
.username("ci")
.password("hunter2")
.insecure(true)
.cert_file("/cert.pem")
.build()
=> RegistryLogin {
username: Some("ci".to_owned()),
password: Some(Secret::from("hunter2")),
insecure: true,
cert_file: Some(PathBuf::from("/cert.pem")),
..RegistryLogin::new("registry.example")
};
"logout": RegistryLogout::builder("registry.example").build()
=> RegistryLogout::new("registry.example");
}
}
#[test]
fn the_login_builder_cannot_print_a_secret() {
let login = RegistryLogin::builder("registry.example").password("hunter2");
assert_not_debug!(RegistryLogin::builder("registry.example").password("hunter2"));
assert!(!format!("{:?}", login.build()).contains("hunter2"));
}