create config.json file for test

pull/15984/head
Steven Powell 2023-03-07 10:12:03 -08:00
parent 93a8607044
commit 2b41e1d4db
1 changed files with 15 additions and 0 deletions

View File

@ -18,10 +18,13 @@ package assets
import (
"fmt"
"os"
"path/filepath"
"testing"
"github.com/spf13/viper"
"k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/tests"
)
// mapsEqual returns true if and only if `a` contains all the same pairs as `b`.
@ -153,6 +156,18 @@ func TestSelectAndPersistImages(t *testing.T) {
gcpAuth := Addons["gcp-auth"]
gcpAuthImages := gcpAuth.Images
// this test will write to ~/.minikube/profiles/minikube/config.json so need to create the file
home := tests.MakeTempDir(t)
profilePath := filepath.Join(home, "profiles", "minikube")
if err := os.MkdirAll(profilePath, 0777); err != nil {
t.Fatalf("failed to create profile directory: %v", err)
}
f, err := os.Create(filepath.Join(profilePath, "config.json"))
if err != nil {
t.Fatalf("failed to create config file: %v", err)
}
defer f.Close()
type expected struct {
numImages int
numRegistries int