Skip to content

Commit

Permalink
tests/r/lightsail_instance_public_ports: Use set testing
Browse files Browse the repository at this point in the history
  • Loading branch information
YakDriver committed Mar 25, 2021
1 parent 5fce8f9 commit 4d85170
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions aws/resource_aws_lightsail_instance_public_ports_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ func TestAccAWSLightsailInstancePublicPorts_basic(t *testing.T) {
Check: resource.ComposeAggregateTestCheckFunc(
testAccCheckAWSLightsailInstancePublicPortsExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "port_info.#", "1"),
resource.TestCheckResourceAttr(resourceName, "port_info.0.protocol", "tcp"),
resource.TestCheckResourceAttr(resourceName, "port_info.0.from_port", "80"),
resource.TestCheckResourceAttr(resourceName, "port_info.0.to_port", "80"),
resource.TestCheckTypeSetElemNestedAttrs(resourceName, "port_info.*", map[string]string{
"protocol": "tcp",
"from_port": "80",
"to_port": "80",
}),
),
},
},
Expand All @@ -59,12 +61,16 @@ func TestAccAWSLightsailInstancePublicPorts_multiple(t *testing.T) {
Check: resource.ComposeAggregateTestCheckFunc(
testAccCheckAWSLightsailInstancePublicPortsExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "port_info.#", "2"),
resource.TestCheckResourceAttr(resourceName, "port_info.1.protocol", "tcp"),
resource.TestCheckResourceAttr(resourceName, "port_info.1.from_port", "80"),
resource.TestCheckResourceAttr(resourceName, "port_info.1.to_port", "80"),
resource.TestCheckResourceAttr(resourceName, "port_info.0.protocol", "tcp"),
resource.TestCheckResourceAttr(resourceName, "port_info.0.from_port", "443"),
resource.TestCheckResourceAttr(resourceName, "port_info.0.to_port", "443"),
resource.TestCheckTypeSetElemNestedAttrs(resourceName, "port_info.*", map[string]string{
"protocol": "tcp",
"from_port": "80",
"to_port": "80",
}),
resource.TestCheckTypeSetElemNestedAttrs(resourceName, "port_info.*", map[string]string{
"protocol": "tcp",
"from_port": "443",
"to_port": "443",
}),
),
},
},
Expand Down Expand Up @@ -94,9 +100,10 @@ func TestAccAWSLightsailInstancePublicPorts_cidrs(t *testing.T) {
"protocol": "tcp",
"from_port": "125",
"to_port": "125",
"cidrs.0": "1.1.1.1/32",
"cidrs.1": "192.168.1.0/24",
"cidrs.#": "2",
}),
resource.TestCheckTypeSetElemAttr(resourceName, "port_info.*.cidrs.*", "1.1.1.1/32"),
resource.TestCheckTypeSetElemAttr(resourceName, "port_info.*.cidrs.*", "192.168.1.0/24"),
),
},
},
Expand Down

0 comments on commit 4d85170

Please sign in to comment.