Skip to content

Commit ee8d4b7

Browse files
committed
fix unit tests
1 parent e9f9df5 commit ee8d4b7

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

cmd/minikube/cmd/start_test.go

+10-6
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"testing"
2222

2323
"github.com/spf13/cobra"
24+
"github.com/spf13/viper"
2425
"k8s.io/minikube/pkg/minikube/constants"
2526
)
2627

@@ -49,11 +50,13 @@ func Test_extractVMDriverVersion(t *testing.T) {
4950
}
5051

5152
func TestGenerateCfgFromFlagsHTTPProxyHandling(t *testing.T) {
53+
viper.SetDefault(memory, constants.DefaultMemorySize)
54+
viper.SetDefault(humanReadableDiskSize, constants.DefaultDiskSize)
5255
originalEnv := os.Getenv("HTTP_PROXY")
5356
defer func() {
5457
err := os.Setenv("HTTP_PROXY", originalEnv)
5558
if err != nil {
56-
t.Fatalf("Error reverting env HTTP_PROXY to it's original value. Got err (%s)", err)
59+
t.Fatalf("Error reverting env HTTP_PROXY to it's original value. Got err: %s", err)
5760
}
5861
}()
5962
k8sVersion := constants.NewestKubernetesVersion
@@ -62,9 +65,7 @@ func TestGenerateCfgFromFlagsHTTPProxyHandling(t *testing.T) {
6265
proxy string
6366
proxyIgnored bool
6467
}{
65-
{
66-
description: "no http_proxy",
67-
},
68+
6869
{
6970
description: "http_proxy=127.0.0.1:3128",
7071
proxy: "127.0.0.1:3128",
@@ -79,14 +80,17 @@ func TestGenerateCfgFromFlagsHTTPProxyHandling(t *testing.T) {
7980
description: "http_proxy=1.2.3.4:3128",
8081
proxy: "1.2.3.4:3128",
8182
},
83+
{
84+
description: "no http_proxy",
85+
},
8286
}
8387
for _, test := range tests {
8488
t.Run(test.description, func(t *testing.T) {
85-
cmd := cobra.Command{}
89+
cmd := &cobra.Command{}
8690
if err := os.Setenv("HTTP_PROXY", test.proxy); err != nil {
8791
t.Fatalf("Unexpected error setting HTTP_PROXY: %v", err)
8892
}
89-
config, err := generateCfgFromFlags(&cmd, k8sVersion)
93+
config, err := generateCfgFromFlags(cmd, k8sVersion)
9094
if err != nil {
9195
t.Fatalf("Got unexpected error %v during config generation", err)
9296
}

0 commit comments

Comments
 (0)