helm-rs 0.1.2

Typed Rust API for Helm 4: swappable backends, native chart, values and release reading
Documentation
use std::path::PathBuf;
use std::time::Duration;

use crate::command::{RepoAdd, RepoIndex, RepoRemove, RepoUpdate};
use crate::options::Secret;

#[test]
fn repo_commands_build_what_the_literals_build() {
    assert_builds! {
        "add": RepoAdd::builder("web", "https://charts.example")
            .username("ci")
            .password("hunter2")
            .force_update(true)
            .timeout(Duration::from_secs(5))
            .ca_file("/ca.pem")
            .build()
            => RepoAdd {
                username: Some("ci".to_owned()),
                password: Some(Secret::from("hunter2")),
                force_update: true,
                timeout: Some(Duration::from_secs(5)),
                ca_file: Some(PathBuf::from("/ca.pem")),
                ..RepoAdd::new("web", "https://charts.example")
            };
        "index": RepoIndex::builder("./charts").url("https://charts.example").json(true).merge("old.yaml").build()
            => RepoIndex {
                url: Some("https://charts.example".to_owned()),
                json: true,
                merge: Some(PathBuf::from("old.yaml")),
                ..RepoIndex::new("./charts")
            };
        "remove": RepoRemove::builder(["a"]).name("b").build() => RepoRemove::new(["a", "b"]);
        "update": RepoUpdate::builder().name("a").timeout(Duration::from_secs(5)).build()
            => RepoUpdate { names: vec!["a".to_owned()], timeout: Some(Duration::from_secs(5)) };
        "update defaults": RepoUpdate::builder().build() => RepoUpdate::default();
    }
}

#[test]
fn repo_collections_add_and_replace() {
    assert_vec_setters!(
        RepoRemove::builder(["first"]),
        names,
        name,
        names,
        String,
        ["first"],
        ["a", "b", "c"]
    );
    assert_vec_setters!(
        RepoUpdate::builder(),
        names,
        name,
        names,
        String,
        [],
        ["a", "b", "c"]
    );
}

#[test]
fn the_add_builder_cannot_print_a_secret() {
    let add = RepoAdd::builder("web", "https://charts.example").password("hunter2");

    assert_not_debug!(RepoAdd::builder("web", "https://charts.example").password("hunter2"));
    assert!(!format!("{:?}", add.build()).contains("hunter2"));
}