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

Update AppMesh resource acceptance tests to 0.12 syntax #14795

Merged
merged 5 commits into from
Aug 24, 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
54 changes: 27 additions & 27 deletions aws/resource_aws_appmesh_mesh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func testSweepAppmeshMeshes(region string) error {

func testAccAwsAppmeshMesh_basic(t *testing.T) {
var mesh appmesh.MeshData
resourceName := "aws_appmesh_mesh.foo"
resourceName := "aws_appmesh_mesh.test"
rName := acctest.RandomWithPrefix("tf-acc-test")

resource.Test(t, resource.TestCase{
Expand Down Expand Up @@ -96,7 +96,7 @@ func testAccAwsAppmeshMesh_basic(t *testing.T) {

func testAccAwsAppmeshMesh_egressFilter(t *testing.T) {
var mesh appmesh.MeshData
resourceName := "aws_appmesh_mesh.foo"
resourceName := "aws_appmesh_mesh.test"
rName := acctest.RandomWithPrefix("tf-acc-test")

resource.Test(t, resource.TestCase{
Expand Down Expand Up @@ -135,7 +135,7 @@ func testAccAwsAppmeshMesh_egressFilter(t *testing.T) {

func testAccAwsAppmeshMesh_tags(t *testing.T) {
var mesh appmesh.MeshData
resourceName := "aws_appmesh_mesh.foo"
resourceName := "aws_appmesh_mesh.test"
rName := acctest.RandomWithPrefix("tf-acc-test")

resource.Test(t, resource.TestCase{
Expand Down Expand Up @@ -225,17 +225,17 @@ func testAccCheckAppmeshMeshExists(name string, v *appmesh.MeshData) resource.Te
}
}

func testAccAppmeshMeshConfig_basic(name string) string {
func testAccAppmeshMeshConfig_basic(rName string) string {
return fmt.Sprintf(`
resource "aws_appmesh_mesh" "foo" {
resource "aws_appmesh_mesh" "test" {
name = %[1]q
}
`, name)
`, rName)
}

func testAccAppmeshMeshConfig_egressFilter(name, egressFilterType string) string {
func testAccAppmeshMeshConfig_egressFilter(rName, egressFilterType string) string {
return fmt.Sprintf(`
resource "aws_appmesh_mesh" "foo" {
resource "aws_appmesh_mesh" "test" {
name = %[1]q

spec {
Expand All @@ -244,44 +244,44 @@ resource "aws_appmesh_mesh" "foo" {
}
}
}
`, name, egressFilterType)
`, rName, egressFilterType)
}

func testAccAppmeshMeshConfigWithTags(name string) string {
func testAccAppmeshMeshConfigWithTags(rName string) string {
return fmt.Sprintf(`
resource "aws_appmesh_mesh" "foo" {
name = "%s"
resource "aws_appmesh_mesh" "test" {
name = %[1]q

tags = {
foo = "bar"
good = "bad"
foo = "bar"
good = "bad"
}
}
`, name)
`, rName)
}

func testAccAppmeshMeshConfigWithUpdateTags(name string) string {
func testAccAppmeshMeshConfigWithUpdateTags(rName string) string {
return fmt.Sprintf(`
resource "aws_appmesh_mesh" "foo" {
name = "%s"
resource "aws_appmesh_mesh" "test" {
name = %[1]q

tags = {
foo = "bar"
good = "bad2"
fizz = "buzz"
foo = "bar"
good = "bad2"
fizz = "buzz"
}
}
`, name)
`, rName)
}

func testAccAppmeshMeshConfigWithRemoveTags(name string) string {
func testAccAppmeshMeshConfigWithRemoveTags(rName string) string {
return fmt.Sprintf(`
resource "aws_appmesh_mesh" "foo" {
name = "%s"
resource "aws_appmesh_mesh" "test" {
name = %[1]q

tags = {
foo = "bar"
foo = "bar"
}
}
`, name)
`, rName)
}
95 changes: 44 additions & 51 deletions aws/resource_aws_appmesh_route_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,32 +289,25 @@ func testAccAwsAppmeshRoute_tags(t *testing.T) {
Config: testAccAppmeshRouteConfigWithTags(meshName, vrName, vn1Name, vn2Name, rName, "foo", "bar", "good", "bad"),
Check: resource.ComposeTestCheckFunc(
testAccCheckAppmeshRouteExists(resourceName, &r),
resource.TestCheckResourceAttr(
resourceName, "tags.%", "2"),
resource.TestCheckResourceAttr(
resourceName, "tags.foo", "bar"),
resource.TestCheckResourceAttr(
resourceName, "tags.good", "bad"),
resource.TestCheckResourceAttr(resourceName, "tags.%", "2"),
resource.TestCheckResourceAttr(resourceName, "tags.foo", "bar"),
resource.TestCheckResourceAttr(resourceName, "tags.good", "bad"),
),
},
{
Config: testAccAppmeshRouteConfigWithTags(meshName, vrName, vn1Name, vn2Name, rName, "foo2", "bar", "good", "bad2"),
Check: resource.ComposeTestCheckFunc(
testAccCheckAppmeshRouteExists(resourceName, &r),
resource.TestCheckResourceAttr(
resourceName, "tags.%", "2"),
resource.TestCheckResourceAttr(
resourceName, "tags.foo2", "bar"),
resource.TestCheckResourceAttr(
resourceName, "tags.good", "bad2"),
resource.TestCheckResourceAttr(resourceName, "tags.%", "2"),
resource.TestCheckResourceAttr(resourceName, "tags.foo2", "bar"),
resource.TestCheckResourceAttr(resourceName, "tags.good", "bad2"),
),
},
{
Config: testAccAppmeshRouteConfig_httpRoute(meshName, vrName, vn1Name, vn2Name, rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckAppmeshRouteExists(resourceName, &r),
resource.TestCheckResourceAttr(
resourceName, "tags.%", "0"),
resource.TestCheckResourceAttr(resourceName, "tags.%", "0"),
),
},
{
Expand Down Expand Up @@ -560,7 +553,7 @@ resource "aws_appmesh_mesh" "test" {

resource "aws_appmesh_virtual_router" "test" {
name = %[2]q
mesh_name = "${aws_appmesh_mesh.test.id}"
mesh_name = aws_appmesh_mesh.test.id

spec {
listener {
Expand All @@ -574,14 +567,14 @@ resource "aws_appmesh_virtual_router" "test" {

resource "aws_appmesh_virtual_node" "foo" {
name = %[3]q
mesh_name = "${aws_appmesh_mesh.test.id}"
mesh_name = aws_appmesh_mesh.test.id

spec {}
}

resource "aws_appmesh_virtual_node" "bar" {
name = %[4]q
mesh_name = "${aws_appmesh_mesh.test.id}"
mesh_name = aws_appmesh_mesh.test.id

spec {}
}
Expand All @@ -592,8 +585,8 @@ func testAccAppmeshRouteConfig_httpRoute(meshName, vrName, vn1Name, vn2Name, rNa
return testAccAppmeshRouteConfigBase(meshName, vrName, vn1Name, vn2Name) + fmt.Sprintf(`
resource "aws_appmesh_route" "test" {
name = %[1]q
mesh_name = "${aws_appmesh_mesh.test.id}"
virtual_router_name = "${aws_appmesh_virtual_router.test.name}"
mesh_name = aws_appmesh_mesh.test.id
virtual_router_name = aws_appmesh_virtual_router.test.name

spec {
http_route {
Expand All @@ -603,7 +596,7 @@ resource "aws_appmesh_route" "test" {

action {
weighted_target {
virtual_node = "${aws_appmesh_virtual_node.foo.name}"
virtual_node = aws_appmesh_virtual_node.foo.name
weight = 100
}
}
Expand All @@ -617,8 +610,8 @@ func testAccAppmeshRouteConfig_httpRouteUpdated(meshName, vrName, vn1Name, vn2Na
return testAccAppmeshRouteConfigBase(meshName, vrName, vn1Name, vn2Name) + fmt.Sprintf(`
resource "aws_appmesh_route" "test" {
name = %[1]q
mesh_name = "${aws_appmesh_mesh.test.id}"
virtual_router_name = "${aws_appmesh_virtual_router.test.name}"
mesh_name = aws_appmesh_mesh.test.id
virtual_router_name = aws_appmesh_virtual_router.test.name

spec {
http_route {
Expand All @@ -628,12 +621,12 @@ resource "aws_appmesh_route" "test" {

action {
weighted_target {
virtual_node = "${aws_appmesh_virtual_node.foo.name}"
virtual_node = aws_appmesh_virtual_node.foo.name
weight = 90
}

weighted_target {
virtual_node = "${aws_appmesh_virtual_node.bar.name}"
virtual_node = aws_appmesh_virtual_node.bar.name
weight = 10
}
}
Expand All @@ -647,8 +640,8 @@ func testAccAppmeshRouteConfig_httpRouteUpdatedWithZeroWeight(meshName, vrName,
return testAccAppmeshRouteConfigBase(meshName, vrName, vn1Name, vn2Name) + fmt.Sprintf(`
resource "aws_appmesh_route" "test" {
name = %[1]q
mesh_name = "${aws_appmesh_mesh.test.id}"
virtual_router_name = "${aws_appmesh_virtual_router.test.name}"
mesh_name = aws_appmesh_mesh.test.id
virtual_router_name = aws_appmesh_virtual_router.test.name

spec {
http_route {
Expand All @@ -658,12 +651,12 @@ resource "aws_appmesh_route" "test" {

action {
weighted_target {
virtual_node = "${aws_appmesh_virtual_node.foo.name}"
virtual_node = aws_appmesh_virtual_node.foo.name
weight = 99
}

weighted_target {
virtual_node = "${aws_appmesh_virtual_node.bar.name}"
virtual_node = aws_appmesh_virtual_node.bar.name
weight = 0
}
}
Expand All @@ -677,14 +670,14 @@ func testAccAppmeshRouteConfig_tcpRoute(meshName, vrName, vn1Name, vn2Name, rNam
return testAccAppmeshRouteConfigBase(meshName, vrName, vn1Name, vn2Name) + fmt.Sprintf(`
resource "aws_appmesh_route" "test" {
name = %[1]q
mesh_name = "${aws_appmesh_mesh.test.id}"
virtual_router_name = "${aws_appmesh_virtual_router.test.name}"
mesh_name = aws_appmesh_mesh.test.id
virtual_router_name = aws_appmesh_virtual_router.test.name

spec {
tcp_route {
action {
weighted_target {
virtual_node = "${aws_appmesh_virtual_node.foo.name}"
virtual_node = aws_appmesh_virtual_node.foo.name
weight = 100
}
}
Expand All @@ -698,19 +691,19 @@ func testAccAppmeshRouteConfig_tcpRouteUpdated(meshName, vrName, vn1Name, vn2Nam
return testAccAppmeshRouteConfigBase(meshName, vrName, vn1Name, vn2Name) + fmt.Sprintf(`
resource "aws_appmesh_route" "test" {
name = %[1]q
mesh_name = "${aws_appmesh_mesh.test.id}"
virtual_router_name = "${aws_appmesh_virtual_router.test.name}"
mesh_name = aws_appmesh_mesh.test.id
virtual_router_name = aws_appmesh_virtual_router.test.name

spec {
tcp_route {
action {
weighted_target {
virtual_node = "${aws_appmesh_virtual_node.foo.name}"
virtual_node = aws_appmesh_virtual_node.foo.name
weight = 90
}

weighted_target {
virtual_node = "${aws_appmesh_virtual_node.bar.name}"
virtual_node = aws_appmesh_virtual_node.bar.name
weight = 10
}
}
Expand All @@ -724,19 +717,19 @@ func testAccAppmeshRouteConfig_tcpRouteUpdatedWithZeroWeight(meshName, vrName, v
return testAccAppmeshRouteConfigBase(meshName, vrName, vn1Name, vn2Name) + fmt.Sprintf(`
resource "aws_appmesh_route" "test" {
name = %[1]q
mesh_name = "${aws_appmesh_mesh.test.id}"
virtual_router_name = "${aws_appmesh_virtual_router.test.name}"
mesh_name = aws_appmesh_mesh.test.id
virtual_router_name = aws_appmesh_virtual_router.test.name

spec {
tcp_route {
action {
weighted_target {
virtual_node = "${aws_appmesh_virtual_node.foo.name}"
virtual_node = aws_appmesh_virtual_node.foo.name
weight = 99
}

weighted_target {
virtual_node = "${aws_appmesh_virtual_node.bar.name}"
virtual_node = aws_appmesh_virtual_node.bar.name
weight = 0
}
}
Expand All @@ -750,8 +743,8 @@ func testAccAppmeshRouteConfigWithTags(meshName, vrName, vn1Name, vn2Name, rName
return testAccAppmeshRouteConfigBase(meshName, vrName, vn1Name, vn2Name) + fmt.Sprintf(`
resource "aws_appmesh_route" "test" {
name = %[1]q
mesh_name = "${aws_appmesh_mesh.test.id}"
virtual_router_name = "${aws_appmesh_virtual_router.test.name}"
mesh_name = aws_appmesh_mesh.test.id
virtual_router_name = aws_appmesh_virtual_router.test.name

spec {
http_route {
Expand All @@ -761,7 +754,7 @@ resource "aws_appmesh_route" "test" {

action {
weighted_target {
virtual_node = "${aws_appmesh_virtual_node.foo.name}"
virtual_node = aws_appmesh_virtual_node.foo.name
weight = 100
}
}
Expand All @@ -780,8 +773,8 @@ func testAccAwsAppmeshRouteConfig_httpHeader(meshName, vrName, vn1Name, vn2Name,
return testAccAppmeshRouteConfigBase(meshName, vrName, vn1Name, vn2Name) + fmt.Sprintf(`
resource "aws_appmesh_route" "test" {
name = %[1]q
mesh_name = "${aws_appmesh_mesh.test.id}"
virtual_router_name = "${aws_appmesh_virtual_router.test.name}"
mesh_name = aws_appmesh_mesh.test.id
virtual_router_name = aws_appmesh_virtual_router.test.name

spec {
http_route {
Expand All @@ -797,7 +790,7 @@ resource "aws_appmesh_route" "test" {

action {
weighted_target {
virtual_node = "${aws_appmesh_virtual_node.foo.name}"
virtual_node = aws_appmesh_virtual_node.foo.name
weight = 100
}
}
Expand All @@ -811,8 +804,8 @@ func testAccAwsAppmeshRouteConfig_httpHeaderUpdated(meshName, vrName, vn1Name, v
return testAccAppmeshRouteConfigBase(meshName, vrName, vn1Name, vn2Name) + fmt.Sprintf(`
resource "aws_appmesh_route" "test" {
name = %[1]q
mesh_name = "${aws_appmesh_mesh.test.id}"
virtual_router_name = "${aws_appmesh_virtual_router.test.name}"
mesh_name = aws_appmesh_mesh.test.id
virtual_router_name = aws_appmesh_virtual_router.test.name

spec {
http_route {
Expand Down Expand Up @@ -841,7 +834,7 @@ resource "aws_appmesh_route" "test" {

action {
weighted_target {
virtual_node = "${aws_appmesh_virtual_node.foo.name}"
virtual_node = aws_appmesh_virtual_node.foo.name
weight = 100
}
}
Expand All @@ -855,8 +848,8 @@ func testAccAwsAppmeshRouteConfig_routePriority(meshName, vrName, vn1Name, vn2Na
return testAccAppmeshRouteConfigBase(meshName, vrName, vn1Name, vn2Name) + fmt.Sprintf(`
resource "aws_appmesh_route" "test" {
name = %[1]q
mesh_name = "${aws_appmesh_mesh.test.id}"
virtual_router_name = "${aws_appmesh_virtual_router.test.name}"
mesh_name = aws_appmesh_mesh.test.id
virtual_router_name = aws_appmesh_virtual_router.test.name

spec {
http_route {
Expand All @@ -866,7 +859,7 @@ resource "aws_appmesh_route" "test" {

action {
weighted_target {
virtual_node = "${aws_appmesh_virtual_node.foo.name}"
virtual_node = aws_appmesh_virtual_node.foo.name
weight = 100
}
}
Expand Down
Loading