Skip to content

Commit 89306fd

Browse files
authored
Fix slow test (#4740)
* Fix slow test Signed-off-by: David Gageot <david@gageot.net> * Use k8s client as a last resort Signed-off-by: David Gageot <david@gageot.net>
1 parent 31d035a commit 89306fd

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

pkg/skaffold/config/util.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,9 @@ func GetDebugHelpersRegistry(configFile string) (string, error) {
219219
func isDefaultLocal(kubeContext string) bool {
220220
return kubeContext == constants.DefaultDockerForDesktopContext ||
221221
kubeContext == constants.DefaultDockerDesktopContext ||
222-
cluster.GetClient().IsMinikube(kubeContext) ||
223222
IsKindCluster(kubeContext) ||
224-
IsK3dCluster(kubeContext)
223+
IsK3dCluster(kubeContext) ||
224+
cluster.GetClient().IsMinikube(kubeContext)
225225
}
226226

227227
// IsImageLoadingRequired checks if the cluster requires loading images into it

pkg/skaffold/config/util_test.go

+9
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@ package config
1818

1919
import (
2020
"fmt"
21+
"os/exec"
2122
"path/filepath"
2223
"strings"
2324
"testing"
2425
"time"
2526

27+
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/cluster"
2628
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/util"
2729
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/yaml"
2830
"github.com/GoogleContainerTools/skaffold/testutil"
@@ -281,13 +283,20 @@ func TestIsDefaultLocal(t *testing.T) {
281283
}
282284
for _, test := range tests {
283285
testutil.Run(t, "", func(t *testutil.T) {
286+
t.Override(&cluster.GetClient, func() cluster.Client { return fakeClient{} })
287+
284288
local := isDefaultLocal(test.context)
285289

286290
t.CheckDeepEqual(test.expectedLocal, local)
287291
})
288292
}
289293
}
290294

295+
type fakeClient struct{}
296+
297+
func (fakeClient) IsMinikube(kubeContext string) bool { return kubeContext == "minikube" }
298+
func (fakeClient) MinikubeExec(...string) (*exec.Cmd, error) { return nil, nil }
299+
291300
func TestIsImageLoadingRequired(t *testing.T) {
292301
tests := []struct {
293302
context string

0 commit comments

Comments
 (0)