Skip to content

Commit

Permalink
Merge pull request hashicorp#18919 from hashicorp/t-fix-aws_sns_topic…
Browse files Browse the repository at this point in the history
…-GovCloud-FIFO-tests

tests/resource/sns_topic: Make FIFO topic tests GovCloud compatible
  • Loading branch information
ewbankkit authored Apr 19, 2021
2 parents 474178a + f646dcc commit 5c130d7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
5 changes: 3 additions & 2 deletions aws/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1067,8 +1067,9 @@ func testAccErrorCheckSkipMessagesContaining(t *testing.T, messages ...string) r
}

for _, message := range messages {
if strings.Contains(err.Error(), message) {
t.Skipf("skipping test for %s/%s: %s", testAccGetPartition(), testAccGetRegion(), err.Error())
errorMessage := err.Error()
if strings.Contains(errorMessage, message) {
t.Skipf("skipping test for %s/%s: %s", testAccGetPartition(), testAccGetRegion(), errorMessage)
}
}

Expand Down
9 changes: 1 addition & 8 deletions aws/resource_aws_sns_topic_subscription_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ func TestAccAWSSNSTopicSubscription_firehose(t *testing.T) {

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ErrorCheck: testAccErrorCheckSkipSNS(t),
ErrorCheck: testAccErrorCheck(t, sns.EndpointsID),
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSSNSTopicSubscriptionDestroy,
Steps: []resource.TestStep{
Expand Down Expand Up @@ -482,13 +482,6 @@ func TestAccAWSSNSTopicSubscription_disappears_topic(t *testing.T) {
})
}

// testAccErrorCheckSkipSNS skips SNS tests that have error messages indicating unsupported features
func testAccErrorCheckSkipSNS(t *testing.T) resource.ErrorCheckFunc {
return testAccErrorCheckSkipMessagesContaining(t,
"Invalid protocol type: firehose",
)
}

func testAccCheckAWSSNSTopicSubscriptionDestroy(s *terraform.State) error {
conn := testAccProvider.Meta().(*AWSClient).snsconn

Expand Down
9 changes: 9 additions & 0 deletions aws/resource_aws_sns_topic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import (
)

func init() {
RegisterServiceErrorCheckFunc(sns.EndpointsID, testAccErrorCheckSkipSNS)

resource.AddTestSweepers("aws_sns_topic", &resource.Sweeper{
Name: "aws_sns_topic",
F: testSweepSnsTopics,
Expand Down Expand Up @@ -88,6 +90,13 @@ func testSweepSnsTopics(region string) error {
return sweeperErrs.ErrorOrNil()
}

func testAccErrorCheckSkipSNS(t *testing.T) resource.ErrorCheckFunc {
return testAccErrorCheckSkipMessagesContaining(t,
"Invalid protocol type: firehose",
"Unknown attribute FifoTopic",
)
}

func TestAccAWSSNSTopic_basic(t *testing.T) {
attributes := make(map[string]string)
resourceName := "aws_sns_topic.test"
Expand Down

0 comments on commit 5c130d7

Please sign in to comment.