From 5c24ee87b02af6b38ee45c471b4d3c34e3ed56e4 Mon Sep 17 00:00:00 2001 From: Henrique Santos Date: Wed, 22 Nov 2023 11:09:11 +0000 Subject: [PATCH] Improve test comparison --- internal/cmd/postgresql/instance/create/create_test.go | 10 +++++----- internal/cmd/postgresql/instance/update/update_test.go | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/internal/cmd/postgresql/instance/create/create_test.go b/internal/cmd/postgresql/instance/create/create_test.go index 0391b21d..a4634e98 100644 --- a/internal/cmd/postgresql/instance/create/create_test.go +++ b/internal/cmd/postgresql/instance/create/create_test.go @@ -26,12 +26,12 @@ type postgreSQLClientMocked struct { getOfferingsResp *postgresql.OfferingList } -func (c *postgreSQLClientMocked) CreateInstance(_ context.Context, _ string) postgresql.ApiCreateInstanceRequest { - return postgresql.ApiCreateInstanceRequest{} +func (c *postgreSQLClientMocked) CreateInstance(ctx context.Context, projectId string) postgresql.ApiCreateInstanceRequest { + return testClient.CreateInstance(ctx, projectId) } -func (c *postgreSQLClientMocked) UpdateInstance(_ context.Context, _, _ string) postgresql.ApiUpdateInstanceRequest { - return postgresql.ApiUpdateInstanceRequest{} +func (c *postgreSQLClientMocked) UpdateInstance(ctx context.Context, projectId, instanceId string) postgresql.ApiUpdateInstanceRequest { + return testClient.UpdateInstance(ctx, projectId, instanceId) } func (c *postgreSQLClientMocked) GetOfferingsExecute(_ context.Context, _ string) (*postgresql.OfferingList, error) { @@ -411,7 +411,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.IgnoreFields(postgresql.ApiCreateInstanceRequest{}, "apiService", "ctx", "projectId"), + cmpopts.EquateComparable(testCtx), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/postgresql/instance/update/update_test.go b/internal/cmd/postgresql/instance/update/update_test.go index cbd381d6..374cf111 100644 --- a/internal/cmd/postgresql/instance/update/update_test.go +++ b/internal/cmd/postgresql/instance/update/update_test.go @@ -26,12 +26,12 @@ type postgreSQLClientMocked struct { getOfferingsResp *postgresql.OfferingList } -func (c *postgreSQLClientMocked) CreateInstance(_ context.Context, _ string) postgresql.ApiCreateInstanceRequest { - return postgresql.ApiCreateInstanceRequest{} +func (c *postgreSQLClientMocked) CreateInstance(ctx context.Context, projectId string) postgresql.ApiCreateInstanceRequest { + return testClient.CreateInstance(ctx, projectId) } -func (c *postgreSQLClientMocked) UpdateInstance(_ context.Context, _, _ string) postgresql.ApiUpdateInstanceRequest { - return postgresql.ApiUpdateInstanceRequest{} +func (c *postgreSQLClientMocked) UpdateInstance(ctx context.Context, projectId, instanceId string) postgresql.ApiUpdateInstanceRequest { + return testClient.UpdateInstance(ctx, projectId, instanceId) } func (c *postgreSQLClientMocked) GetOfferingsExecute(_ context.Context, _ string) (*postgresql.OfferingList, error) { @@ -432,7 +432,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.IgnoreFields(postgresql.ApiUpdateInstanceRequest{}, "apiService", "ctx", "projectId", "instanceId"), + cmpopts.EquateComparable(testCtx), ) if diff != "" { t.Fatalf("Data does not match: %s", diff)