driftctl/pkg/resource/aws/aws_sqs_queue_policy_test.go

51 lines
1.3 KiB
Go
Raw Normal View History

2021-01-29 11:35:11 +00:00
package aws_test
import (
"testing"
"time"
"github.com/aws/aws-sdk-go/service/sqs"
2021-03-31 14:33:25 +00:00
"github.com/cloudskiff/driftctl/test"
"github.com/cloudskiff/driftctl/test/acceptance/awsutils"
"github.com/sirupsen/logrus"
2021-01-29 11:35:11 +00:00
"github.com/cloudskiff/driftctl/test/acceptance"
)
func TestAcc_AwsSqsQueuePolicy(t *testing.T) {
acceptance.Run(t, acceptance.AccTestCase{
2021-02-23 12:44:48 +00:00
Paths: []string{"./testdata/acc/aws_sqs_queue_policy"},
Args: []string{"scan", "--filter", "Type=='aws_sqs_queue_policy'"},
2021-01-29 11:35:11 +00:00
Checks: []acceptance.AccCheck{
{
Env: map[string]string{
"AWS_REGION": "us-east-1",
},
PreExec: func() {
err := acceptance.RetryFor(60*time.Second, func(doneCh chan struct{}) error {
return sqs.New(awsutils.Session()).ListQueuesPages(&sqs.ListQueuesInput{},
func(resp *sqs.ListQueuesOutput, lastPage bool) bool {
logrus.Debugf("Retrieved %d SQS queues", len(resp.QueueUrls))
if len(resp.QueueUrls) == 3 {
doneCh <- struct{}{}
}
return !lastPage
},
)
})
if err != nil {
t.Fatal("Timeout while fetching SQS queues")
}
},
2021-03-31 14:33:25 +00:00
Check: func(result *test.ScanResult, stdout string, err error) {
2021-01-29 11:35:11 +00:00
if err != nil {
t.Fatal(err)
}
result.AssertInfrastructureIsInSync()
result.Equal(2, result.Summary().TotalManaged)
},
},
},
})
}