From 4a34d2d989c34e2aa2de8f3a673d1c8a4f6799d1 Mon Sep 17 00:00:00 2001 From: Cyril Plisko Date: Sat, 20 Nov 2021 12:06:24 +0200 Subject: [PATCH] Update unit tests Signed-off-by: Cyril Plisko --- kube-client/src/config/file_config.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/kube-client/src/config/file_config.rs b/kube-client/src/config/file_config.rs index afed24591..ae0deba1d 100644 --- a/kube-client/src/config/file_config.rs +++ b/kube-client/src/config/file_config.rs @@ -543,7 +543,7 @@ users: client-certificate: /home/kevin/.minikube/profiles/minikube/client.crt client-key: /home/kevin/.minikube/profiles/minikube/client.key"; - let config: Kubeconfig = serde_yaml::from_str(config_yaml).unwrap(); + let config = Kubeconfig::from_yaml(config_yaml).unwrap(); assert_eq!(config.clusters[0].name, "eks"); assert_eq!(config.clusters[1].name, "minikube"); @@ -598,9 +598,7 @@ users: client-certificate-data: aGVsbG8K client-key-data: aGVsbG8K "#; - let file = tempfile::NamedTempFile::new().expect("create config tempfile"); - fs::write(file.path(), config_yaml).unwrap(); - let cfg = Kubeconfig::read_from(file.path())?; + let cfg = Kubeconfig::from_yaml(config_yaml)?; // Ensure we have data from both documents: assert_eq!(cfg.clusters[0].name, "k3d-promstack"); @@ -608,4 +606,11 @@ users: Ok(()) } + + #[test] + fn kubeconfig_from_empty_string() { + let cfg = Kubeconfig::from_yaml("").unwrap(); + + assert_eq!(cfg, Kubeconfig::default()); + } }