driftctl/pkg/resource/aws/aws_sns_topic_subscription_...

52 lines
1.4 KiB
Go
Raw Normal View History

package aws_test
import (
"testing"
2021-02-09 15:54:50 +00:00
"time"
2021-02-09 15:54:50 +00:00
"github.com/cloudskiff/driftctl/pkg/remote/aws/repository"
2021-03-31 14:33:25 +00:00
"github.com/cloudskiff/driftctl/test"
"github.com/cloudskiff/driftctl/test/acceptance"
2021-02-09 15:54:50 +00:00
"github.com/cloudskiff/driftctl/test/acceptance/awsutils"
"github.com/sirupsen/logrus"
)
func TestAcc_AwsSNSTopicSubscription(t *testing.T) {
acceptance.Run(t, acceptance.AccTestCase{
TerraformVersion: "0.14.9",
Paths: []string{"./testdata/acc/aws_sns_topic_subscription"},
Args: []string{"scan", "--filter", "Type=='aws_sns_topic_subscription'"},
Checks: []acceptance.AccCheck{
{
Env: map[string]string{
"AWS_REGION": "us-east-1",
},
2021-02-09 15:54:50 +00:00
PreExec: func() {
err := acceptance.RetryFor(60*time.Second, func(doneCh chan struct{}) error {
client := repository.NewSNSClient(awsutils.Session())
topics, err := client.ListAllSubscriptions()
if err != nil {
logrus.Warnf("Cannot list Subscriptions: %+v", err)
return err
}
if len(topics) == 2 {
doneCh <- struct{}{}
}
return nil
})
if err != nil {
t.Fatal("Timeout while fetching SNS Subscriptions")
}
},
2021-03-31 14:33:25 +00:00
Check: func(result *test.ScanResult, stdout string, err error) {
if err != nil {
t.Fatal(err)
}
result.AssertInfrastructureIsInSync()
result.AssertManagedCount(2)
},
},
},
})
}