11package mnq_test
22
33import (
4+ "context"
45 "errors"
56 "fmt"
67 "strings"
78 "testing"
89
9- sns "github.com/aws/aws-sdk-go/service/sns"
10+ sns "github.com/aws/aws-sdk-go-v2 /service/sns"
1011 "github.com/hashicorp/aws-sdk-go-base/tfawserr"
1112 "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
1213 "github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
@@ -19,10 +20,12 @@ func TestAccSNSTopic_Basic(t *testing.T) {
1920 tt := acctest .NewTestTools (t )
2021 defer tt .Cleanup ()
2122
23+ ctx := context .Background ()
24+
2225 resource .ParallelTest (t , resource.TestCase {
2326 PreCheck : func () { acctest .PreCheck (t ) },
2427 ProviderFactories : tt .ProviderFactories ,
25- CheckDestroy : isSNSTopicDestroyed (tt ),
28+ CheckDestroy : isSNSTopicDestroyed (ctx , tt ),
2629 Steps : []resource.TestStep {
2730 {
2831 Config : `
@@ -49,7 +52,7 @@ func TestAccSNSTopic_Basic(t *testing.T) {
4952 }
5053 ` ,
5154 Check : resource .ComposeTestCheckFunc (
52- isSNSTopicPresent (tt , "scaleway_mnq_sns_topic.main" ),
55+ isSNSTopicPresent (ctx , tt , "scaleway_mnq_sns_topic.main" ),
5356 acctest .CheckResourceAttrUUID ("scaleway_mnq_sns_topic.main" , "id" ),
5457 resource .TestCheckResourceAttr ("scaleway_mnq_sns_topic.main" , "name" , "test-mnq-sns-topic-basic" ),
5558 ),
@@ -81,7 +84,7 @@ func TestAccSNSTopic_Basic(t *testing.T) {
8184 }
8285 ` ,
8386 Check : resource .ComposeTestCheckFunc (
84- isSNSTopicPresent (tt , "scaleway_mnq_sns_topic.main" ),
87+ isSNSTopicPresent (ctx , tt , "scaleway_mnq_sns_topic.main" ),
8588 acctest .CheckResourceAttrUUID ("scaleway_mnq_sns_topic.main" , "id" ),
8689 resource .TestCheckResourceAttr ("scaleway_mnq_sns_topic.main" , "name" , "test-mnq-sns-topic-basic.fifo" ),
8790 resource .TestCheckResourceAttr ("scaleway_mnq_sns_topic.main" , "content_based_deduplication" , "true" ),
@@ -114,7 +117,7 @@ func TestAccSNSTopic_Basic(t *testing.T) {
114117 }
115118 ` ,
116119 Check : resource .ComposeTestCheckFunc (
117- isSNSTopicPresent (tt , "scaleway_mnq_sns_topic.main" ),
120+ isSNSTopicPresent (ctx , tt , "scaleway_mnq_sns_topic.main" ),
118121 acctest .CheckResourceAttrUUID ("scaleway_mnq_sns_topic.main" , "id" ),
119122 func (state * terraform.State ) error {
120123 topic , exists := state .RootModule ().Resources ["scaleway_mnq_sns_topic.main" ]
@@ -139,7 +142,7 @@ func TestAccSNSTopic_Basic(t *testing.T) {
139142 })
140143}
141144
142- func isSNSTopicPresent (tt * acctest.TestTools , n string ) resource.TestCheckFunc {
145+ func isSNSTopicPresent (ctx context. Context , tt * acctest.TestTools , n string ) resource.TestCheckFunc {
143146 return func (state * terraform.State ) error {
144147 rs , ok := state .RootModule ().Resources [n ]
145148 if ! ok {
@@ -156,7 +159,7 @@ func isSNSTopicPresent(tt *acctest.TestTools, n string) resource.TestCheckFunc {
156159 return err
157160 }
158161
159- _ , err = snsClient .GetTopicAttributes (& sns.GetTopicAttributesInput {
162+ _ , err = snsClient .GetTopicAttributes (ctx , & sns.GetTopicAttributesInput {
160163 TopicArn : scw .StringPtr (mnq .ComposeSNSARN (region , projectID , topicName )),
161164 })
162165 if err != nil {
@@ -167,7 +170,7 @@ func isSNSTopicPresent(tt *acctest.TestTools, n string) resource.TestCheckFunc {
167170 }
168171}
169172
170- func isSNSTopicDestroyed (tt * acctest.TestTools ) resource.TestCheckFunc {
173+ func isSNSTopicDestroyed (ctx context. Context , tt * acctest.TestTools ) resource.TestCheckFunc {
171174 return func (state * terraform.State ) error {
172175 for _ , rs := range state .RootModule ().Resources {
173176 if rs .Type != "scaleway_mnq_sns_topic" {
@@ -184,7 +187,7 @@ func isSNSTopicDestroyed(tt *acctest.TestTools) resource.TestCheckFunc {
184187 return err
185188 }
186189
187- _ , err = snsClient .GetTopicAttributes (& sns.GetTopicAttributesInput {
190+ _ , err = snsClient .GetTopicAttributes (ctx , & sns.GetTopicAttributesInput {
188191 TopicArn : scw .StringPtr (mnq .ComposeSNSARN (region , projectID , topicName )),
189192 })
190193 if err != nil {
0 commit comments