Update tests
parent
e09a1221bb
commit
8f3ef2d69e
|
|
@ -202,14 +202,14 @@ func Suggest(options []registry.DriverState) (registry.DriverState, []registry.D
|
||||||
for _, ds := range options {
|
for _, ds := range options {
|
||||||
if ds != pick {
|
if ds != pick {
|
||||||
glog.Errorf("%s: %s", ds.Name, ds.Rejection)
|
glog.Errorf("%s: %s", ds.Name, ds.Rejection)
|
||||||
if !ds.State.Healthy {
|
if !ds.State.Installed {
|
||||||
ds.Rejection = fmt.Sprintf("Not healthy: %v", ds.State.Error)
|
ds.Rejection = fmt.Sprintf("Not installed: %v", ds.State.Error)
|
||||||
rejects = append(rejects, ds)
|
rejects = append(rejects, ds)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if !ds.State.Installed {
|
if !ds.State.Healthy {
|
||||||
ds.Rejection = fmt.Sprintf("Not installed: %v", ds.State.Error)
|
ds.Rejection = fmt.Sprintf("Not healthy: %v", ds.State.Error)
|
||||||
rejects = append(rejects, ds)
|
rejects = append(rejects, ds)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -112,6 +112,7 @@ func TestSuggest(t *testing.T) {
|
||||||
choices []string
|
choices []string
|
||||||
pick string
|
pick string
|
||||||
alts []string
|
alts []string
|
||||||
|
rejects []string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
def: registry.DriverDef{
|
def: registry.DriverDef{
|
||||||
|
|
@ -122,6 +123,7 @@ func TestSuggest(t *testing.T) {
|
||||||
choices: []string{"unhealthy"},
|
choices: []string{"unhealthy"},
|
||||||
pick: "",
|
pick: "",
|
||||||
alts: []string{},
|
alts: []string{},
|
||||||
|
rejects: []string{"unhealthy"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
def: registry.DriverDef{
|
def: registry.DriverDef{
|
||||||
|
|
@ -132,6 +134,7 @@ func TestSuggest(t *testing.T) {
|
||||||
choices: []string{"discouraged", "unhealthy"},
|
choices: []string{"discouraged", "unhealthy"},
|
||||||
pick: "",
|
pick: "",
|
||||||
alts: []string{"discouraged"},
|
alts: []string{"discouraged"},
|
||||||
|
rejects: []string{"unhealthy"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
def: registry.DriverDef{
|
def: registry.DriverDef{
|
||||||
|
|
@ -142,6 +145,7 @@ func TestSuggest(t *testing.T) {
|
||||||
choices: []string{"default", "discouraged", "unhealthy"},
|
choices: []string{"default", "discouraged", "unhealthy"},
|
||||||
pick: "default",
|
pick: "default",
|
||||||
alts: []string{"discouraged"},
|
alts: []string{"discouraged"},
|
||||||
|
rejects: []string{"unhealthy"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
def: registry.DriverDef{
|
def: registry.DriverDef{
|
||||||
|
|
@ -152,6 +156,7 @@ func TestSuggest(t *testing.T) {
|
||||||
choices: []string{"preferred", "default", "discouraged", "unhealthy"},
|
choices: []string{"preferred", "default", "discouraged", "unhealthy"},
|
||||||
pick: "preferred",
|
pick: "preferred",
|
||||||
alts: []string{"default", "discouraged"},
|
alts: []string{"default", "discouraged"},
|
||||||
|
rejects: []string{"unhealthy"},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, tc := range tests {
|
for _, tc := range tests {
|
||||||
|
|
@ -172,7 +177,7 @@ func TestSuggest(t *testing.T) {
|
||||||
t.Errorf("choices mismatch (-want +got):\n%s", diff)
|
t.Errorf("choices mismatch (-want +got):\n%s", diff)
|
||||||
}
|
}
|
||||||
|
|
||||||
pick, alts := Suggest(got)
|
pick, alts, rejects := Suggest(got)
|
||||||
if pick.Name != tc.pick {
|
if pick.Name != tc.pick {
|
||||||
t.Errorf("pick = %q, expected %q", 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 != "" {
|
if diff := cmp.Diff(gotAlts, tc.alts); diff != "" {
|
||||||
t.Errorf("alts mismatch (-want +got):\n%s", 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)
|
||||||
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue