Skip to content

Commit

Permalink
Refactoring the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tombuildsstuff committed Jul 4, 2017
1 parent 5a77880 commit f2182ff
Showing 1 changed file with 40 additions and 50 deletions.
90 changes: 40 additions & 50 deletions azurerm/resource_arm_servicebus_queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
)

func TestAccAzureRMServiceBusQueue_basic(t *testing.T) {
resourceName := "azurerm_servicebus_queue.test"
ri := acctest.RandInt()
config := testAccAzureRMServiceBusQueue_basic(ri)

Expand All @@ -22,20 +23,18 @@ func TestAccAzureRMServiceBusQueue_basic(t *testing.T) {
{
Config: config,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMServiceBusQueueExists("azurerm_servicebus_queue.test"),
resource.TestCheckResourceAttr(
"azurerm_servicebus_queue.test", "enable_batched_operations", "false"),
resource.TestCheckResourceAttr(
"azurerm_servicebus_queue.test", "enable_express", "false"),
resource.TestCheckResourceAttr(
"azurerm_servicebus_queue.test", "enable_partitioning", "false"),
testCheckAzureRMServiceBusQueueExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "enable_batched_operations", "false"),
resource.TestCheckResourceAttr(resourceName, "enable_express", "false"),
resource.TestCheckResourceAttr(resourceName, "enable_partitioning", "false"),
),
},
},
})
}

func TestAccAzureRMServiceBusQueue_update(t *testing.T) {
resourceName := "azurerm_servicebus_queue.test"
ri := acctest.RandInt()
preConfig := testAccAzureRMServiceBusQueue_basic(ri)
postConfig := testAccAzureRMServiceBusQueue_update(ri)
Expand All @@ -48,29 +47,25 @@ func TestAccAzureRMServiceBusQueue_update(t *testing.T) {
{
Config: preConfig,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMServiceBusQueueExists("azurerm_servicebus_queue.test"),
resource.TestCheckResourceAttr(
"azurerm_servicebus_queue.test", "enable_batched_operations", "false"),
resource.TestCheckResourceAttr(
"azurerm_servicebus_queue.test", "enable_express", "false"),
testCheckAzureRMServiceBusQueueExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "enable_batched_operations", "false"),
resource.TestCheckResourceAttr(resourceName, "enable_express", "false"),
),
},
{
Config: postConfig,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(
"azurerm_servicebus_queue.test", "enable_batched_operations", "true"),
resource.TestCheckResourceAttr(
"azurerm_servicebus_queue.test", "enable_express", "true"),
resource.TestCheckResourceAttr(
"azurerm_servicebus_queue.test", "max_size_in_megabytes", "2048"),
resource.TestCheckResourceAttr(resourceName, "enable_batched_operations", "true"),
resource.TestCheckResourceAttr(resourceName, "enable_express", "true"),
resource.TestCheckResourceAttr(resourceName, "max_size_in_megabytes", "2048"),
),
},
},
})
}

func TestAccAzureRMServiceBusQueue_enablePartitioningStandard(t *testing.T) {
resourceName := "azurerm_servicebus_queue.test"
ri := acctest.RandInt()
preConfig := testAccAzureRMServiceBusQueue_basic(ri)
postConfig := testAccAzureRMServiceBusQueue_enablePartitioningStandard(ri)
Expand All @@ -83,26 +78,24 @@ func TestAccAzureRMServiceBusQueue_enablePartitioningStandard(t *testing.T) {
{
Config: preConfig,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMServiceBusQueueExists("azurerm_servicebus_queue.test"),
resource.TestCheckResourceAttr(
"azurerm_servicebus_queue.test", "enable_partitioning", "false"),
testCheckAzureRMServiceBusQueueExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "enable_partitioning", "false"),
),
},
{
Config: postConfig,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(
"azurerm_servicebus_queue.test", "enable_partitioning", "true"),
resource.TestCheckResourceAttr(resourceName, "enable_partitioning", "true"),
// Ensure size is read back in it's original value and not the x16 value returned by Azure
resource.TestCheckResourceAttr(
"azurerm_servicebus_queue.test", "max_size_in_megabytes", "5120"),
resource.TestCheckResourceAttr(resourceName, "max_size_in_megabytes", "5120"),
),
},
},
})
}

func TestAccAzureRMServiceBusQueue_defaultEnablePartitioningPremium(t *testing.T) {
resourceName := "azurerm_servicebus_queue.test"
ri := acctest.RandInt()
config := testAccAzureRMServiceBusQueue_Premium(ri)

Expand All @@ -114,18 +107,17 @@ func TestAccAzureRMServiceBusQueue_defaultEnablePartitioningPremium(t *testing.T
{
Config: config,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMServiceBusQueueExists("azurerm_servicebus_queue.test"),
resource.TestCheckResourceAttr(
"azurerm_servicebus_queue.test", "enable_partitioning", "true"),
resource.TestCheckResourceAttr(
"azurerm_servicebus_queue.test", "enable_express", "false"),
testCheckAzureRMServiceBusQueueExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "enable_partitioning", "true"),
resource.TestCheckResourceAttr(resourceName, "enable_express", "false"),
),
},
},
})
}

