Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fake k8s context for test #1788

Merged
merged 1 commit into from
Mar 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pkg/skaffold/build/cache/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"github.com/GoogleContainerTools/skaffold/testutil"
"github.com/docker/docker/api/types"
yaml "gopkg.in/yaml.v2"
"k8s.io/client-go/tools/clientcmd/api"
)

var (
Expand Down Expand Up @@ -122,6 +123,8 @@ func Test_NewCache(t *testing.T) {

for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
restore := testutil.SetupFakeKubernetesContext(t, api.Config{CurrentContext: "cluster1"})
defer restore()

cacheFile := createTempCacheFile(t, test.cacheFileContents)
if test.updateCacheFile {
Expand Down
10 changes: 10 additions & 0 deletions pkg/skaffold/runner/dev_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/sync"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/watch"
"github.com/GoogleContainerTools/skaffold/testutil"
"k8s.io/client-go/tools/clientcmd/api"
)

type NoopWatcher struct{}
Expand Down Expand Up @@ -92,6 +93,9 @@ func discardOutput() *config.Output {
}

func TestDevFailFirstCycle(t *testing.T) {
restore := testutil.SetupFakeKubernetesContext(t, api.Config{CurrentContext: "cluster1"})
defer restore()

var tests = []struct {
description string
testBench *TestBench
Expand Down Expand Up @@ -148,6 +152,9 @@ func TestDevFailFirstCycle(t *testing.T) {
}

func TestDev(t *testing.T) {
restore := testutil.SetupFakeKubernetesContext(t, api.Config{CurrentContext: "cluster1"})
defer restore()

var tests = []struct {
description string
testBench *TestBench
Expand Down Expand Up @@ -280,6 +287,9 @@ func TestDev(t *testing.T) {
}

func TestDevSync(t *testing.T) {
restore := testutil.SetupFakeKubernetesContext(t, api.Config{CurrentContext: "cluster1"})
defer restore()

var tests = []struct {
description string
testBench *TestBench
Expand Down
3 changes: 3 additions & 0 deletions pkg/skaffold/runner/runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,9 @@ func TestNewForConfig(t *testing.T) {
}

func TestRun(t *testing.T) {
restore := testutil.SetupFakeKubernetesContext(t, api.Config{CurrentContext: "cluster1"})
defer restore()

var tests = []struct {
description string
testBench *TestBench
Expand Down