Skip to content

Commit

Permalink
resource/servicebus_subscription: Allow the setting of default_messag…
Browse files Browse the repository at this point in the history
…e_ttl

Fixes: #1566

This wasn't being passed to the Create func even though the user could
define it
  • Loading branch information
stack72 committed Jul 13, 2018
1 parent 854521d commit 66e9076
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
4 changes: 4 additions & 0 deletions azurerm/resource_arm_servicebus_subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ func resourceArmServiceBusSubscriptionCreate(d *schema.ResourceData, meta interf
parameters.SBSubscriptionProperties.ForwardTo = &forwardTo
}

if defaultMessageTtl := d.Get("default_message_ttl").(string); defaultMessageTtl != "" {
parameters.DefaultMessageTimeToLive = &defaultMessageTtl
}

_, err := client.CreateOrUpdate(ctx, resourceGroup, namespaceName, topicName, name, parameters)
if err != nil {
return err
Expand Down
25 changes: 25 additions & 0 deletions azurerm/resource_arm_servicebus_subscription_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,26 @@ func TestAccAzureRMServiceBusSubscription_basic(t *testing.T) {
})
}

func TestAccAzureRMServiceBusSubscription_defaultTtl(t *testing.T) {
ri := acctest.RandInt()
config := testAccAzureRMServiceBusSubscription_withDefaultTtl(ri, testLocation())

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMServiceBusTopicDestroy,
Steps: []resource.TestStep{
{
Config: config,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMServiceBusSubscriptionExists("azurerm_servicebus_subscription.test"),
resource.TestCheckResourceAttr("azurerm_servicebus_subscription.test", "default_message_ttl", "PT1H"),
),
},
},
})
}

func TestAccAzureRMServiceBusSubscription_updateEnableBatched(t *testing.T) {
resourceName := "azurerm_servicebus_subscription.test"
ri := acctest.RandInt()
Expand Down Expand Up @@ -211,6 +231,11 @@ func testAccAzureRMServiceBusSubscription_basic(rInt int, location string) strin
return fmt.Sprintf(testAccAzureRMServiceBusSubscription_tfTemplate, rInt, location, rInt, rInt, rInt, "")
}

func testAccAzureRMServiceBusSubscription_withDefaultTtl(rInt int, location string) string {
return fmt.Sprintf(testAccAzureRMServiceBusSubscription_tfTemplate, rInt, location, rInt, rInt, rInt,
"default_message_ttl = \"PT1H\"\n")
}

func testAccAzureRMServiceBusSubscription_updateEnableBatched(rInt int, location string) string {
return fmt.Sprintf(testAccAzureRMServiceBusSubscription_tfTemplate, rInt, location, rInt, rInt, rInt,
"enable_batched_operations = true\n")
Expand Down

0 comments on commit 66e9076

Please sign in to comment.