Skip to content

Commit

Permalink
chore: Updates delete logic for mongodbatlas_search_deployment (#2389)
Browse files Browse the repository at this point in the history
* update delete logic

* update unit test
  • Loading branch information
lantoli authored Jul 4, 2024
1 parent 7de7e64 commit 2288b94
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"go.mongodb.org/atlas-sdk/v20240530002/admin"
)

const SearchDeploymentDoesNotExistsError = "ATLAS_FTS_DEPLOYMENT_DOES_NOT_EXIST"
const SearchDeploymentDoesNotExistsError = "ATLAS_SEARCH_DEPLOYMENT_DOES_NOT_EXIST"

func WaitSearchNodeStateTransition(ctx context.Context, projectID, clusterName string, client admin.AtlasSearchApi,
timeConfig retrystrategy.TimeConfig) (*admin.ApiSearchDeploymentResponse, error) {
Expand Down Expand Up @@ -56,7 +56,7 @@ func searchDeploymentRefreshFunc(ctx context.Context, projectID, clusterName str
return nil, "", err
}
if err != nil {
if resp.StatusCode == 400 && strings.Contains(err.Error(), SearchDeploymentDoesNotExistsError) {
if resp.StatusCode == 404 && strings.Contains(err.Error(), SearchDeploymentDoesNotExistsError) {
return "", retrystrategy.RetryStrategyDeletedState, nil
}
if resp.StatusCode == 503 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var (
updating = "UPDATING"
idle = "IDLE"
unknown = ""
sc400 = conversion.IntPtr(400)
sc404 = conversion.IntPtr(404)
sc500 = conversion.IntPtr(500)
sc503 = conversion.IntPtr(503)
)
Expand Down Expand Up @@ -94,7 +94,7 @@ func TestSearchDeploymentStateTransitionForDelete(t *testing.T) {
name: "Regular transition to DELETED",
mockResponses: []response{
{state: &updating},
{statusCode: sc400, err: errors.New(searchdeployment.SearchDeploymentDoesNotExistsError)},
{statusCode: sc404, err: errors.New(searchdeployment.SearchDeploymentDoesNotExistsError)},
},
expectedError: false,
},
Expand Down

0 comments on commit 2288b94

Please sign in to comment.