@@ -22,7 +22,6 @@ import (
2222 "context"
2323 "encoding/json"
2424 "fmt"
25- "os"
2625 "os/exec"
2726 "path/filepath"
2827 "runtime"
@@ -87,23 +86,16 @@ func VerifyNoK8sDownloadCache(ctx context.Context, t *testing.T, profile string)
8786
8887 cachePath := filepath .Join (localpath .MiniPath (), "cache" , runtime .GOOS , runtime .GOARCH , constants .NoKubernetesVersion )
8988
90- // Check if the cache directory exists at all
9189 t .Logf ("Checking cache directory: %s" , cachePath )
92- if _ , err := os .Stat (cachePath ); err == nil {
93- // Directory exists - let's see what's in it for debugging
94- if files , err := filepath .Glob (filepath .Join (cachePath , "*" )); err == nil && len (files ) > 0 {
95- t .Logf ("Files found in cache directory:" )
96- for _ , file := range files {
97- t .Logf (" - %s" , file )
98- }
99- } else {
100- t .Logf ("Cache directory exists but is empty" )
101- }
102- t .Errorf ("Cache directory %s should not exist when using --no-kubernetes" , cachePath )
103- } else if os .IsNotExist (err ) {
104- t .Logf ("No cache directory found (as expected)" )
105- } else {
106- t .Errorf ("Error checking cache directory %s: %v" , cachePath , err )
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" )
10799 }
108100}
109101
0 commit comments