From d98a484f876f883fa3d8071e89a50abe757f6890 Mon Sep 17 00:00:00 2001 From: Thomas Stromberg Date: Fri, 24 Apr 2020 17:11:52 -0700 Subject: [PATCH] Ensure that there is an output file to operate on --- pkg/minikube/download/download.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/pkg/minikube/download/download.go b/pkg/minikube/download/download.go index 98011e6145..03ef7bdb4d 100644 --- a/pkg/minikube/download/download.go +++ b/pkg/minikube/download/download.go @@ -49,19 +49,21 @@ func download(src string, dst string) error { }, } + if err := os.MkdirAll(filepath.Dir(dst), 0755); err != nil { + return errors.Wrap(err, "mkdir") + } + // Don't bother with getter.MockGetter, as we don't provide a way to inspect the outcome if Mock { glog.Infof("Mock download: %s -> %s", src, dst) - return nil + // Callers expect the file to exist + _, err := os.Create(dst) + return err } // Politely prevent tests from shooting themselves in the foot if underTest() { - return fmt.Errorf("unmocked download under test, set download.Mock=true") - } - - if err := os.MkdirAll(filepath.Dir(dst), 0750); err != nil { - return errors.Wrap(err, "mkdir") + return fmt.Errorf("unmocked download under test") } glog.Infof("Downloading: %s -> %s", src, dst)