func TestAccAzureRMServiceBusQueue_enableDuplicateDetection(t *testing.T) {
resourceName := "azurerm_servicebus_queue.test"
ri := acctest.RandInt()
preConfig := testAccAzureRMServiceBusQueue_basic(ri)
postConfig := testAccAzureRMServiceBusQueue_enableDuplicateDetection(ri)
Expand All @@ -138,16 +130,14 @@ func TestAccAzureRMServiceBusQueue_enableDuplicateDetection(t *testing.T) {
{
Config: preConfig,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMServiceBusQueueExists("azurerm_servicebus_queue.test"),
resource.TestCheckResourceAttr(
"azurerm_servicebus_queue.test", "requires_duplicate_detection", "false"),
testCheckAzureRMServiceBusQueueExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "requires_duplicate_detection", "false"),
),
},
{
Config: postConfig,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(
"azurerm_servicebus_queue.test", "requires_duplicate_detection", "true"),
resource.TestCheckResourceAttr(resourceName, "requires_duplicate_detection", "true"),
),
},
},
Expand Down Expand Up @@ -221,16 +211,16 @@ resource "azurerm_resource_group" "test" {
resource "azurerm_servicebus_namespace" "test" {
name = "acctestservicebusnamespace-%d"
location = "West US"
resource_group_name = "${azurerm_resource_group.test.name}"
location = "${azurerm_resource_group.test.location}"
sku = "standard"
}
resource "azurerm_servicebus_queue" "test" {
name = "acctestservicebusqueue-%d"
location = "West US"
namespace_name = "${azurerm_servicebus_namespace.test.name}"
resource_group_name = "${azurerm_resource_group.test.name}"
location = "${azurerm_resource_group.test.location}"
namespace_name = "${azurerm_servicebus_namespace.test.name}"
}
`, rInt, rInt, rInt)
}
Expand All @@ -244,16 +234,16 @@ resource "azurerm_resource_group" "test" {
resource "azurerm_servicebus_namespace" "test" {
name = "acctestservicebusnamespace-%d"
location = "West US"
resource_group_name = "${azurerm_resource_group.test.name}"
location = "${azurerm_resource_group.test.location}"
sku = "premium"
}
resource "azurerm_servicebus_queue" "test" {
name = "acctestservicebusqueue-%d"
location = "West US"
namespace_name = "${azurerm_servicebus_namespace.test.name}"
resource_group_name = "${azurerm_resource_group.test.name}"
location = "${azurerm_resource_group.test.location}"
namespace_name = "${azurerm_servicebus_namespace.test.name}"
enable_partitioning = true
enable_express = false
}
Expand All @@ -269,16 +259,16 @@ resource "azurerm_resource_group" "test" {
resource "azurerm_servicebus_namespace" "test" {
name = "acctestservicebusnamespace-%d"
location = "West US"
resource_group_name = "${azurerm_resource_group.test.name}"
location = "${azurerm_resource_group.test.location}"
sku = "standard"
}
resource "azurerm_servicebus_queue" "test" {
name = "acctestservicebusqueue-%d"
location = "West US"
namespace_name = "${azurerm_servicebus_namespace.test.name}"
resource_group_name = "${azurerm_resource_group.test.name}"
location = "${azurerm_resource_group.test.location}"
namespace_name = "${azurerm_servicebus_namespace.test.name}"
enable_batched_operations = true
enable_express = true
max_size_in_megabytes = 2048
Expand All @@ -295,16 +285,16 @@ resource "azurerm_resource_group" "test" {
resource "azurerm_servicebus_namespace" "test" {
name = "acctestservicebusnamespace-%d"
location = "West US"
resource_group_name = "${azurerm_resource_group.test.name}"
location = "${azurerm_resource_group.test.location}"
sku = "standard"
}
resource "azurerm_servicebus_queue" "test" {
name = "acctestservicebusqueue-%d"
location = "West US"
namespace_name = "${azurerm_servicebus_namespace.test.name}"
resource_group_name = "${azurerm_resource_group.test.name}"
location = "${azurerm_resource_group.test.location}"
namespace_name = "${azurerm_servicebus_namespace.test.name}"
enable_partitioning = true
max_size_in_megabytes = 5120
}
Expand All @@ -320,16 +310,16 @@ resource "azurerm_resource_group" "test" {
resource "azurerm_servicebus_namespace" "test" {
name = "acctestservicebusnamespace-%d"
location = "West US"
resource_group_name = "${azurerm_resource_group.test.name}"
location = "${azurerm_resource_group.test.location}"
sku = "standard"
}
resource "azurerm_servicebus_queue" "test" {
name = "acctestservicebusqueue-%d"
location = "West US"
namespace_name = "${azurerm_servicebus_namespace.test.name}"
resource_group_name = "${azurerm_resource_group.test.name}"
location = "${azurerm_resource_group.test.location}"
namespace_name = "${azurerm_servicebus_namespace.test.name}"
requires_duplicate_detection = true
}
`, rInt, rInt, rInt)
Expand Down

0 comments on commit f2182ff

Please sign in to comment.