use temp file for kubeconfig in test

Kubernetes-commit: 03af5089afb5d31707e7d91e55dfd6b157e6f8e1
This commit is contained in:
juanvallejo
2018-08-13 14:29:34 -04:00
committed by Kubernetes Publisher
parent 744b11616f
commit 69308bcf06

View File

@@ -132,9 +132,17 @@ func TestModifyContext(t *testing.T) {
"clean": true,
}
tempPath, err := ioutil.TempFile("", "testclientcmd-")
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
defer os.Remove(tempPath.Name())
pathOptions := NewDefaultPathOptions()
config := createValidTestConfig()
pathOptions.GlobalFile = tempPath.Name()
// define new context and assign it - our path options config
config.Contexts["updated"] = &clientcmdapi.Context{
Cluster: "updated",