Skip to content

Commit

Permalink
add test to update topic rule kafka
Browse files Browse the repository at this point in the history
  • Loading branch information
mbbush committed Aug 29, 2023
1 parent c67e7e0 commit bda97bc
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions internal/service/iot/topic_rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1115,9 +1115,6 @@ func TestAccIoTTopicRule_IoT_events_batch_mode(t *testing.T) {

func TestAccIoTTopicRule_kafka(t *testing.T) {
ctx := acctest.Context(t)
if testing.Short() {
t.Skip("skipping long-running test in short mode")
}

rName := testAccTopicRuleName()
resourceName := "aws_iot_topic_rule.test"
Expand All @@ -1129,7 +1126,7 @@ func TestAccIoTTopicRule_kafka(t *testing.T) {
CheckDestroy: testAccCheckTopicRuleDestroy(ctx),
Steps: []resource.TestStep{
{
Config: testAccTopicRuleConfig_kafka(rName),
Config: testAccTopicRuleConfig_kafka(rName, "fake_topic"),
Check: resource.ComposeTestCheckFunc(
testAccCheckTopicRuleExists(ctx, resourceName),
resource.TestCheckResourceAttr(resourceName, "cloudwatch_alarm.#", "0"),
Expand Down Expand Up @@ -1165,6 +1162,9 @@ func TestAccIoTTopicRule_kafka(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "timestream.#", "0"),
),
},
{
Config: testAccTopicRuleConfig_kafka(rName, "different_topic"),
},
{
ResourceName: resourceName,
ImportState: true,
Expand Down Expand Up @@ -2311,11 +2311,14 @@ resource "aws_iot_topic_rule" "test" {
`, rName, batchMode))
}

func testAccTopicRuleConfig_kafka(rName string) string {
func testAccTopicRuleConfig_kafka(rName string, topic string) string {
// Making a topic rule destination takes several minutes, as it requires creating many networking resources.
// It's far faster to simply use a properly-formatted but nonexistent ARN for the destination.
return acctest.ConfigCompose(
testAccTopicRuleDestinationConfig_basic(rName),
testAccTopicRuleConfig_destinationRole(rName),
fmt.Sprintf(`
data "aws_region" "current" {}
data "aws_caller_identity" "current" {}
resource "aws_iot_topic_rule" "test" {
name = %[1]q
Expand All @@ -2324,8 +2327,8 @@ resource "aws_iot_topic_rule" "test" {
sql_version = "2015-10-08"
kafka {
destination_arn = aws_iot_topic_rule_destination.test.arn
topic = "fake_topic"
destination_arn = "arn:${data.aws_partition.current.partition}:iot:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:ruledestination/vpc/pretend-this-is-a-uuid"
topic = "%s"
client_properties = {
"acks" = "1"
Expand All @@ -2339,7 +2342,7 @@ resource "aws_iot_topic_rule" "test" {
}
}
}
`, rName))
`, rName, topic))
}

func testAccTopicRuleConfig_kinesis(rName string) string {
Expand Down

0 comments on commit bda97bc

Please sign in to comment.