Return specific type (#4840)
This commit is contained in:
parent
0976d3307f
commit
facf841992
2 changed files with 3 additions and 7 deletions
|
@ -1009,7 +1009,7 @@ type errorLocation struct {
|
||||||
// of errorLocations, each of which contain the upstream name and a list of
|
// of errorLocations, each of which contain the upstream name and a list of
|
||||||
// error codes for that given upstream, so that sufficiently unique
|
// error codes for that given upstream, so that sufficiently unique
|
||||||
// @custom error location blocks can be created in the template
|
// @custom error location blocks can be created in the template
|
||||||
func buildCustomErrorLocationsPerServer(input interface{}) interface{} {
|
func buildCustomErrorLocationsPerServer(input interface{}) []errorLocation {
|
||||||
server, ok := input.(*ingress.Server)
|
server, ok := input.(*ingress.Server)
|
||||||
if !ok {
|
if !ok {
|
||||||
klog.Errorf("expected a '*ingress.Server' type but %T was returned", input)
|
klog.Errorf("expected a '*ingress.Server' type but %T was returned", input)
|
||||||
|
|
|
@ -1108,12 +1108,8 @@ func TestBuildCustomErrorLocationsPerServer(t *testing.T) {
|
||||||
|
|
||||||
for _, c := range testCases {
|
for _, c := range testCases {
|
||||||
response := buildCustomErrorLocationsPerServer(c.server)
|
response := buildCustomErrorLocationsPerServer(c.server)
|
||||||
if results, ok := response.([]errorLocation); ok {
|
if !reflect.DeepEqual(c.expectedResults, response) {
|
||||||
if !reflect.DeepEqual(c.expectedResults, results) {
|
t.Errorf("Expected %+v but got %+v", c.expectedResults, response)
|
||||||
t.Errorf("Expected %+v but got %+v", c.expectedResults, results)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
t.Error("Unable to convert to []errorLocation")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue