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

Skip acceptance test based on error regex #15066

Closed
YakDriver opened this issue Sep 8, 2020 · 2 comments
Closed

Skip acceptance test based on error regex #15066

YakDriver opened this issue Sep 8, 2020 · 2 comments
Labels
enhancement Requests to existing resources that expand the functionality or scope. partition/aws-us-gov Pertains to the aws-us-gov partition.

Comments

@YakDriver
Copy link
Member

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Description

Enhance the acceptance testing framework TestStep to accept an error regular expression to skip a test.

New or Affected Resource(s)

  • many

Example code

Without this enhancement (note the precheck):

func TestAccAWSRDSClusterInstance_PerformanceInsightsEnabled_AuroraMysql1(t *testing.T) {
	var dbInstance rds.DBInstance
	resourceName := "aws_rds_cluster_instance.test"
	rName := acctest.RandomWithPrefix("tf-acc-test")

	resource.ParallelTest(t, resource.TestCase{
		PreCheck:     func() { testAccPreCheck(t); testAccPreCheckAWSRDSClusterInstance_performanceInsights(t) },
		Providers:    testAccProviders,
		CheckDestroy: testAccCheckAWSClusterDestroy,
		Steps: []resource.TestStep{
			{
				Config: testAccAWSClusterInstanceConfigPerformanceInsightsEnabledAuroraMysql1(rName),
				Check: resource.ComposeTestCheckFunc(
					testAccCheckAWSClusterInstanceExists(resourceName, &dbInstance),
					resource.TestCheckResourceAttr(resourceName, "performance_insights_enabled", "true"),
				),
			},
		},
	})
}

With this enhancement (note the lack of a special precheck):

func TestAccAWSRDSClusterInstance_PerformanceInsightsEnabled_AuroraMysql1(t *testing.T) {
	var dbInstance rds.DBInstance
	resourceName := "aws_rds_cluster_instance.test"
	rName := acctest.RandomWithPrefix("tf-acc-test")

	resource.ParallelTest(t, resource.TestCase{
		PreCheck:     func() { testAccPreCheck(t) },
		Providers:    testAccProviders,
		CheckDestroy: testAccCheckAWSClusterDestroy,
		Steps: []resource.TestStep{
			{
				Config: testAccAWSClusterInstanceConfigPerformanceInsightsEnabledAuroraMysql1(rName),
				Check: resource.ComposeTestCheckFunc(
					testAccCheckAWSClusterInstanceExists(resourceName, &dbInstance),
					resource.TestCheckResourceAttr(resourceName, "performance_insights_enabled", "true"),
				),
				SkipErrorRegex: "InvalidParameterCombination: Access denied to Performance Insights"
			},
		},
	})
}

References

@YakDriver YakDriver added enhancement Requests to existing resources that expand the functionality or scope. partition/aws-us-gov Pertains to the aws-us-gov partition. labels Sep 8, 2020
@YakDriver
Copy link
Member Author

This should be in the SDK. Superseded by hashicorp/terraform-plugin-sdk#568.

@ghost
Copy link

ghost commented Oct 9, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked as resolved and limited conversation to collaborators Oct 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Requests to existing resources that expand the functionality or scope. partition/aws-us-gov Pertains to the aws-us-gov partition.
Projects
None yet
Development

No branches or pull requests

1 participant