Skip to content

Commit

Permalink
Fix slow test (#4740)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
dgageot authored Aug 31, 2020
1 parent 31d035a commit 89306fd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/skaffold/config/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,9 @@ func GetDebugHelpersRegistry(configFile string) (string, error) {
func isDefaultLocal(kubeContext string) bool {
return kubeContext == constants.DefaultDockerForDesktopContext ||
kubeContext == constants.DefaultDockerDesktopContext ||
cluster.GetClient().IsMinikube(kubeContext) ||
IsKindCluster(kubeContext) ||
IsK3dCluster(kubeContext)
IsK3dCluster(kubeContext) ||
cluster.GetClient().IsMinikube(kubeContext)
}

// IsImageLoadingRequired checks if the cluster requires loading images into it
Expand Down
9 changes: 9 additions & 0 deletions pkg/skaffold/config/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ package config

import (
"fmt"
"os/exec"
"path/filepath"
"strings"
"testing"
"time"

"github.com/GoogleContainerTools/skaffold/pkg/skaffold/cluster"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/util"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/yaml"
"github.com/GoogleContainerTools/skaffold/testutil"
Expand Down Expand Up @@ -281,13 +283,20 @@ func TestIsDefaultLocal(t *testing.T) {
}
for _, test := range tests {
testutil.Run(t, "", func(t *testutil.T) {
t.Override(&cluster.GetClient, func() cluster.Client { return fakeClient{} })

local := isDefaultLocal(test.context)

t.CheckDeepEqual(test.expectedLocal, local)
})
}
}

type fakeClient struct{}

func (fakeClient) IsMinikube(kubeContext string) bool { return kubeContext == "minikube" }
func (fakeClient) MinikubeExec(...string) (*exec.Cmd, error) { return nil, nil }

func TestIsImageLoadingRequired(t *testing.T) {
tests := []struct {
context string
Expand Down

0 comments on commit 89306fd

Please sign in to comment.