Skip to content

Commit

Permalink
Add timespan test cases according to issue #646
Browse files Browse the repository at this point in the history
  • Loading branch information
Junyi Yi committed Sep 13, 2018
1 parent bce918a commit 5a31a39
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 0 deletions.
50 changes: 50 additions & 0 deletions azurerm/resource_arm_servicebus_queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,30 @@ func TestAccAzureRMServiceBusQueue_lockDuration(t *testing.T) {
})
}

func TestAccAzureRMServiceBusQueue_isoTimeSpanAttributes(t *testing.T) {
resourceName := "azurerm_servicebus_queue.test"
ri := acctest.RandInt()
config := testAccAzureRMServiceBusQueue_isoTimeSpanAttributes(ri, testLocation())

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMServiceBusQueueDestroy,
Steps: []resource.TestStep{
{
Config: config,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMServiceBusQueueExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "auto_delete_on_idle", "00:10:00"),
resource.TestCheckResourceAttr(resourceName, "default_message_ttl", "00:30:00"),
resource.TestCheckResourceAttr(resourceName, "requires_duplicate_detection", "true"),
resource.TestCheckResourceAttr(resourceName, "duplicate_detection_history_time_window", "00:15:00"),
),
},
},
})
}

func testCheckAzureRMServiceBusQueueDestroy(s *terraform.State) error {
client := testAccProvider.Meta().(*ArmClient).serviceBusQueuesClient
ctx := testAccProvider.Meta().(*ArmClient).StopContext
Expand Down Expand Up @@ -501,3 +525,29 @@ resource "azurerm_servicebus_queue" "test" {
}
`, rInt, location, rInt, rInt)
}

func testAccAzureRMServiceBusQueue_isoTimeSpanAttributes(rInt int, location string) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
location = "%s"
}
resource "azurerm_servicebus_namespace" "test" {
name = "acctestservicebusnamespace-%d"
resource_group_name = "${azurerm_resource_group.test.name}"
location = "${azurerm_resource_group.test.location}"
sku = "standard"
}
resource "azurerm_servicebus_queue" "test" {
name = "acctestservicebusqueue-%d"
resource_group_name = "${azurerm_resource_group.test.name}"
namespace_name = "${azurerm_servicebus_namespace.test.name}"
auto_delete_on_idle = "00:10:00"
default_message_ttl = "00:30:00"
requires_duplicate_detection = true
duplicate_detection_history_time_window = "00:15:00"
}
`, rInt, location, rInt, rInt)
}
50 changes: 50 additions & 0 deletions azurerm/resource_arm_servicebus_topic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,30 @@ func TestAccAzureRMServiceBusTopic_enableDuplicateDetection(t *testing.T) {
})
}

func TestAccAzureRMServiceBusTopic_isoTimeSpanAttributes(t *testing.T) {
resourceName := "azurerm_servicebus_topic.test"
ri := acctest.RandInt()
config := testAccAzureRMServiceBusTopic_isoTimeSpanAttributes(ri, testLocation())

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMServiceBusTopicDestroy,
Steps: []resource.TestStep{
{
Config: config,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMServiceBusTopicExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "auto_delete_on_idle", "00:10:00"),
resource.TestCheckResourceAttr(resourceName, "default_message_ttl", "00:30:00"),
resource.TestCheckResourceAttr(resourceName, "requires_duplicate_detection", "true"),
resource.TestCheckResourceAttr(resourceName, "duplicate_detection_history_time_window", "00:15:00"),
),
},
},
})
}

func testCheckAzureRMServiceBusTopicDestroy(s *terraform.State) error {
client := testAccProvider.Meta().(*ArmClient).serviceBusTopicsClient
ctx := testAccProvider.Meta().(*ArmClient).StopContext
Expand Down Expand Up @@ -425,3 +449,29 @@ resource "azurerm_servicebus_topic" "test" {
}
`, rInt, location, rInt, rInt)
}

func testAccAzureRMServiceBusTopic_isoTimeSpanAttributes(rInt int, location string) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
location = "%s"
}
resource "azurerm_servicebus_namespace" "test" {
name = "acctestservicebusnamespace-%d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
sku = "standard"
}
resource "azurerm_servicebus_topic" "test" {
name = "acctestservicebustopic-%d"
namespace_name = "${azurerm_servicebus_namespace.test.name}"
resource_group_name = "${azurerm_resource_group.test.name}"
auto_delete_on_idle = "00:10:00"
default_message_ttl = "00:30:00"
requires_duplicate_detection = true
duplicate_detection_history_time_window = "00:15:00"
}
`, rInt, location, rInt, rInt)
}

0 comments on commit 5a31a39

Please sign in to comment.