@@ -23,10 +23,13 @@ import (
2323 "encoding/json"
2424 "fmt"
2525 "os/exec"
26+ "path/filepath"
27+ "runtime"
2628 "strings"
2729 "testing"
2830
2931 "k8s.io/minikube/pkg/minikube/constants"
32+ "k8s.io/minikube/pkg/minikube/localpath"
3033)
3134
3235// TestNoKubernetes tests starting minikube without Kubernetes,
@@ -52,6 +55,7 @@ func TestNoKubernetes(t *testing.T) {
5255 {"StartWithK8s" , validateStartWithK8S },
5356 {"StartWithStopK8s" , validateStartWithStopK8s },
5457 {"Start" , validateStartNoK8S },
58+ {"VerifyNok8sNoK8sDownloads" , VerifyNoK8sDownloadCache },
5559 {"VerifyK8sNotRunning" , validateK8SNotRunning },
5660 {"ProfileList" , validateProfileListNoK8S },
5761 {"Stop" , validateStopNoK8S },
@@ -76,6 +80,25 @@ func TestNoKubernetes(t *testing.T) {
7680 })
7781}
7882
83+ // VerifyNoK8sDownloadCache verifies that starting minikube with --no-kubernetes does not create a download cache.
84+ func VerifyNoK8sDownloadCache (ctx context.Context , t * testing.T , profile string ) {
85+ defer PostMortemLogs (t , profile )
86+
87+ cachePath := filepath .Join (localpath .MiniPath (), "cache" , runtime .GOOS , runtime .GOARCH , constants .NoKubernetesVersion )
88+
89+ t .Logf ("Checking cache directory: %s" , cachePath )
90+ files , err := filepath .Glob (filepath .Join (cachePath , "*" ))
91+ if err != nil {
92+ t .Errorf ("Error reading cache directory: %v" , err )
93+ return
94+ }
95+
96+ if len (files ) > 0 {
97+ t .Logf ("Files found in cache directory: %v" , files )
98+ t .Errorf ("Cache directory should not contain files when using --no-kubernetes" )
99+ }
100+ }
101+
79102// validateStartNoK8sWithVersion expect an error when starting a minikube cluster without kubernetes and with a kubernetes version.
80103func validateStartNoK8sWithVersion (ctx context.Context , t * testing.T , profile string ) {
81104 defer PostMortemLogs (t , profile )
0 commit comments