helm-rs 0.1.0

Typed Rust API for Helm 4: swappable backends, native chart, values and release reading
Documentation
//! Tests of the annotation walk against what helm-schema 0.24.0 does with the same values.

use super::annotations;

#[test]
fn a_root_block_does_not_leak_into_the_first_key() {
    let values =
        "# @schema.root\n# title: Root\n# @schema.root\n# @schema\n# title: Key\n# @schema\na: 1\n";
    let found = annotations(values, false).expect("reads");
    let titles: Vec<(bool, &str)> = found
        .iter()
        .map(|a| (a.root, a.keywords["title"].as_str().expect("title")))
        .collect();

    assert_eq!(titles, vec![(true, "Root"), (false, "Key")]);
}

/// helm-schema 0.24.0 aborts with a stack overflow on a values file whose alias contains itself;
/// reading it is an error here, in the words of `yaml.v3`'s own check.
#[test]
fn an_alias_that_contains_itself_is_an_error() {
    for values in ["node: &loop\n  self: *loop\n", "a: &a\n  b:\n    c: *a\n"] {
        let error = annotations(values, false).expect_err("fails");

        assert!(
            error.to_string().starts_with("yaml: anchor '")
                && error.to_string().ends_with("' value contains itself"),
            "{error}"
        );
    }
}