Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests/provider: Update resource testing to 0.12 syntax (N Resources) #14634

Merged
merged 1 commit into from
Aug 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions aws/resource_aws_nat_gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,31 +194,34 @@ func testAccCheckNatGatewayExists(n string, ng *ec2.NatGateway) resource.TestChe
const testAccNatGatewayConfigBase = `
resource "aws_vpc" "test" {
cidr_block = "10.0.0.0/16"

tags = {
Name = "terraform-testacc-nat-gw-basic"
}
}

resource "aws_subnet" "private" {
vpc_id = "${aws_vpc.test.id}"
vpc_id = aws_vpc.test.id
cidr_block = "10.0.1.0/24"
map_public_ip_on_launch = false

tags = {
Name = "tf-acc-nat-gw-basic-private"
}
}

resource "aws_subnet" "public" {
vpc_id = "${aws_vpc.test.id}"
vpc_id = aws_vpc.test.id
cidr_block = "10.0.2.0/24"
map_public_ip_on_launch = true

tags = {
Name = "tf-acc-nat-gw-basic-public"
}
}

resource "aws_internet_gateway" "test" {
vpc_id = "${aws_vpc.test.id}"
vpc_id = aws_vpc.test.id
}

resource "aws_eip" "test" {
Expand All @@ -229,8 +232,8 @@ resource "aws_eip" "test" {
const testAccNatGatewayConfig = testAccNatGatewayConfigBase + `
// Actual SUT
resource "aws_nat_gateway" "test" {
allocation_id = "${aws_eip.test.id}"
subnet_id = "${aws_subnet.public.id}"
allocation_id = aws_eip.test.id
subnet_id = aws_subnet.public.id

depends_on = ["aws_internet_gateway.test"]
}
Expand All @@ -239,8 +242,8 @@ resource "aws_nat_gateway" "test" {
func testAccNatGatewayConfigTags1(tagKey1, tagValue1 string) string {
return testAccNatGatewayConfigBase + fmt.Sprintf(`
resource "aws_nat_gateway" "test" {
allocation_id = "${aws_eip.test.id}"
subnet_id = "${aws_subnet.public.id}"
allocation_id = aws_eip.test.id
subnet_id = aws_subnet.public.id

tags = {
%[1]q = %[2]q
Expand All @@ -254,8 +257,8 @@ resource "aws_nat_gateway" "test" {
func testAccNatGatewayConfigTags2(tagKey1, tagValue1, tagKey2, tagValue2 string) string {
return testAccNatGatewayConfigBase + fmt.Sprintf(`
resource "aws_nat_gateway" "test" {
allocation_id = "${aws_eip.test.id}"
subnet_id = "${aws_subnet.public.id}"
allocation_id = aws_eip.test.id
subnet_id = aws_subnet.public.id

tags = {
%[1]q = %[2]q
Expand Down
50 changes: 25 additions & 25 deletions aws/resource_aws_neptune_cluster_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ func testAccCheckAWSNeptuneClusterInstanceExists(n string, v *neptune.DBInstance

func testAccCheckAWSNeptuneClusterInstanceAttributes(v *neptune.DBInstance) resource.TestCheckFunc {
return func(s *terraform.State) error {

if aws.StringValue(v.Engine) != "neptune" {
return fmt.Errorf("Incorrect engine, expected \"neptune\": %#v", aws.StringValue(v.Engine))
}
Expand Down Expand Up @@ -260,9 +259,9 @@ func testAccAWSNeptuneClusterInstanceConfig(instanceName string, n int) string {
fmt.Sprintf(`
resource "aws_neptune_cluster_instance" "cluster_instances" {
identifier = %[1]q
cluster_identifier = "${aws_neptune_cluster.default.id}"
cluster_identifier = aws_neptune_cluster.default.id
instance_class = "db.r4.large"
neptune_parameter_group_name = "${aws_neptune_parameter_group.test.name}"
neptune_parameter_group_name = aws_neptune_parameter_group.test.name
promotion_tier = "3"
}

Expand Down Expand Up @@ -294,9 +293,9 @@ func testAccAWSNeptuneClusterInstanceConfigModified(instanceName string, n int)
fmt.Sprintf(`
resource "aws_neptune_cluster_instance" "cluster_instances" {
identifier = %[1]q
cluster_identifier = "${aws_neptune_cluster.default.id}"
cluster_identifier = aws_neptune_cluster.default.id
instance_class = "db.r4.large"
neptune_parameter_group_name = "${aws_neptune_parameter_group.test.name}"
neptune_parameter_group_name = aws_neptune_parameter_group.test.name
auto_minor_version_upgrade = false
promotion_tier = "3"
}
Expand Down Expand Up @@ -329,9 +328,9 @@ func testAccAWSNeptuneClusterInstanceConfig_az(n int) string {
fmt.Sprintf(`
resource "aws_neptune_cluster_instance" "cluster_instances" {
identifier = "tf-cluster-instance-%[1]d"
cluster_identifier = "${aws_neptune_cluster.default.id}"
cluster_identifier = aws_neptune_cluster.default.id
instance_class = "db.r4.large"
neptune_parameter_group_name = "${aws_neptune_parameter_group.test.name}"
neptune_parameter_group_name = aws_neptune_parameter_group.test.name
promotion_tier = "3"
availability_zone = data.aws_availability_zones.available.names[0]
}
Expand Down Expand Up @@ -364,13 +363,13 @@ func testAccAWSNeptuneClusterInstanceConfig_withSubnetGroup(n int) string {
fmt.Sprintf(`
resource "aws_neptune_cluster_instance" "test" {
identifier = "tf-cluster-instance-%[1]d"
cluster_identifier = "${aws_neptune_cluster.test.id}"
cluster_identifier = aws_neptune_cluster.test.id
instance_class = "db.r4.large"
}

resource "aws_neptune_cluster" "test" {
cluster_identifier = "tf-neptune-cluster-%[1]d"
neptune_subnet_group_name = "${aws_neptune_subnet_group.test.name}"
neptune_subnet_group_name = aws_neptune_subnet_group.test.name
skip_final_snapshot = true
}

Expand All @@ -383,7 +382,7 @@ resource "aws_vpc" "test" {
}

resource "aws_subnet" "a" {
vpc_id = "${aws_vpc.test.id}"
vpc_id = aws_vpc.test.id
cidr_block = "10.0.0.0/24"
availability_zone = "us-west-2a"

Expand All @@ -393,7 +392,7 @@ resource "aws_subnet" "a" {
}

resource "aws_subnet" "b" {
vpc_id = "${aws_vpc.test.id}"
vpc_id = aws_vpc.test.id
cidr_block = "10.0.1.0/24"
availability_zone = "us-west-2b"

Expand All @@ -404,7 +403,7 @@ resource "aws_subnet" "b" {

resource "aws_neptune_subnet_group" "test" {
name = "tf-test-%[1]d"
subnet_ids = ["${aws_subnet.a.id}", "${aws_subnet.b.id}"]
subnet_ids = [aws_subnet.a.id, aws_subnet.b.id]
}
`, n))
}
Expand All @@ -415,13 +414,13 @@ func testAccAWSNeptuneClusterInstanceConfig_namePrefix(namePrefix string, n int)
fmt.Sprintf(`
resource "aws_neptune_cluster_instance" "test" {
identifier_prefix = %[1]q
cluster_identifier = "${aws_neptune_cluster.test.id}"
cluster_identifier = aws_neptune_cluster.test.id
instance_class = "db.r4.large"
}

resource "aws_neptune_cluster" "test" {
cluster_identifier = "tf-neptune-cluster-%[2]d"
neptune_subnet_group_name = "${aws_neptune_subnet_group.test.name}"
neptune_subnet_group_name = aws_neptune_subnet_group.test.name
skip_final_snapshot = true
}

Expand All @@ -434,7 +433,7 @@ resource "aws_vpc" "test" {
}

resource "aws_subnet" "a" {
vpc_id = "${aws_vpc.test.id}"
vpc_id = aws_vpc.test.id
cidr_block = "10.0.0.0/24"
availability_zone = "us-west-2a"

Expand All @@ -444,7 +443,7 @@ resource "aws_subnet" "a" {
}

resource "aws_subnet" "b" {
vpc_id = "${aws_vpc.test.id}"
vpc_id = aws_vpc.test.id
cidr_block = "10.0.1.0/24"
availability_zone = "us-west-2b"

Expand All @@ -455,7 +454,7 @@ resource "aws_subnet" "b" {

resource "aws_neptune_subnet_group" "test" {
name = "tf-test-%[2]d"
subnet_ids = ["${aws_subnet.a.id}", "${aws_subnet.b.id}"]
subnet_ids = [aws_subnet.a.id, aws_subnet.b.id]
}
`, namePrefix, n))
}
Expand All @@ -465,13 +464,13 @@ func testAccAWSNeptuneClusterInstanceConfig_generatedName(n int) string {
testAccAWSNeptuneClusterConfigBase,
fmt.Sprintf(`
resource "aws_neptune_cluster_instance" "test" {
cluster_identifier = "${aws_neptune_cluster.test.id}"
cluster_identifier = aws_neptune_cluster.test.id
instance_class = "db.r4.large"
}

resource "aws_neptune_cluster" "test" {
cluster_identifier = "tf-neptune-cluster-%[1]d"
neptune_subnet_group_name = "${aws_neptune_subnet_group.test.name}"
neptune_subnet_group_name = aws_neptune_subnet_group.test.name
skip_final_snapshot = true
}

Expand All @@ -484,7 +483,7 @@ resource "aws_vpc" "test" {
}

resource "aws_subnet" "a" {
vpc_id = "${aws_vpc.test.id}"
vpc_id = aws_vpc.test.id
cidr_block = "10.0.0.0/24"
availability_zone = "us-west-2a"

Expand All @@ -494,7 +493,7 @@ resource "aws_subnet" "a" {
}

resource "aws_subnet" "b" {
vpc_id = "${aws_vpc.test.id}"
vpc_id = aws_vpc.test.id
cidr_block = "10.0.1.0/24"
availability_zone = "us-west-2b"

Expand All @@ -505,7 +504,7 @@ resource "aws_subnet" "b" {

resource "aws_neptune_subnet_group" "test" {
name = "tf-test-%[1]d"
subnet_ids = ["${aws_subnet.a.id}", "${aws_subnet.b.id}"]
subnet_ids = [aws_subnet.a.id, aws_subnet.b.id]
}
`, n))
}
Expand Down Expand Up @@ -534,21 +533,22 @@ resource "aws_kms_key" "test" {
]
}
POLICY

}

resource "aws_neptune_cluster" "default" {
cluster_identifier = "tf-neptune-cluster-test-%[1]d"
availability_zones = local.availability_zone_names
skip_final_snapshot = true
storage_encrypted = true
kms_key_arn = "${aws_kms_key.test.arn}"
kms_key_arn = aws_kms_key.test.arn
}

resource "aws_neptune_cluster_instance" "cluster_instances" {
identifier = "tf-cluster-instance-%[1]d"
cluster_identifier = "${aws_neptune_cluster.default.id}"
cluster_identifier = aws_neptune_cluster.default.id
instance_class = "db.r4.large"
neptune_parameter_group_name = "${aws_neptune_parameter_group.test.name}"
neptune_parameter_group_name = aws_neptune_parameter_group.test.name
}

resource "aws_neptune_parameter_group" "test" {
Expand Down
2 changes: 1 addition & 1 deletion aws/resource_aws_neptune_cluster_parameter_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,6 @@ func testAccCheckAWSNeptuneClusterParameterGroupDestroy(s *terraform.State) erro

func testAccCheckAWSNeptuneClusterParameterGroupAttributes(v *neptune.DBClusterParameterGroup, name string) resource.TestCheckFunc {
return func(s *terraform.State) error {

if *v.DBClusterParameterGroupName != name {
return fmt.Errorf("bad name: %#v expected: %v", *v.DBClusterParameterGroupName, name)
}
Expand Down Expand Up @@ -356,6 +355,7 @@ resource "aws_neptune_cluster_parameter_group" "test" {
name_prefix = "tf-test-"
}
`

const testAccAWSNeptuneClusterParameterGroupConfig_generatedName = `
resource "aws_neptune_cluster_parameter_group" "test" {
family = "neptune1"
Expand Down
2 changes: 1 addition & 1 deletion aws/resource_aws_neptune_cluster_snapshot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ resource "aws_neptune_cluster" "test" {
}

resource "aws_neptune_cluster_snapshot" "test" {
db_cluster_identifier = "${aws_neptune_cluster.test.id}"
db_cluster_identifier = aws_neptune_cluster.test.id
db_cluster_snapshot_identifier = %[1]q
}
`, rName)
Expand Down
Loading