Skip to content

Commit

Permalink
add some error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
1riatsila1 committed Oct 24, 2024
1 parent e1c71a6 commit 6b93d32
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,15 @@ func (r *serviceTestGroupAssignmentResource) Delete(ctx context.Context, req res
return
}

r.client.ConfigurationAPI.
DeleteServiceTestGroupAssignmentUxiV1alpha1ServiceTestGroupAssignmentsIdDelete(ctx, state.ID.ValueString()).
Execute()
request := r.client.ConfigurationAPI.DeleteServiceTestGroupAssignmentUxiV1alpha1ServiceTestGroupAssignmentsIdDelete(ctx, state.ID.ValueString())

_, response, err := util.RetryFor429(request.Execute)
errorPresent, errorDetail := util.RaiseForStatus(response, err)

if errorPresent {
resp.Diagnostics.AddError(util.GenerateErrorSummary("delete", "uxi_service_test_group_assignment"), errorDetail)
return
}

Check warning on line 172 in pkg/config-api-provider/provider/resources/service_group_assignment.go

View check run for this annotation

Codecov / codecov/patch

pkg/config-api-provider/provider/resources/service_group_assignment.go#L170-L172

Added lines #L170 - L172 were not covered by tests
}

func (r *serviceTestGroupAssignmentResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ func TestServiceTestGroupAssignmentResource(t *testing.T) {
3,
)

// required for deleting existing group
util.MockDeleteServiceTestGroupAssignment("service_test_group_assignment", 1)

// required for creating another group
util.MockPostGroup(util.StructToMap(util.GenerateGroupResponseModel("group_uid_2", "_2", "_2")), 1)

Expand Down Expand Up @@ -176,8 +179,7 @@ func TestServiceTestGroupAssignmentResource(t *testing.T) {

util.MockDeleteGroup("group_uid", 1)
util.MockDeleteGroup("group_uid_2", 1)
util.MockDeleteServiceTestGroupAssignment("service_test_group_assignment", 1)
util.MockDeleteServiceTestGroupAssignment("service_test_group_assignment_2", 1)
util.MockDeleteServiceTestGroupAssignment("service_test_group_assignment_uid_2", 1)
},
Config: provider.ProviderConfig + `
removed {
Expand Down Expand Up @@ -279,6 +281,7 @@ func TestServiceTestGroupAssignmentResource429Handling(t *testing.T) {
)

util.MockDeleteGroup("group_uid", 1)
util.MockDeleteServiceTestGroupAssignment("service_test_group_assignment", 1)
},
Config: provider.ProviderConfig + `
removed {
Expand Down

0 comments on commit 6b93d32

Please sign in to comment.