provider/azurerm: Randomizing the test names for network interface card (#10364)

This commit is contained in:
Paul Stack 2016-11-25 14:34:05 +00:00 committed by GitHub
parent 3d3609c271
commit 446afbc241

View File

@ -5,18 +5,20 @@ import (
"net/http" "net/http"
"testing" "testing"
"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform" "github.com/hashicorp/terraform/terraform"
) )
func TestAccAzureRMNetworkInterface_basic(t *testing.T) { func TestAccAzureRMNetworkInterface_basic(t *testing.T) {
rInt := acctest.RandInt()
resource.Test(t, resource.TestCase{ resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
CheckDestroy: testCheckAzureRMNetworkInterfaceDestroy, CheckDestroy: testCheckAzureRMNetworkInterfaceDestroy,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
{ {
Config: testAccAzureRMNetworkInterface_basic, Config: testAccAzureRMNetworkInterface_basic(rInt),
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
testCheckAzureRMNetworkInterfaceExists("azurerm_network_interface.test"), testCheckAzureRMNetworkInterfaceExists("azurerm_network_interface.test"),
), ),
@ -26,13 +28,14 @@ func TestAccAzureRMNetworkInterface_basic(t *testing.T) {
} }
func TestAccAzureRMNetworkInterface_disappears(t *testing.T) { func TestAccAzureRMNetworkInterface_disappears(t *testing.T) {
rInt := acctest.RandInt()
resource.Test(t, resource.TestCase{ resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
CheckDestroy: testCheckAzureRMNetworkInterfaceDestroy, CheckDestroy: testCheckAzureRMNetworkInterfaceDestroy,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
{ {
Config: testAccAzureRMNetworkInterface_basic, Config: testAccAzureRMNetworkInterface_basic(rInt),
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
testCheckAzureRMNetworkInterfaceExists("azurerm_network_interface.test"), testCheckAzureRMNetworkInterfaceExists("azurerm_network_interface.test"),
testCheckAzureRMNetworkInterfaceDisappears("azurerm_network_interface.test"), testCheckAzureRMNetworkInterfaceDisappears("azurerm_network_interface.test"),
@ -44,13 +47,14 @@ func TestAccAzureRMNetworkInterface_disappears(t *testing.T) {
} }
func TestAccAzureRMNetworkInterface_enableIPForwarding(t *testing.T) { func TestAccAzureRMNetworkInterface_enableIPForwarding(t *testing.T) {
rInt := acctest.RandInt()
resource.Test(t, resource.TestCase{ resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
CheckDestroy: testCheckAzureRMNetworkInterfaceDestroy, CheckDestroy: testCheckAzureRMNetworkInterfaceDestroy,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
{ {
Config: testAccAzureRMNetworkInterface_ipForwarding, Config: testAccAzureRMNetworkInterface_ipForwarding(rInt),
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
testCheckAzureRMNetworkInterfaceExists("azurerm_network_interface.test"), testCheckAzureRMNetworkInterfaceExists("azurerm_network_interface.test"),
resource.TestCheckResourceAttr( resource.TestCheckResourceAttr(
@ -62,13 +66,14 @@ func TestAccAzureRMNetworkInterface_enableIPForwarding(t *testing.T) {
} }
func TestAccAzureRMNetworkInterface_withTags(t *testing.T) { func TestAccAzureRMNetworkInterface_withTags(t *testing.T) {
rInt := acctest.RandInt()
resource.Test(t, resource.TestCase{ resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
CheckDestroy: testCheckAzureRMNetworkInterfaceDestroy, CheckDestroy: testCheckAzureRMNetworkInterfaceDestroy,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
{ {
Config: testAccAzureRMNetworkInterface_withTags, Config: testAccAzureRMNetworkInterface_withTags(rInt),
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
testCheckAzureRMNetworkInterfaceExists("azurerm_network_interface.test"), testCheckAzureRMNetworkInterfaceExists("azurerm_network_interface.test"),
resource.TestCheckResourceAttr( resource.TestCheckResourceAttr(
@ -80,7 +85,7 @@ func TestAccAzureRMNetworkInterface_withTags(t *testing.T) {
), ),
}, },
{ {
Config: testAccAzureRMNetworkInterface_withTagsUpdate, Config: testAccAzureRMNetworkInterface_withTagsUpdate(rInt),
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
testCheckAzureRMNetworkInterfaceExists("azurerm_network_interface.test"), testCheckAzureRMNetworkInterfaceExists("azurerm_network_interface.test"),
resource.TestCheckResourceAttr( resource.TestCheckResourceAttr(
@ -201,9 +206,10 @@ func testCheckAzureRMNetworkInterfaceDestroy(s *terraform.State) error {
return nil return nil
} }
var testAccAzureRMNetworkInterface_basic = ` func testAccAzureRMNetworkInterface_basic(rInt int) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" { resource "azurerm_resource_group" "test" {
name = "acceptanceTestResourceGroup1" name = "acctest-rg-%d"
location = "West US" location = "West US"
} }
@ -232,11 +238,13 @@ resource "azurerm_network_interface" "test" {
private_ip_address_allocation = "dynamic" private_ip_address_allocation = "dynamic"
} }
} }
` `, rInt)
}
var testAccAzureRMNetworkInterface_ipForwarding = ` func testAccAzureRMNetworkInterface_ipForwarding(rInt int) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" { resource "azurerm_resource_group" "test" {
name = "acceptanceTestResourceGroup1" name = "acctest-rg-%d"
location = "West US" location = "West US"
} }
@ -266,11 +274,13 @@ resource "azurerm_network_interface" "test" {
private_ip_address_allocation = "dynamic" private_ip_address_allocation = "dynamic"
} }
} }
` `, rInt)
}
var testAccAzureRMNetworkInterface_withTags = ` func testAccAzureRMNetworkInterface_withTags(rInt int) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" { resource "azurerm_resource_group" "test" {
name = "acceptanceTestResourceGroup1" name = "acctest-rg-%d"
location = "West US" location = "West US"
} }
@ -304,11 +314,13 @@ resource "azurerm_network_interface" "test" {
cost_center = "MSFT" cost_center = "MSFT"
} }
} }
` `, rInt)
}
var testAccAzureRMNetworkInterface_withTagsUpdate = ` func testAccAzureRMNetworkInterface_withTagsUpdate(rInt int) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" { resource "azurerm_resource_group" "test" {
name = "acceptanceTestResourceGroup1" name = "acctest-rg-%d"
location = "West US" location = "West US"
} }
@ -341,7 +353,8 @@ resource "azurerm_network_interface" "test" {
environment = "staging" environment = "staging"
} }
} }
` `, rInt)
}
//TODO: Re-enable this test when https://github.com/Azure/azure-sdk-for-go/issues/259 is fixed //TODO: Re-enable this test when https://github.com/Azure/azure-sdk-for-go/issues/259 is fixed
//var testAccAzureRMNetworkInterface_extraIpConfiguration = ` //var testAccAzureRMNetworkInterface_extraIpConfiguration = `