use temp file for kubeconfig in test

This commit is contained in:
juanvallejo 2018-08-13 14:29:34 -04:00
parent d745508cc0
commit 03af5089af
No known key found for this signature in database
GPG Key ID: 7D2C958002D6448D

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",