Updated test to not fail when directory is present

pull/21139/head
Divy Singhvi 2025-11-09 18:40:19 +05:30
parent 9d0cf672d7
commit c4345f2baa
1 changed files with 9 additions and 17 deletions

View File

@ -22,7 +22,6 @@ import (
"context"
"encoding/json"
"fmt"
"os"
"os/exec"
"path/filepath"
"runtime"
@ -87,23 +86,16 @@ func VerifyNoK8sDownloadCache(ctx context.Context, t *testing.T, profile string)
cachePath := filepath.Join(localpath.MiniPath(), "cache", runtime.GOOS, runtime.GOARCH, constants.NoKubernetesVersion)
// Check if the cache directory exists at all
t.Logf("Checking cache directory: %s", cachePath)
if _, err := os.Stat(cachePath); err == nil {
// Directory exists - let's see what's in it for debugging
if files, err := filepath.Glob(filepath.Join(cachePath, "*")); err == nil && len(files) > 0 {
t.Logf("Files found in cache directory:")
for _, file := range files {
t.Logf(" - %s", file)
}
} else {
t.Logf("Cache directory exists but is empty")
}
t.Errorf("Cache directory %s should not exist when using --no-kubernetes", cachePath)
} else if os.IsNotExist(err) {
t.Logf("No cache directory found (as expected)")
} else {
t.Errorf("Error checking cache directory %s: %v", cachePath, err)
files, err := filepath.Glob(filepath.Join(cachePath, "*"))
if err != nil {
t.Errorf("Error reading cache directory: %v", err)
return
}
if len(files) > 0 {
t.Logf("Files found in cache directory: %v", files)
t.Errorf("Cache directory should not contain files when using --no-kubernetes")
}
}