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

V2 ImportState Testing Ignoring ExpectError #532

Closed
bflad opened this issue Aug 11, 2020 · 1 comment · Fixed by #550
Closed

V2 ImportState Testing Ignoring ExpectError #532

bflad opened this issue Aug 11, 2020 · 1 comment · Fixed by #550
Labels
bug Something isn't working

Comments

@bflad
Copy link
Contributor

bflad commented Aug 11, 2020

SDK version

v2.0.1

Relevant provider source code

func TestAccAWSKinesisFirehoseDeliveryStream_basic(t *testing.T) {
	resourceName := "aws_kinesis_firehose_delivery_stream.test"
	rInt := acctest.RandInt()

	funcName := fmt.Sprintf("aws_kinesis_firehose_ds_import_%d", rInt)
	policyName := fmt.Sprintf("tf_acc_policy_%d", rInt)
	roleName := fmt.Sprintf("tf_acc_role_%d", rInt)
	var stream firehose.DeliveryStreamDescription

	config := testAccFirehoseAWSLambdaConfigBasic(funcName, policyName, roleName) +
		fmt.Sprintf(testAccKinesisFirehoseDeliveryStreamConfig_extendedS3basic,
			rInt, rInt, rInt, rInt)

	resource.ParallelTest(t, resource.TestCase{
		PreCheck:     func() { testAccPreCheck(t) },
		Providers:    testAccProviders,
		CheckDestroy: testAccCheckKinesisFirehoseDeliveryStreamDestroy,
		Steps: []resource.TestStep{
			{
				Config: config,
				Check: resource.ComposeTestCheckFunc(
					testAccCheckKinesisFirehoseDeliveryStreamExists(resourceName, &stream),
					testAccCheckAWSKinesisFirehoseDeliveryStreamAttributes(&stream, nil, nil, nil, nil, nil),
				),
			},
			{
				ResourceName:      resourceName,
				ImportState:       true,
				ImportStateVerify: true,
			},
			// Ensure we properly error on malformed import IDs
			{
				ResourceName:  resourceName,
				ImportState:   true,
				ImportStateId: "just-a-name",
				ExpectError:   regexp.MustCompile(`Expected ID in format`),
			},
			{
				ResourceName:  resourceName,
				ImportState:   true,
				ImportStateId: "arn:aws:firehose:us-east-1:123456789012:missing-slash",
				ExpectError:   regexp.MustCompile(`Expected ID in format`),
			},
		},
	})
}

Terraform Configuration Files

Please see the Terraform AWS Provider repository, but presumably this would happen with any resource configuration and ImportState + ExpectError defined.

Debug Output

Please ask if you need it.

Expected Behavior

ExpectError passes when import error message matches regular expression, which was the behavior in SDK v1. Otherwise this change to be documented in the SDK v2 upgrade guide.

Actual Behavior

=== CONT  TestAccAWSKinesisFirehoseDeliveryStream_basic
    TestAccAWSKinesisFirehoseDeliveryStream_basic: testing_new_import_state.go:74: failed to import: terraform failed: exit status 1

        stderr:

        Error: Expected ID in format of arn:PARTITION:firehose:REGION:ACCOUNTID:deliverystream/NAME and provided: just-a-name



--- FAIL: TestAccAWSKinesisFirehoseDeliveryStream_basic (101.43s)

Steps to Reproduce

  1. TF_ACC=1 go test ./aws -v -count 1 -timeout 120m -parallel 20 -run='TestAccAWSKinesisFirehoseDeliveryStream_basic'
@ghost
Copy link

ghost commented Oct 11, 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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked as resolved and limited conversation to collaborators Oct 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant