Skip to content

Commit

Permalink
Improve test comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
Henrique Santos committed Nov 22, 2023
1 parent 9a27441 commit 5c24ee8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions internal/cmd/postgresql/instance/create/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions internal/cmd/postgresql/instance/update/update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 5c24ee8

Please sign in to comment.