Skip to content

Commit

Permalink
Merge pull request #16 from stackitcloud/hs/test-improve-comparisons
Browse files Browse the repository at this point in the history
Improve comparisons in tests
  • Loading branch information
hcsa73 authored Nov 22, 2023
2 parents 9506161 + 5c24ee8 commit edd81a7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 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
2 changes: 1 addition & 1 deletion internal/cmd/ske/cluster/create/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ func TestBuildRequest(t *testing.T) {

diff := cmp.Diff(request, tt.expectedRequest,
cmp.AllowUnexported(tt.expectedRequest),
cmpopts.IgnoreFields(ske.ApiCreateOrUpdateClusterRequest{}, "apiService", "ctx", "projectId"),
cmpopts.EquateComparable(testCtx),
)
if diff != "" {
t.Fatalf("Data does not match: %s", diff)
Expand Down

0 comments on commit edd81a7

Please sign in to comment.