Skip to content

Commit

Permalink
Update unit tests
Browse files Browse the repository at this point in the history
Signed-off-by: Cyril Plisko <cyril.plisko@mountall.com>
  • Loading branch information
imp committed Nov 20, 2021
1 parent 841655c commit 4a34d2d
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions kube-client/src/config/file_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -598,14 +598,19 @@ 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");
assert_eq!(cfg.clusters[1].name, "k3d-k3s-default");

Ok(())
}

#[test]
fn kubeconfig_from_empty_string() {
let cfg = Kubeconfig::from_yaml("").unwrap();

assert_eq!(cfg, Kubeconfig::default());
}
}

0 comments on commit 4a34d2d

Please sign in to comment.