use std::path::PathBuf;
use crate::command::{ChartPathOptions, ChartRef, Pull, Push, Verify};
use crate::options::Secret;
#[test]
fn fetch_commands_build_what_the_literals_build() {
let chart = || ChartRef::Repo("repo/web".to_owned());
let chart_path = ChartPathOptions {
verify: true,
..ChartPathOptions::default()
};
assert_builds! {
"pull": Pull::builder(chart())
.chart_path(chart_path.clone())
.untar(true)
.untardir("/charts")
.destination("/out")
.build()
=> Pull {
chart_path,
untar: true,
untardir: Some(PathBuf::from("/charts")),
destination: Some(PathBuf::from("/out")),
..Pull::new(chart())
};
"pull defaults": Pull::builder(chart()).build() => Pull::new(chart());
"push": Push::builder("web-1.0.0.tgz", "oci://registry.example/charts")
.plain_http(true)
.username("ci")
.password("hunter2")
.ca_file("/ca.pem")
.build()
=> Push {
plain_http: true,
username: Some("ci".to_owned()),
password: Some(Secret::from("hunter2")),
ca_file: Some(PathBuf::from("/ca.pem")),
..Push::new("web-1.0.0.tgz", "oci://registry.example/charts")
};
"verify": Verify::builder("web-1.0.0.tgz").keyring("/ring.gpg").build()
=> Verify { keyring: Some(PathBuf::from("/ring.gpg")), ..Verify::new("web-1.0.0.tgz") };
}
}