mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
provider/aws: Randomize acc tests for Inspector Assesment Tpl (#12990)
This commit is contained in:
parent
0804c34946
commit
1fb810d1fc
@ -7,24 +7,27 @@ import (
|
|||||||
"github.com/aws/aws-sdk-go/aws"
|
"github.com/aws/aws-sdk-go/aws"
|
||||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||||
"github.com/aws/aws-sdk-go/service/inspector"
|
"github.com/aws/aws-sdk-go/service/inspector"
|
||||||
|
"github.com/hashicorp/terraform/helper/acctest"
|
||||||
"github.com/hashicorp/terraform/helper/resource"
|
"github.com/hashicorp/terraform/helper/resource"
|
||||||
"github.com/hashicorp/terraform/terraform"
|
"github.com/hashicorp/terraform/terraform"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestAccAWSInspectorTemplate_basic(t *testing.T) {
|
func TestAccAWSInspectorTemplate_basic(t *testing.T) {
|
||||||
|
rInt := acctest.RandInt()
|
||||||
|
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
Providers: testAccProviders,
|
Providers: testAccProviders,
|
||||||
CheckDestroy: testAccCheckAWSInspectorTemplateDestroy,
|
CheckDestroy: testAccCheckAWSInspectorTemplateDestroy,
|
||||||
Steps: []resource.TestStep{
|
Steps: []resource.TestStep{
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccAWSInspectorTemplateAssessment,
|
Config: testAccAWSInspectorTemplateAssessment(rInt),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckAWSInspectorTemplateExists("aws_inspector_assessment_template.foo"),
|
testAccCheckAWSInspectorTemplateExists("aws_inspector_assessment_template.foo"),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccCheckAWSInspectorTemplatetModified,
|
Config: testAccCheckAWSInspectorTemplatetModified(rInt),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckAWSInspectorTargetExists("aws_inspector_assessment_template.foo"),
|
testAccCheckAWSInspectorTargetExists("aws_inspector_assessment_template.foo"),
|
||||||
),
|
),
|
||||||
@ -74,20 +77,21 @@ func testAccCheckAWSInspectorTemplateExists(name string) resource.TestCheckFunc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var testAccAWSInspectorTemplateAssessment = `
|
func testAccAWSInspectorTemplateAssessment(rInt int) string {
|
||||||
|
return fmt.Sprintf(`
|
||||||
resource "aws_inspector_resource_group" "foo" {
|
resource "aws_inspector_resource_group" "foo" {
|
||||||
tags {
|
tags {
|
||||||
Name = "bar"
|
Name = "tf-acc-test-%d"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_inspector_assessment_target" "foo" {
|
resource "aws_inspector_assessment_target" "foo" {
|
||||||
name = "foo"
|
name = "tf-acc-test-basic-%d"
|
||||||
resource_group_arn = "${aws_inspector_resource_group.foo.arn}"
|
resource_group_arn = "${aws_inspector_resource_group.foo.arn}"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_inspector_assessment_template" "foo" {
|
resource "aws_inspector_assessment_template" "foo" {
|
||||||
name = "foo template"
|
name = "tf-acc-test-basic-tpl-%d"
|
||||||
target_arn = "${aws_inspector_assessment_target.foo.arn}"
|
target_arn = "${aws_inspector_assessment_target.foo.arn}"
|
||||||
duration = 3600
|
duration = 3600
|
||||||
|
|
||||||
@ -97,22 +101,24 @@ resource "aws_inspector_assessment_template" "foo" {
|
|||||||
"arn:aws:inspector:us-west-2:758058086616:rulespackage/0-JJOtZiqQ",
|
"arn:aws:inspector:us-west-2:758058086616:rulespackage/0-JJOtZiqQ",
|
||||||
"arn:aws:inspector:us-west-2:758058086616:rulespackage/0-vg5GGHSD",
|
"arn:aws:inspector:us-west-2:758058086616:rulespackage/0-vg5GGHSD",
|
||||||
]
|
]
|
||||||
}`
|
}`, rInt, rInt, rInt)
|
||||||
|
}
|
||||||
|
|
||||||
var testAccCheckAWSInspectorTemplatetModified = `
|
func testAccCheckAWSInspectorTemplatetModified(rInt int) string {
|
||||||
|
return fmt.Sprintf(`
|
||||||
resource "aws_inspector_resource_group" "foo" {
|
resource "aws_inspector_resource_group" "foo" {
|
||||||
tags {
|
tags {
|
||||||
Name = "bar"
|
Name = "tf-acc-test-%d"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_inspector_assessment_target" "foo" {
|
resource "aws_inspector_assessment_target" "foo" {
|
||||||
name = "foo"
|
name = "tf-acc-test-basic-%d"
|
||||||
resource_group_arn = "${aws_inspector_resource_group.foo.arn}"
|
resource_group_arn = "${aws_inspector_resource_group.foo.arn}"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_inspector_assessment_template" "foo" {
|
resource "aws_inspector_assessment_template" "foo" {
|
||||||
name = "bar template"
|
name = "tf-acc-test-basic-tpl-%d"
|
||||||
target_arn = "${aws_inspector_assessment_target.foo.arn}"
|
target_arn = "${aws_inspector_assessment_target.foo.arn}"
|
||||||
duration = 3600
|
duration = 3600
|
||||||
|
|
||||||
@ -122,4 +128,5 @@ resource "aws_inspector_assessment_template" "foo" {
|
|||||||
"arn:aws:inspector:us-west-2:758058086616:rulespackage/0-JJOtZiqQ",
|
"arn:aws:inspector:us-west-2:758058086616:rulespackage/0-JJOtZiqQ",
|
||||||
"arn:aws:inspector:us-west-2:758058086616:rulespackage/0-vg5GGHSD",
|
"arn:aws:inspector:us-west-2:758058086616:rulespackage/0-vg5GGHSD",
|
||||||
]
|
]
|
||||||
}`
|
}`, rInt, rInt, rInt)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user