diff --git a/cli/internal/cmd/init_test.go b/cli/internal/cmd/init_test.go index c95a0c7f2d4..089bb9c42d1 100644 --- a/cli/internal/cmd/init_test.go +++ b/cli/internal/cmd/init_test.go @@ -58,6 +58,18 @@ func TestInitArgumentValidation(t *testing.T) { } func TestInitialize(t *testing.T) { + require := require.New(t) + + respKubeconfig := k8sclientapi.Config{ + Clusters: map[string]*k8sclientapi.Cluster{ + "cluster": { + Server: "https://192.0.2.1:6443", + }, + }, + } + respKubeconfigBytes, err := clientcmd.Write(respKubeconfig) + require.NoError(err) + gcpServiceAccKey := &gcpshared.ServiceAccountKey{ Type: "service_account", ProjectID: "project_id", @@ -71,7 +83,7 @@ func TestInitialize(t *testing.T) { ClientX509CertURL: "client_cert", } testInitResp := &initproto.InitSuccessResponse{ - Kubeconfig: []byte("kubeconfig"), + Kubeconfig: respKubeconfigBytes, OwnerId: []byte("ownerID"), ClusterId: []byte("clusterID"), } @@ -162,7 +174,7 @@ func TestInitialize(t *testing.T) { initServerAPI: &stubInitServer{res: []*initproto.InitResponse{{Kind: &initproto.InitResponse_InitSuccess{InitSuccess: testInitResp}}}}, configMutator: func(c *config.Config) { res, err := versions.NewValidK8sVersion(strings.TrimPrefix(string(versions.Default), "v"), true) - require.NoError(t, err) + require.NoError(err) c.KubernetesVersion = res }, }, @@ -172,7 +184,7 @@ func TestInitialize(t *testing.T) { initServerAPI: &stubInitServer{res: []*initproto.InitResponse{{Kind: &initproto.InitResponse_InitSuccess{InitSuccess: testInitResp}}}}, configMutator: func(c *config.Config) { v, err := semver.New(versions.SupportedK8sVersions()[0]) - require.NoError(t, err) + require.NoError(err) outdatedPatchVer := semver.NewFromInt(v.Major(), v.Minor(), v.Patch()-1, "").String() c.KubernetesVersion = versions.ValidK8sVersion(outdatedPatchVer) }, @@ -184,8 +196,6 @@ func TestInitialize(t *testing.T) { for name, tc := range testCases { t.Run(name, func(t *testing.T) { assert := assert.New(t) - require := require.New(t) - // Networking netDialer := testdialer.NewBufconnDialer() newDialer := func(atls.Validator) *dialer.Dialer {