From 2288b94e681bca3ac03c546b6db9fa7dc372ccc0 Mon Sep 17 00:00:00 2001 From: Leo Antoli <430982+lantoli@users.noreply.github.com> Date: Thu, 4 Jul 2024 15:31:03 +0200 Subject: [PATCH] chore: Updates delete logic for `mongodbatlas_search_deployment` (#2389) * update delete logic * update unit test --- .../searchdeployment/state_transition_search_deployment.go | 4 ++-- .../state_transition_search_deployment_test.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/service/searchdeployment/state_transition_search_deployment.go b/internal/service/searchdeployment/state_transition_search_deployment.go index ff0ea37ab1..3ba981c451 100644 --- a/internal/service/searchdeployment/state_transition_search_deployment.go +++ b/internal/service/searchdeployment/state_transition_search_deployment.go @@ -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) { @@ -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 { diff --git a/internal/service/searchdeployment/state_transition_search_deployment_test.go b/internal/service/searchdeployment/state_transition_search_deployment_test.go index ea9b197a50..21511e0d95 100644 --- a/internal/service/searchdeployment/state_transition_search_deployment_test.go +++ b/internal/service/searchdeployment/state_transition_search_deployment_test.go @@ -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) ) @@ -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, },