Skip to content

Commit

Permalink
Merge pull request #1335 from snyk/chore/rename-acc-tests
Browse files Browse the repository at this point in the history
AWS acceptance tests
  • Loading branch information
wbeuil authored Feb 3, 2022
2 parents fc821fc + f801244 commit 66baef7
Show file tree
Hide file tree
Showing 25 changed files with 65 additions and 25 deletions.
2 changes: 1 addition & 1 deletion pkg/resource/aws/aws_dynamodb_table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/snyk/driftctl/test/acceptance"
)

func TestAcc_AwsDynamoDBTable(t *testing.T) {
func TestAcc_Aws_DynamoDBTable(t *testing.T) {
acceptance.Run(t, acceptance.AccTestCase{
TerraformVersion: "0.15.5",
Paths: []string{"./testdata/acc/aws_dynamodb_table"},
Expand Down
2 changes: 1 addition & 1 deletion pkg/resource/aws/aws_ecr_repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/snyk/driftctl/test/acceptance/awsutils"
)

func TestAcc_AwsECRRepository(t *testing.T) {
func TestAcc_Aws_ECRRepository(t *testing.T) {
var mutatedRepositoryID string
acceptance.Run(t, acceptance.AccTestCase{
TerraformVersion: "0.15.5",
Expand Down
11 changes: 11 additions & 0 deletions pkg/resource/aws/aws_eip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@ func TestAcc_Aws_Eip(t *testing.T) {
Env: map[string]string{
"AWS_REGION": "us-east-1",
},
// New resources are not visible immediately through AWS API after an apply operation
// (e.g. error attaching EC2 Internet Gateway)
// Logic below retries driftctl scan using a back-off strategy of retrying 'n' times
// and doubling the amount of time waited after each one.
ShouldRetry: func(result *test.ScanResult, retryDuration time.Duration, retryCount uint8) bool {
if result.IsSync() || retryDuration > 10*time.Minute {
return false
}
time.Sleep((2 * time.Duration(retryCount)) * time.Minute)
return true
},
Check: func(result *test.ScanResult, stdout string, err error) {
if err != nil {
t.Fatal(err)
Expand Down
5 changes: 4 additions & 1 deletion pkg/resource/aws/aws_iam_policy_attachment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@ import (
"github.com/snyk/driftctl/test/acceptance"
)

func TestAcc_AwsIamPolicyAttachment_WithGroupsUsers(t *testing.T) {
func TestAcc_Aws_IamPolicyAttachment_WithGroupsUsers(t *testing.T) {
acceptance.Run(t, acceptance.AccTestCase{
TerraformVersion: "0.15.5",
Paths: []string{"./testdata/acc/aws_iam_policy_attachment"},
Args: []string{"scan", "--deep"},
Checks: []acceptance.AccCheck{
{
Env: map[string]string{
"AWS_REGION": "us-east-1",
},
Check: func(result *test.ScanResult, stdout string, err error) {
if err != nil {
t.Fatal(err)
Expand Down
4 changes: 2 additions & 2 deletions pkg/resource/aws/aws_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/snyk/driftctl/test/acceptance/awsutils"
)

func TestAcc_AwsInstance(t *testing.T) {
func TestAcc_Aws_Instance(t *testing.T) {
acceptance.Run(t, acceptance.AccTestCase{
TerraformVersion: "0.15.5",
Paths: []string{"./testdata/acc/aws_instance_default"},
Expand All @@ -39,7 +39,7 @@ func TestAcc_AwsInstance(t *testing.T) {
})
}

func TestAcc_AwsInstance_WithBlockDevices(t *testing.T) {
func TestAcc_Aws_Instance_WithBlockDevices(t *testing.T) {
var mutatedInstanceId string
acceptance.Run(t, acceptance.AccTestCase{
TerraformVersion: "0.15.5",
Expand Down
13 changes: 12 additions & 1 deletion pkg/resource/aws/aws_internet_gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/snyk/driftctl/test/acceptance"
)

func TestAcc_AwsInternetGateway(t *testing.T) {
func TestAcc_Aws_InternetGateway(t *testing.T) {
acceptance.Run(t, acceptance.AccTestCase{
TerraformVersion: "0.15.5",
Paths: []string{"./testdata/acc/aws_internet_gateway"},
Expand All @@ -22,6 +22,17 @@ func TestAcc_AwsInternetGateway(t *testing.T) {
Env: map[string]string{
"AWS_REGION": "us-east-1",
},
// New resources are not visible immediately through AWS API after an apply operation
// (e.g. InvalidVpcID.NotFound)
// Logic below retries driftctl scan using a back-off strategy of retrying 'n' times
// and doubling the amount of time waited after each one.
ShouldRetry: func(result *test.ScanResult, retryDuration time.Duration, retryCount uint8) bool {
if result.IsSync() || retryDuration > 10*time.Minute {
return false
}
time.Sleep((2 * time.Duration(retryCount)) * time.Minute)
return true
},
Check: func(result *test.ScanResult, stdout string, err error) {
if err != nil {
t.Fatal(err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/resource/aws/aws_lambda_event_source_mapping_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
// aws lambda list-event-source-mappings to list all event source mappings
// aws lambda delete-event-source-mapping --uuid xxx to delete a specific event source mapping

func TestAcc_AwsLambdaEventSourceMapping(t *testing.T) {
func TestAcc_Aws_LambdaEventSourceMapping(t *testing.T) {
acceptance.Run(t, acceptance.AccTestCase{
TerraformVersion: "0.15.5",
Paths: []string{"./testdata/acc/aws_lambda_event_source_mapping"},
Expand Down
2 changes: 1 addition & 1 deletion pkg/resource/aws/aws_launch_configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/snyk/driftctl/test/acceptance"
)

func TestAcc_AwsLaunchConfiguration(t *testing.T) {
func TestAcc_Aws_LaunchConfiguration(t *testing.T) {
acceptance.Run(t, acceptance.AccTestCase{
TerraformVersion: "0.15.5",
Paths: []string{"./testdata/acc/aws_launch_configuration"},
Expand Down
2 changes: 1 addition & 1 deletion pkg/resource/aws/aws_launch_template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/snyk/driftctl/test/acceptance"
)

func TestAcc_AwsLaunchTemplate(t *testing.T) {
func TestAcc_Aws_LaunchTemplate(t *testing.T) {
acceptance.Run(t, acceptance.AccTestCase{
TerraformVersion: "0.15.5",
Paths: []string{"./testdata/acc/aws_launch_template"},
Expand Down
2 changes: 1 addition & 1 deletion pkg/resource/aws/aws_nat_gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/snyk/driftctl/test/acceptance"
)

func TestAcc_AwsNATGateway(t *testing.T) {
func TestAcc_Aws_NATGateway(t *testing.T) {
acceptance.Run(t, acceptance.AccTestCase{
TerraformVersion: "0.15.5",
Paths: []string{"./testdata/acc/aws_nat_gateway"},
Expand Down
12 changes: 12 additions & 0 deletions pkg/resource/aws/aws_network_acl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package aws_test

import (
"testing"
"time"

"github.com/snyk/driftctl/test"
"github.com/snyk/driftctl/test/acceptance"
Expand Down Expand Up @@ -41,6 +42,17 @@ func TestAcc_Aws_NetworkAcl_NonDeep(t *testing.T) {
Env: map[string]string{
"AWS_REGION": "us-east-1",
},
// New resources are not visible immediately through AWS API after an apply operation
// (e.g. InvalidNetworkAclID.NotFound)
// Logic below retries driftctl scan using a back-off strategy of retrying 'n' times
// and doubling the amount of time waited after each one.
ShouldRetry: func(result *test.ScanResult, retryDuration time.Duration, retryCount uint8) bool {
if result.IsSync() || retryDuration > 10*time.Minute {
return false
}
time.Sleep((2 * time.Duration(retryCount)) * time.Minute)
return true
},
Check: func(result *test.ScanResult, stdout string, err error) {
if err != nil {
t.Fatal(err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/resource/aws/aws_route53_health_check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/snyk/driftctl/test/acceptance/awsutils"
)

func TestAcc_AwsRoute53HealthCheck(t *testing.T) {
func TestAcc_Aws_Route53HealthCheck(t *testing.T) {
var mutatedHealthCheckID string
acceptance.Run(t, acceptance.AccTestCase{
TerraformVersion: "0.15.5",
Expand Down
7 changes: 5 additions & 2 deletions pkg/resource/aws/aws_route53_record_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/snyk/driftctl/test/acceptance"
)

func TestAcc_AwsRoute53Record_WithFQDNAsId(t *testing.T) {
func TestAcc_Aws_Route53Record_WithFQDNAsId(t *testing.T) {
acceptance.Run(t, acceptance.AccTestCase{
TerraformVersion: "0.15.5",
Paths: []string{"./testdata/acc/aws_route53_record"},
Expand All @@ -30,13 +30,16 @@ func TestAcc_AwsRoute53Record_WithFQDNAsId(t *testing.T) {
})
}

func TestAcc_AwsRoute53Record_WithAlias(t *testing.T) {
func TestAcc_Aws_Route53Record_WithAlias(t *testing.T) {
acceptance.Run(t, acceptance.AccTestCase{
TerraformVersion: "0.15.5",
Paths: []string{"./testdata/acc/aws_route53_record_with_alias"},
Args: []string{"scan", "--deep"},
Checks: []acceptance.AccCheck{
{
Env: map[string]string{
"AWS_REGION": "us-east-1",
},
Check: func(result *test.ScanResult, stdout string, err error) {
if err != nil {
t.Fatal(err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/resource/aws/aws_route_table_association_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/snyk/driftctl/test/acceptance"
)

func TestAcc_AwsRouteTableAssociation(t *testing.T) {
func TestAcc_Aws_RouteTableAssociation(t *testing.T) {
acceptance.Run(t, acceptance.AccTestCase{
TerraformVersion: "0.15.5",
Paths: []string{"./testdata/acc/aws_route_table_association"},
Expand Down
2 changes: 1 addition & 1 deletion pkg/resource/aws/aws_route_table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/snyk/driftctl/test/acceptance"
)

func TestAcc_AwsRouteTable(t *testing.T) {
func TestAcc_Aws_RouteTable(t *testing.T) {
acceptance.Run(t, acceptance.AccTestCase{
TerraformVersion: "0.15.5",
Paths: []string{"./testdata/acc/aws_route_table"},
Expand Down
2 changes: 1 addition & 1 deletion pkg/resource/aws/aws_route_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/snyk/driftctl/test/acceptance"
)

func TestAcc_AwsRoute(t *testing.T) {
func TestAcc_Aws_Route(t *testing.T) {
acceptance.Run(t, acceptance.AccTestCase{
TerraformVersion: "0.15.5",
Paths: []string{"./testdata/acc/aws_route"},
Expand Down
2 changes: 1 addition & 1 deletion pkg/resource/aws/aws_s3_bucket_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/snyk/driftctl/test/acceptance"
)

func TestAcc_AwsS3Bucket_BucketInUsEast1(t *testing.T) {
func TestAcc_Aws_S3Bucket_BucketInUsEast1(t *testing.T) {
acceptance.Run(t, acceptance.AccTestCase{
TerraformVersion: "0.15.5",
Paths: []string{"./testdata/acc/aws_s3_bucket"},
Expand Down
2 changes: 1 addition & 1 deletion pkg/resource/aws/aws_security_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/snyk/driftctl/test/acceptance"
)

func TestAcc_AwsSecurityGroup(t *testing.T) {
func TestAcc_Aws_SecurityGroup(t *testing.T) {
acceptance.Run(t, acceptance.AccTestCase{
TerraformVersion: "0.15.5",
Paths: []string{"./testdata/acc/aws_security_group"},
Expand Down
2 changes: 1 addition & 1 deletion pkg/resource/aws/aws_sns_topic_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/snyk/driftctl/test/acceptance/awsutils"
)

func TestAcc_AwsSNSTopicPolicy(t *testing.T) {
func TestAcc_Aws_SNSTopicPolicy(t *testing.T) {
acceptance.Run(t, acceptance.AccTestCase{
TerraformVersion: "0.15.5",
Paths: []string{"./testdata/acc/aws_sns_topic_policy"},
Expand Down
2 changes: 1 addition & 1 deletion pkg/resource/aws/aws_sns_topic_subscription_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/snyk/driftctl/test/acceptance/awsutils"
)

func TestAcc_AwsSNSTopicSubscription(t *testing.T) {
func TestAcc_Aws_SNSTopicSubscription(t *testing.T) {
acceptance.Run(t, acceptance.AccTestCase{
TerraformVersion: "0.15.5",
Paths: []string{"./testdata/acc/aws_sns_topic_subscription"},
Expand Down
2 changes: 1 addition & 1 deletion pkg/resource/aws/aws_sns_topic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"github.com/snyk/driftctl/test/acceptance/awsutils"
)

func TestAcc_AwsSNSTopic(t *testing.T) {
func TestAcc_Aws_SNSTopic(t *testing.T) {
var mutatedTopicArn string
acceptance.Run(t, acceptance.AccTestCase{
TerraformVersion: "0.15.5",
Expand Down
2 changes: 1 addition & 1 deletion pkg/resource/aws/aws_sqs_queue_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/snyk/driftctl/test/acceptance"
)

func TestAcc_AwsSQSQueuePolicy(t *testing.T) {
func TestAcc_Aws_SQSQueuePolicy(t *testing.T) {
acceptance.Run(t, acceptance.AccTestCase{
TerraformVersion: "0.15.5",
Paths: []string{"./testdata/acc/aws_sqs_queue_policy"},
Expand Down
2 changes: 1 addition & 1 deletion pkg/resource/aws/aws_sqs_queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"github.com/snyk/driftctl/test/acceptance/awsutils"
)

func TestAcc_AwsSQSQueue(t *testing.T) {
func TestAcc_Aws_SQSQueue(t *testing.T) {
var mutatedQueue string
acceptance.Run(t, acceptance.AccTestCase{
TerraformVersion: "0.15.5",
Expand Down
2 changes: 1 addition & 1 deletion pkg/resource/aws/aws_subnet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/snyk/driftctl/test/acceptance"
)

func TestAcc_AwsSubnet(t *testing.T) {
func TestAcc_Aws_Subnet(t *testing.T) {
acceptance.Run(t, acceptance.AccTestCase{
TerraformVersion: "0.15.5",
Paths: []string{"./testdata/acc/aws_subnet"},
Expand Down
2 changes: 1 addition & 1 deletion pkg/resource/aws/aws_vpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/snyk/driftctl/test/acceptance"
)

func TestAcc_AwsVPC(t *testing.T) {
func TestAcc_Aws_VPC(t *testing.T) {
acceptance.Run(t, acceptance.AccTestCase{
TerraformVersion: "0.15.5",
Paths: []string{"./testdata/acc/aws_vpc"},
Expand Down

0 comments on commit 66baef7

Please sign in to comment.