Skip to content

Commit

Permalink
Update test to use new kubeconfig_from_text and Kubeconfig::from_text…
Browse files Browse the repository at this point in the history
… functions
  • Loading branch information
imp committed Nov 18, 2021
1 parent 7f5d807 commit 8f7a84a
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions kube-client/src/config/file_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -538,12 +538,12 @@ 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_text(config_yaml).unwrap();

assert_eq!(config.clusters[0].name, "eks");
assert_eq!(config.clusters[1].name, "minikube");
assert_eq!(config[0].clusters[0].name, "eks");
assert_eq!(config[0].clusters[1].name, "minikube");
assert_eq!(
config.clusters[1].cluster.extensions.as_ref().unwrap()[0]
config[0].clusters[1].cluster.extensions.as_ref().unwrap()[0]
.extension
.get("provider"),
Some(&Value::String("minikube.sigs.k8s.io".to_owned()))
Expand Down Expand Up @@ -593,9 +593,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_text(config_yaml)?;

// Ensure we have data from both documents:
assert_eq!(cfg.clusters[0].name, "k3d-promstack");
Expand Down

0 comments on commit 8f7a84a

Please sign in to comment.