Merge pull request #10806 from prezha/fix-testlogfile

make sure path to logs directory exists
pull/10893/head
Medya Ghazizadeh 2021-03-22 18:56:29 -07:00 committed by GitHub
commit ebb13e56ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 0 deletions

View File

@ -20,12 +20,19 @@ import (
"io" "io"
"io/ioutil" "io/ioutil"
"os" "os"
"path/filepath"
"testing" "testing"
"time" "time"
"k8s.io/minikube/pkg/minikube/localpath"
) )
func TestLogFile(t *testing.T) { func TestLogFile(t *testing.T) {
t.Run("SetLogFile", func(t *testing.T) { t.Run("SetLogFile", func(t *testing.T) {
// make sure logs directory exists
if err := os.MkdirAll(filepath.Dir(localpath.AuditLog()), 0755); err != nil {
t.Fatalf("Error creating logs directory: %v", err)
}
if err := setLogFile(); err != nil { if err := setLogFile(); err != nil {
t.Error(err) t.Error(err)
} }