Skip to content

Commit

Permalink
Removal of Unnecessary Operation
Browse files Browse the repository at this point in the history
  • Loading branch information
ralikio committed Oct 30, 2024
1 parent 1590e9e commit 3d1861a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
6 changes: 3 additions & 3 deletions cmd/broker/binding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,9 @@ func TestDeprovisioningWithExistingBindings(t *testing.T) {
response = suite.CallAPI(http.MethodDelete, fmt.Sprintf("oauth/v2/service_instances/%s/service_bindings/%s?plan_id=361c511f-f939-4621-b228-d0fb79a1fe15&service_id=47c9dcbf-ff30-448e-ab36-d3bad66ba281", iid, bindingID2), "")
assert.Equal(t, http.StatusGone, response.StatusCode)

// then expect bindings to be removed
suite.AssertBindingRemoval(iid, bindingID1)
suite.AssertBindingRemoval(iid, bindingID2)
// then expect bindings to exist in database
suite.AssertBindingExists(iid, bindingID1)
suite.AssertBindingExists(iid, bindingID2)
}

func TestRemoveBindingsFromSuspended(t *testing.T) {
Expand Down
6 changes: 6 additions & 0 deletions cmd/broker/broker_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,12 @@ func (s *BrokerSuiteTest) AssertBindingRemoval(iid string, bindingID string) {
assert.True(s.t, dberr.IsNotFound(err), "bindings should be removed")
}

func (s *BrokerSuiteTest) AssertBindingExists(iid string, bindingID string) {
binding, err := s.db.Bindings().Get(iid, bindingID)
assert.NoError(s.t, err)
assert.NotNil(s.t, binding)
}

func (s *BrokerSuiteTest) LastOperation(iid string) *internal.Operation {
op, _ := s.db.Operations().GetLastOperation(iid)
return op
Expand Down
4 changes: 0 additions & 4 deletions internal/broker/bind_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ func (b *UnbindEndpoint) Unbind(ctx context.Context, instanceID, bindingID strin
instance, err := b.instancesStorage.GetByID(instanceID)
switch {
case dberr.IsNotFound(err):
if err != nil {
b.log.Errorf("Unbind error during removal of db entity: %v", err)
return domain.UnbindSpec{}, apiresponses.NewFailureResponse(fmt.Errorf("failed to delete binding for binding %s and not existing instance %s: %v", bindingID, instanceID, err), http.StatusInternalServerError, fmt.Sprintf("failed to delete resources for binding %s and not existing instance %s: %v", bindingID, instanceID, err))
}
return domain.UnbindSpec{}, apiresponses.ErrInstanceDoesNotExist
case err != nil:
return domain.UnbindSpec{}, apiresponses.NewFailureResponse(fmt.Errorf("failed to get instance %s", instanceID), http.StatusInternalServerError, fmt.Sprintf("failed to get instance %s", instanceID))
Expand Down

0 comments on commit 3d1861a

Please sign in to comment.