From 8f3ef2d69e8da26a9df806af50c4bdf9ad2d30b1 Mon Sep 17 00:00:00 2001 From: Thomas Stromberg Date: Thu, 2 Apr 2020 06:28:21 -0700 Subject: [PATCH] Update tests --- pkg/minikube/driver/driver.go | 8 ++++---- pkg/minikube/driver/driver_test.go | 16 +++++++++++++++- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/pkg/minikube/driver/driver.go b/pkg/minikube/driver/driver.go index bc2ca06c0a..7f67a76fe7 100644 --- a/pkg/minikube/driver/driver.go +++ b/pkg/minikube/driver/driver.go @@ -202,14 +202,14 @@ func Suggest(options []registry.DriverState) (registry.DriverState, []registry.D for _, ds := range options { if ds != pick { glog.Errorf("%s: %s", ds.Name, ds.Rejection) - if !ds.State.Healthy { - ds.Rejection = fmt.Sprintf("Not healthy: %v", ds.State.Error) + if !ds.State.Installed { + ds.Rejection = fmt.Sprintf("Not installed: %v", ds.State.Error) rejects = append(rejects, ds) continue } - if !ds.State.Installed { - ds.Rejection = fmt.Sprintf("Not installed: %v", ds.State.Error) + if !ds.State.Healthy { + ds.Rejection = fmt.Sprintf("Not healthy: %v", ds.State.Error) rejects = append(rejects, ds) continue } diff --git a/pkg/minikube/driver/driver_test.go b/pkg/minikube/driver/driver_test.go index 5d0bfd4009..b6afd6a62c 100644 --- a/pkg/minikube/driver/driver_test.go +++ b/pkg/minikube/driver/driver_test.go @@ -112,6 +112,7 @@ func TestSuggest(t *testing.T) { choices []string pick string alts []string + rejects []string }{ { def: registry.DriverDef{ @@ -122,6 +123,7 @@ func TestSuggest(t *testing.T) { choices: []string{"unhealthy"}, pick: "", alts: []string{}, + rejects: []string{"unhealthy"}, }, { def: registry.DriverDef{ @@ -132,6 +134,7 @@ func TestSuggest(t *testing.T) { choices: []string{"discouraged", "unhealthy"}, pick: "", alts: []string{"discouraged"}, + rejects: []string{"unhealthy"}, }, { def: registry.DriverDef{ @@ -142,6 +145,7 @@ func TestSuggest(t *testing.T) { choices: []string{"default", "discouraged", "unhealthy"}, pick: "default", alts: []string{"discouraged"}, + rejects: []string{"unhealthy"}, }, { def: registry.DriverDef{ @@ -152,6 +156,7 @@ func TestSuggest(t *testing.T) { choices: []string{"preferred", "default", "discouraged", "unhealthy"}, pick: "preferred", alts: []string{"default", "discouraged"}, + rejects: []string{"unhealthy"}, }, } for _, tc := range tests { @@ -172,7 +177,7 @@ func TestSuggest(t *testing.T) { t.Errorf("choices mismatch (-want +got):\n%s", diff) } - pick, alts := Suggest(got) + pick, alts, rejects := Suggest(got) if pick.Name != tc.pick { t.Errorf("pick = %q, expected %q", pick.Name, tc.pick) } @@ -184,6 +189,15 @@ func TestSuggest(t *testing.T) { if diff := cmp.Diff(gotAlts, tc.alts); diff != "" { t.Errorf("alts mismatch (-want +got):\n%s", diff) } + + gotRejects := []string{} + for _, r := range rejects { + gotRejects = append(gotRejects, r.Name) + } + if diff := cmp.Diff(gotRejects, tc.rejects); diff != "" { + t.Errorf("rejects mismatch (-want +got):\n%s", diff) + } + }) } }