Skip to content

Commit de37754

Browse files
authored
Merge pull request #38146 from hashicorp/td-m2-tagtests
Adds tagging tests for M2 resources
2 parents 10a6b16 + a07da70 commit de37754

File tree

20 files changed

+4032
-189
lines changed

20 files changed

+4032
-189
lines changed

internal/service/m2/application.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ import (
3636
"github.com/hashicorp/terraform-provider-aws/names"
3737
)
3838

39-
// @FrameworkResource(name="Application")
39+
// @FrameworkResource("aws_m2_application", name="Application")
4040
// @Tags(identifierAttribute="arn")
41+
// @Testing(existsType="github.com/aws/aws-sdk-go-v2/service/m2;m2.GetApplicationOutput")
4142
func newApplicationResource(context.Context) (resource.ResourceWithConfigure, error) {
4243
r := &applicationResource{}
4344

internal/service/m2/application_tags_gen_test.go

Lines changed: 1800 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/service/m2/application_test.go

Lines changed: 0 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -97,57 +97,6 @@ func TestAccM2Application_disappears(t *testing.T) {
9797
})
9898
}
9999

100-
func TestAccM2Application_tags(t *testing.T) {
101-
ctx := acctest.Context(t)
102-
if testing.Short() {
103-
t.Skip("skipping long-running test in short mode")
104-
}
105-
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
106-
resourceName := "aws_m2_application.test"
107-
var application m2.GetApplicationOutput
108-
109-
resource.ParallelTest(t, resource.TestCase{
110-
PreCheck: func() { acctest.PreCheck(ctx, t) },
111-
ErrorCheck: acctest.ErrorCheck(t, names.M2),
112-
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
113-
CheckDestroy: resource.ComposeAggregateTestCheckFunc(
114-
testAccCheckApplicationDestroy(ctx),
115-
),
116-
Steps: []resource.TestStep{
117-
{
118-
Config: testAccApplicationConfig_tags1(rName, acctest.CtKey1, acctest.CtValue1),
119-
Check: resource.ComposeTestCheckFunc(
120-
testAccCheckApplicationExists(ctx, resourceName, &application),
121-
resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.Ct1),
122-
resource.TestCheckResourceAttr(resourceName, acctest.CtTagsKey1, acctest.CtValue1),
123-
),
124-
},
125-
{
126-
ResourceName: resourceName,
127-
ImportState: true,
128-
ImportStateVerify: true,
129-
},
130-
{
131-
Config: testAccApplicationConfig_tags2(rName, acctest.CtKey1, acctest.CtValue1Updated, acctest.CtKey2, acctest.CtValue2),
132-
Check: resource.ComposeTestCheckFunc(
133-
testAccCheckApplicationExists(ctx, resourceName, &application),
134-
resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.Ct2),
135-
resource.TestCheckResourceAttr(resourceName, acctest.CtTagsKey1, acctest.CtValue1Updated),
136-
resource.TestCheckResourceAttr(resourceName, acctest.CtTagsKey2, acctest.CtValue2),
137-
),
138-
},
139-
{
140-
Config: testAccApplicationConfig_tags1(rName, acctest.CtKey2, acctest.CtValue2),
141-
Check: resource.ComposeTestCheckFunc(
142-
testAccCheckApplicationExists(ctx, resourceName, &application),
143-
resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.Ct1),
144-
resource.TestCheckResourceAttr(resourceName, acctest.CtTagsKey2, acctest.CtValue2),
145-
),
146-
},
147-
},
148-
})
149-
}
150-
151100
func TestAccM2Application_full(t *testing.T) {
152101
ctx := acctest.Context(t)
153102
if testing.Short() {
@@ -391,60 +340,3 @@ resource "aws_iam_role_policy" "test" {
391340
}
392341
`, rName)
393342
}
394-
395-
func testAccApplicationConfig_tags1(rName, tagKey1, tagValue1 string) string {
396-
return fmt.Sprintf(`
397-
resource "aws_s3_bucket" "test" {
398-
bucket = %[1]q
399-
}
400-
401-
resource "aws_s3_object" "test" {
402-
bucket = aws_s3_bucket.test.id
403-
key = "v1/PlanetsDemo-v1.zip"
404-
source = "test-fixtures/PlanetsDemo-v1.zip"
405-
}
406-
407-
resource "aws_m2_application" "test" {
408-
name = %[1]q
409-
engine_type = "bluage"
410-
definition {
411-
content = templatefile("test-fixtures/application-definition.json", { s3_bucket = aws_s3_bucket.test.id, version = "v1" })
412-
}
413-
414-
tags = {
415-
%[2]q = %[3]q
416-
}
417-
418-
depends_on = [aws_s3_object.test]
419-
}
420-
`, rName, tagKey1, tagValue1)
421-
}
422-
423-
func testAccApplicationConfig_tags2(rName, tagKey1, tagValue1, tagKey2, tagValue2 string) string {
424-
return fmt.Sprintf(`
425-
resource "aws_s3_bucket" "test" {
426-
bucket = %[1]q
427-
}
428-
429-
resource "aws_s3_object" "test" {
430-
bucket = aws_s3_bucket.test.id
431-
key = "v1/PlanetsDemo-v1.zip"
432-
source = "test-fixtures/PlanetsDemo-v1.zip"
433-
}
434-
435-
resource "aws_m2_application" "test" {
436-
name = %[1]q
437-
engine_type = "bluage"
438-
definition {
439-
content = templatefile("test-fixtures/application-definition.json", { s3_bucket = aws_s3_bucket.test.id, version = "v1" })
440-
}
441-
442-
tags = {
443-
%[2]q = %[3]q
444-
%[4]q = %[5]q
445-
}
446-
447-
depends_on = [aws_s3_object.test]
448-
}
449-
`, rName, tagKey1, tagValue1, tagKey2, tagValue2)
450-
}

internal/service/m2/deployment.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import (
3030
"github.com/hashicorp/terraform-provider-aws/names"
3131
)
3232

33-
// @FrameworkResource(name="Deployment")
33+
// @FrameworkResource("aws_m2_deployment", name="Deployment")
3434
func newDeploymentResource(context.Context) (resource.ResourceWithConfigure, error) {
3535
r := &deploymentResource{}
3636

internal/service/m2/environment.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ import (
4242
"github.com/hashicorp/terraform-provider-aws/names"
4343
)
4444

45-
// @FrameworkResource(name="Environment")
45+
// @FrameworkResource("aws_m2_environment", name="Environment")
4646
// @Tags(identifierAttribute="arn")
47+
// @Testing(existsType="github.com/aws/aws-sdk-go-v2/service/m2;m2.GetEnvironmentOutput")
4748
func newEnvironmentResource(context.Context) (resource.ResourceWithConfigure, error) {
4849
r := &environmentResource{}
4950

0 commit comments

Comments
 (0)