Skip to content

Commit ce3f07c

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

5 files changed

+5324
-8270
lines changed

internal/services/mongodb/instance_test.go

+1-2
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

+7-12
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,20 +113,16 @@ 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 {
124-
return err
121+
if err == nil {
122+
return fmt.Errorf("instance (%s) still exists", rs.Primary.ID)
125123
}
126-
127-
for _, snapshot := range listSnapshots.Snapshots {
128-
if snapshot.ID == ID {
129-
return fmt.Errorf("snapshot (%s) still exists", rs.Primary.ID)
130-
}
124+
if !httperrors.Is404(err) {
125+
return err
131126
}
132127
}
133128
return nil

0 commit comments

Comments
 (0)