provider/aws: Add tests for Network ACL subnets
This commit is contained in:
parent
468de49265
commit
d9521efbf6
|
@ -182,6 +182,18 @@ func TestAccAWSNetworkAcl_SubnetChange(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAccAWSNetworkAcl_Subnets(t *testing.T) {
|
func TestAccAWSNetworkAcl_Subnets(t *testing.T) {
|
||||||
|
var networkAcl ec2.NetworkACL
|
||||||
|
|
||||||
|
checkACLSubnets := func(acl *ec2.NetworkACL, count int) resource.TestCheckFunc {
|
||||||
|
return func(*terraform.State) (err error) {
|
||||||
|
if count != len(acl.Associations) {
|
||||||
|
return fmt.Errorf("ACL association count does not match, expected %d, got %d", count, len(acl.Associations))
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
Providers: testAccProviders,
|
Providers: testAccProviders,
|
||||||
|
@ -190,17 +202,21 @@ func TestAccAWSNetworkAcl_Subnets(t *testing.T) {
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccAWSNetworkAclSubnet_SubnetIds,
|
Config: testAccAWSNetworkAclSubnet_SubnetIds,
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
|
testAccCheckAWSNetworkAclExists("aws_network_acl.bar", &networkAcl),
|
||||||
testAccCheckSubnetIsAssociatedWithAcl("aws_network_acl.bar", "aws_subnet.one"),
|
testAccCheckSubnetIsAssociatedWithAcl("aws_network_acl.bar", "aws_subnet.one"),
|
||||||
testAccCheckSubnetIsAssociatedWithAcl("aws_network_acl.bar", "aws_subnet.two"),
|
testAccCheckSubnetIsAssociatedWithAcl("aws_network_acl.bar", "aws_subnet.two"),
|
||||||
|
checkACLSubnets(&networkAcl, 2),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccAWSNetworkAclSubnet_SubnetIdsUpdate,
|
Config: testAccAWSNetworkAclSubnet_SubnetIdsUpdate,
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
|
testAccCheckAWSNetworkAclExists("aws_network_acl.bar", &networkAcl),
|
||||||
testAccCheckSubnetIsAssociatedWithAcl("aws_network_acl.bar", "aws_subnet.one"),
|
testAccCheckSubnetIsAssociatedWithAcl("aws_network_acl.bar", "aws_subnet.one"),
|
||||||
testAccCheckSubnetIsAssociatedWithAcl("aws_network_acl.bar", "aws_subnet.three"),
|
testAccCheckSubnetIsAssociatedWithAcl("aws_network_acl.bar", "aws_subnet.three"),
|
||||||
testAccCheckSubnetIsAssociatedWithAcl("aws_network_acl.bar", "aws_subnet.four"),
|
testAccCheckSubnetIsAssociatedWithAcl("aws_network_acl.bar", "aws_subnet.four"),
|
||||||
|
checkACLSubnets(&networkAcl, 3),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue