Skip to content

Commit

Permalink
better error messages for failed tests
Browse files Browse the repository at this point in the history
Signed-off-by: Navendu Pottekkat <[email protected]>
  • Loading branch information
pottekkat committed Jan 7, 2024
1 parent 0504226 commit 87c933a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pkg/i2gw/providers/apisix/apisix.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (p *Provider) ReadResourcesFromCluster(ctx context.Context) error {
}

func (p *Provider) ReadResourcesFromFile(ctx context.Context, filename string) error {
storage, err := p.resourceReader.readResourcesFromFile(ctx, filename)
storage, err := p.resourceReader.readResourcesFromFile(filename)
if err != nil {
return fmt.Errorf("failed to read resources from file: %w", err)
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/i2gw/providers/apisix/http_to_https_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
gatewayv1 "sigs.k8s.io/gateway-api/apis/v1"
)

func Test_httpToHttps(t *testing.T) {
func Test_httpToHttpsFeature(t *testing.T) {
testCases := []struct {
name string
ingress networkingv1.Ingress
Expand Down Expand Up @@ -269,18 +269,18 @@ func Test_httpToHttps(t *testing.T) {
errs := httpToHttpsFeature(ingressResources, gatewayResources)

if len(errs) != len(tc.expectedError) {
t.Fatalf("expected %d errors, got %d", len(tc.expectedError), len(errs))
t.Errorf("expected %d errors, got %d", len(tc.expectedError), len(errs))
}

key := types.NamespacedName{Namespace: tc.ingress.Namespace, Name: common.RouteName(tc.ingress.Name, tc.ingress.Spec.Rules[0].Host)}

actualHTTPRoute, ok := gatewayResources.HTTPRoutes[key]
if !ok {
t.Fatalf("HTTPRoute not found: %v", key)
t.Errorf("HTTPRoute not found: %v", key)
}

if diff := cmp.Diff(*tc.expectedHTTPRoute, actualHTTPRoute); diff != "" {
t.Fatalf("mismatch (-want +got):\n%s", diff)
t.Errorf("Unexpected HTTPRoute resource found, \n want: %+v\n got: %+v\n diff (-want +got):\n%s", *tc.expectedHTTPRoute, actualHTTPRoute, diff)
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/i2gw/providers/apisix/resource_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (r *resourceReader) readResourcesFromCluster(ctx context.Context) (*storage
return storage, nil
}

func (r *resourceReader) readResourcesFromFile(_ context.Context, filename string) (*storage, error) {
func (r *resourceReader) readResourcesFromFile(filename string) (*storage, error) {
// read apisix related resources from file.
storage := newResourcesStorage()

Expand Down

0 comments on commit 87c933a

Please sign in to comment.