Skip to content

Commit 2a29dc3

Browse files
committed
test: add unit test for KubernetesClusterInfo creation
1 parent 3b4c662 commit 2a29dc3

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

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

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

0 commit comments

Comments
 (0)