Skip to content

Commit 5578f16

Browse files
authored
chore: Removes usage of old Admin SDK in tests (#2442)
* remove matlas from alert_configuration test * remove matlas from custom_db_role test
1 parent 3de3793 commit 5578f16

File tree

2 files changed

+121
-126
lines changed

2 files changed

+121
-126
lines changed

internal/service/alertconfiguration/data_source_alert_configurations_test.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
"github.com/hashicorp/terraform-plugin-testing/terraform"
1313
"github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion"
1414
"github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/acc"
15-
matlas "go.mongodb.org/atlas/mongodbatlas"
1615
)
1716

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

144-
alertResp, _, err := acc.Conn().AlertConfigurations.List(context.Background(), projectID, &matlas.ListOptions{
145-
PageNum: 0,
146-
ItemsPerPage: 100,
147-
IncludeCount: true,
148-
})
143+
alertResp, _, err := acc.ConnV2().AlertConfigurationsApi.ListAlertConfigurations(context.Background(), projectID).Execute()
149144

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

160-
if resultsCount != len(alertResp) {
161-
return fmt.Errorf("%s results count (%d) did not match that of current Alert Configurations (%d)", resourceName, resultsCount, len(alertResp))
155+
if resultsCount != len(alertResp.GetResults()) {
156+
return fmt.Errorf("%s results count (%d) did not match that of current Alert Configurations (%d)", resourceName, resultsCount, len(alertResp.GetResults()))
162157
}
163158

164159
if totalCountAttr := rs.Primary.Attributes["total_count"]; totalCountAttr != "" {

0 commit comments

Comments
 (0)