Skip to content

Commit cbbd221

Browse files
committed
feat(mongodb): add getsnapshot in test
1 parent c00be25 commit cbbd221

File tree

5 files changed

+5324
-8269
lines changed

5 files changed

+5324
-8269
lines changed

internal/services/mongodb/instance_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,11 +235,10 @@ func IsInstanceDestroyed(tt *acctest.TestTools) resource.TestCheckFunc {
235235
if err != nil {
236236
return err
237237
}
238-
instance, err := mongodbAPI.GetInstance(&mongodbSDK.GetInstanceRequest{
238+
_, err = mongodbAPI.GetInstance(&mongodbSDK.GetInstanceRequest{
239239
InstanceID: ID,
240240
Region: extractRegion,
241241
})
242-
_ = instance
243242

244243
if err == nil {
245244
return fmt.Errorf("instance (%s) still exists", rs.Primary.ID)

internal/services/mongodb/snapshot_test.go

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ import (
88
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
99
mongodbSDK "github.com/scaleway/scaleway-sdk-go/api/mongodb/v1alpha1"
1010
"github.com/scaleway/terraform-provider-scaleway/v2/internal/acctest"
11-
"github.com/scaleway/terraform-provider-scaleway/v2/internal/locality/regional"
12-
"github.com/scaleway/terraform-provider-scaleway/v2/internal/locality/zonal"
11+
"github.com/scaleway/terraform-provider-scaleway/v2/internal/httperrors"
1312
"github.com/scaleway/terraform-provider-scaleway/v2/internal/services/mongodb"
1413
)
1514

@@ -114,21 +113,18 @@ func isSnapshotDestroyed(tt *acctest.TestTools) resource.TestCheckFunc {
114113
if err != nil {
115114
return err
116115
}
117-
instanceID := zonal.ExpandID(regional.ExpandID(rs.Primary.Attributes["instance_id"]).String())
118116

119-
listSnapshots, err := mongodbAPI.ListSnapshots(&mongodbSDK.ListSnapshotsRequest{
120-
InstanceID: &instanceID.ID,
117+
_, err = mongodbAPI.GetSnapshot(&mongodbSDK.GetSnapshotRequest{
118+
SnapshotID: ID,
121119
Region: region,
122120
})
123-
if err != nil {
121+
if err == nil {
122+
return fmt.Errorf("instance (%s) still exists", rs.Primary.ID)
123+
}
124+
if !httperrors.Is404(err) {
124125
return err
125126
}
126127

127-
for _, snapshot := range listSnapshots.Snapshots {
128-
if snapshot.ID == ID {
129-
return fmt.Errorf("snapshot (%s) still exists", rs.Primary.ID)
130-
}
131-
}
132128
}
133129
return nil
134130
}

0 commit comments

Comments
 (0)