Skip to content

Commit

Permalink
Return specific type (#4840)
Browse files Browse the repository at this point in the history
  • Loading branch information
aledbf authored Dec 17, 2019
1 parent 0976d33 commit facf841
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
2 changes: 1 addition & 1 deletion internal/ingress/controller/template/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -1009,7 +1009,7 @@ type errorLocation struct {
// of errorLocations, each of which contain the upstream name and a list of
// error codes for that given upstream, so that sufficiently unique
// @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)
if !ok {
klog.Errorf("expected a '*ingress.Server' type but %T was returned", input)
Expand Down
8 changes: 2 additions & 6 deletions internal/ingress/controller/template/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1108,12 +1108,8 @@ func TestBuildCustomErrorLocationsPerServer(t *testing.T) {

for _, c := range testCases {
response := buildCustomErrorLocationsPerServer(c.server)
if results, ok := response.([]errorLocation); ok {
if !reflect.DeepEqual(c.expectedResults, results) {
t.Errorf("Expected %+v but got %+v", c.expectedResults, results)
}
} else {
t.Error("Unable to convert to []errorLocation")
if !reflect.DeepEqual(c.expectedResults, response) {
t.Errorf("Expected %+v but got %+v", c.expectedResults, response)
}
}
}
Expand Down

0 comments on commit facf841

Please sign in to comment.