Skip to content

Commit

Permalink
chore: Removes usage of old Admin SDK in tests (#2442)
Browse files Browse the repository at this point in the history
* remove matlas from alert_configuration test

* remove matlas from custom_db_role test
  • Loading branch information
oarbusi authored Jul 19, 2024
1 parent 3de3793 commit 5578f16
Show file tree
Hide file tree
Showing 2 changed files with 121 additions and 126 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/hashicorp/terraform-plugin-testing/terraform"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/acc"
matlas "go.mongodb.org/atlas/mongodbatlas"
)

func TestAccConfigDSAlertConfigurations_basic(t *testing.T) {
Expand Down Expand Up @@ -141,11 +140,7 @@ func checkCount(resourceName string) resource.TestCheckFunc {
ids := conversion.DecodeStateID(rs.Primary.ID)
projectID := ids["project_id"]

alertResp, _, err := acc.Conn().AlertConfigurations.List(context.Background(), projectID, &matlas.ListOptions{
PageNum: 0,
ItemsPerPage: 100,
IncludeCount: true,
})
alertResp, _, err := acc.ConnV2().AlertConfigurationsApi.ListAlertConfigurations(context.Background(), projectID).Execute()

if err != nil {
return fmt.Errorf("the Alert Configurations List for project (%s) could not be read", projectID)
Expand All @@ -157,8 +152,8 @@ func checkCount(resourceName string) resource.TestCheckFunc {
return fmt.Errorf("%s results count is somehow not a number %s", resourceName, resultsCountAttr)
}

if resultsCount != len(alertResp) {
return fmt.Errorf("%s results count (%d) did not match that of current Alert Configurations (%d)", resourceName, resultsCount, len(alertResp))
if resultsCount != len(alertResp.GetResults()) {
return fmt.Errorf("%s results count (%d) did not match that of current Alert Configurations (%d)", resourceName, resultsCount, len(alertResp.GetResults()))
}

if totalCountAttr := rs.Primary.Attributes["total_count"]; totalCountAttr != "" {
Expand Down
Loading

0 comments on commit 5578f16

Please sign in to comment.