Skip to content

Commit 772b32a

Browse files
committed
test: add unit test for KubernetesClusterInfo creation
1 parent 3b4c662 commit 772b32a

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

crates/stackable-operator/src/utils/cluster_info.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,30 @@ impl KubernetesClusterInfo {
4646
Self { cluster_domain }
4747
}
4848
}
49+
50+
51+
#[cfg(test)]
52+
mod test {
53+
use rstest::rstest;
54+
55+
use super::*;
56+
57+
#[rstest]
58+
#[case(None, KUBERNETES_CLUSTER_DOMAIN_DEFAULT)]
59+
#[case(Some("example.com".parse().unwrap()), "example.com.")]
60+
fn test_kubernetes_cluster_info_creation(
61+
#[case] kubernetes_cluster_domain: Option<DomainName>,
62+
#[case] expected_cluster_domain: &str,
63+
) {
64+
let opts = KubernetesClusterInfoOpts {
65+
kubernetes_cluster_domain,
66+
};
67+
68+
let cluster_info = KubernetesClusterInfo::new(&opts);
69+
70+
assert_eq!(
71+
cluster_info.cluster_domain,
72+
DomainName::from_str(expected_cluster_domain).unwrap()
73+
);
74+
}
75+
}

0 commit comments

Comments
 (0)