test: Remove duplicate kubernetes versions in tests

Replace manual deduplication logic in aaa_download_only_test.go with
util.RemoveDuplicateStrings() function for better consistency and
maintainability.

Previously, when DefaultKubernetesVersion and NewestKubernetesVersion
had the same value (currently both v1.34.0), tests would run twice
for the same version. The manual check and slice manipulation has been
replaced with the existing utility function that handles deduplication
more robustly.

Fixes #21483

Signed-off-by: DeepDN <nemadedeepak1111@gmail.com>
pull/21571/head
DeepDN 2025-09-15 20:17:12 +05:30
parent 574f958887
commit 1bc33a8ff9
No known key found for this signature in database
GPG Key ID: 94CCFA7F13AEE44F
1 changed files with 3 additions and 7 deletions

View File

@ -39,6 +39,7 @@ import (
"k8s.io/minikube/pkg/minikube/constants" "k8s.io/minikube/pkg/minikube/constants"
"k8s.io/minikube/pkg/minikube/download" "k8s.io/minikube/pkg/minikube/download"
"k8s.io/minikube/pkg/minikube/localpath" "k8s.io/minikube/pkg/minikube/localpath"
"k8s.io/minikube/pkg/util"
) )
// TestDownloadOnly makes sure the --download-only parameter in minikube start caches the appropriate images and tarballs. // TestDownloadOnly makes sure the --download-only parameter in minikube start caches the appropriate images and tarballs.
@ -58,16 +59,11 @@ func TestDownloadOnly(t *testing.T) { // nolint:gocyclo
containerRuntime := ContainerRuntime() containerRuntime := ContainerRuntime()
versions := []string{ versions := util.RemoveDuplicateStrings([]string{
constants.OldestKubernetesVersion, constants.OldestKubernetesVersion,
constants.DefaultKubernetesVersion, constants.DefaultKubernetesVersion,
constants.NewestKubernetesVersion, constants.NewestKubernetesVersion,
} })
// Small optimization, don't run the exact same set of tests twice
if constants.DefaultKubernetesVersion == constants.NewestKubernetesVersion {
versions = versions[:len(versions)-1]
}
for _, v := range versions { for _, v := range versions {
t.Run(v, func(t *testing.T) { t.Run(v, func(t *testing.T) {