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" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"os"
"os/exec" "os/exec"
"path/filepath" "path/filepath"
"runtime" "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) 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) t.Logf("Checking cache directory: %s", cachePath)
if _, err := os.Stat(cachePath); err == nil { files, err := filepath.Glob(filepath.Join(cachePath, "*"))
// Directory exists - let's see what's in it for debugging if err != nil {
if files, err := filepath.Glob(filepath.Join(cachePath, "*")); err == nil && len(files) > 0 { t.Errorf("Error reading cache directory: %v", err)
t.Logf("Files found in cache directory:") return
for _, file := range files {
t.Logf(" - %s", file)
} }
} else {
t.Logf("Cache directory exists but is empty") if len(files) > 0 {
} t.Logf("Files found in cache directory: %v", files)
t.Errorf("Cache directory %s should not exist when using --no-kubernetes", cachePath) t.Errorf("Cache directory should not contain files when using --no-kubernetes")
} else if os.IsNotExist(err) {
t.Logf("No cache directory found (as expected)")
} else {
t.Errorf("Error checking cache directory %s: %v", cachePath, err)
} }
} }