Skip to content

Commit 446afbc

Browse files
authored
provider/azurerm: Randomizing the test names for network interface card (hashicorp#10364)
1 parent 3d3609c commit 446afbc

1 file changed

Lines changed: 30 additions & 17 deletions

File tree

builtin/providers/azurerm/resource_arm_network_interface_card_test.go

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,20 @@ import (
55
"net/http"
66
"testing"
77

8+
"github.com/hashicorp/terraform/helper/acctest"
89
"github.com/hashicorp/terraform/helper/resource"
910
"github.com/hashicorp/terraform/terraform"
1011
)
1112

1213
func TestAccAzureRMNetworkInterface_basic(t *testing.T) {
14+
rInt := acctest.RandInt()
1315
resource.Test(t, resource.TestCase{
1416
PreCheck: func() { testAccPreCheck(t) },
1517
Providers: testAccProviders,
1618
CheckDestroy: testCheckAzureRMNetworkInterfaceDestroy,
1719
Steps: []resource.TestStep{
1820
{
19-
Config: testAccAzureRMNetworkInterface_basic,
21+
Config: testAccAzureRMNetworkInterface_basic(rInt),
2022
Check: resource.ComposeTestCheckFunc(
2123
testCheckAzureRMNetworkInterfaceExists("azurerm_network_interface.test"),
2224
),
@@ -26,13 +28,14 @@ func TestAccAzureRMNetworkInterface_basic(t *testing.T) {
2628
}
2729

2830
func TestAccAzureRMNetworkInterface_disappears(t *testing.T) {
31+
rInt := acctest.RandInt()
2932
resource.Test(t, resource.TestCase{
3033
PreCheck: func() { testAccPreCheck(t) },
3134
Providers: testAccProviders,
3235
CheckDestroy: testCheckAzureRMNetworkInterfaceDestroy,
3336
Steps: []resource.TestStep{
3437
{
35-
Config: testAccAzureRMNetworkInterface_basic,
38+
Config: testAccAzureRMNetworkInterface_basic(rInt),
3639
Check: resource.ComposeTestCheckFunc(
3740
testCheckAzureRMNetworkInterfaceExists("azurerm_network_interface.test"),
3841
testCheckAzureRMNetworkInterfaceDisappears("azurerm_network_interface.test"),
@@ -44,13 +47,14 @@ func TestAccAzureRMNetworkInterface_disappears(t *testing.T) {
4447
}
4548

4649
func TestAccAzureRMNetworkInterface_enableIPForwarding(t *testing.T) {
50+
rInt := acctest.RandInt()
4751
resource.Test(t, resource.TestCase{
4852
PreCheck: func() { testAccPreCheck(t) },
4953
Providers: testAccProviders,
5054
CheckDestroy: testCheckAzureRMNetworkInterfaceDestroy,
5155
Steps: []resource.TestStep{
5256
{
53-
Config: testAccAzureRMNetworkInterface_ipForwarding,
57+
Config: testAccAzureRMNetworkInterface_ipForwarding(rInt),
5458
Check: resource.ComposeTestCheckFunc(
5559
testCheckAzureRMNetworkInterfaceExists("azurerm_network_interface.test"),
5660
resource.TestCheckResourceAttr(
@@ -62,13 +66,14 @@ func TestAccAzureRMNetworkInterface_enableIPForwarding(t *testing.T) {
6266
}
6367

6468
func TestAccAzureRMNetworkInterface_withTags(t *testing.T) {
69+
rInt := acctest.RandInt()
6570
resource.Test(t, resource.TestCase{
6671
PreCheck: func() { testAccPreCheck(t) },
6772
Providers: testAccProviders,
6873
CheckDestroy: testCheckAzureRMNetworkInterfaceDestroy,
6974
Steps: []resource.TestStep{
7075
{
71-
Config: testAccAzureRMNetworkInterface_withTags,
76+
Config: testAccAzureRMNetworkInterface_withTags(rInt),
7277
Check: resource.ComposeTestCheckFunc(
7378
testCheckAzureRMNetworkInterfaceExists("azurerm_network_interface.test"),
7479
resource.TestCheckResourceAttr(
@@ -80,7 +85,7 @@ func TestAccAzureRMNetworkInterface_withTags(t *testing.T) {
8085
),
8186
},
8287
{
83-
Config: testAccAzureRMNetworkInterface_withTagsUpdate,
88+
Config: testAccAzureRMNetworkInterface_withTagsUpdate(rInt),
8489
Check: resource.ComposeTestCheckFunc(
8590
testCheckAzureRMNetworkInterfaceExists("azurerm_network_interface.test"),
8691
resource.TestCheckResourceAttr(
@@ -201,9 +206,10 @@ func testCheckAzureRMNetworkInterfaceDestroy(s *terraform.State) error {
201206
return nil
202207
}
203208

204-
var testAccAzureRMNetworkInterface_basic = `
209+
func testAccAzureRMNetworkInterface_basic(rInt int) string {
210+
return fmt.Sprintf(`
205211
resource "azurerm_resource_group" "test" {
206-
name = "acceptanceTestResourceGroup1"
212+
name = "acctest-rg-%d"
207213
location = "West US"
208214
}
209215
@@ -232,11 +238,13 @@ resource "azurerm_network_interface" "test" {
232238
private_ip_address_allocation = "dynamic"
233239
}
234240
}
235-
`
241+
`, rInt)
242+
}
236243

237-
var testAccAzureRMNetworkInterface_ipForwarding = `
244+
func testAccAzureRMNetworkInterface_ipForwarding(rInt int) string {
245+
return fmt.Sprintf(`
238246
resource "azurerm_resource_group" "test" {
239-
name = "acceptanceTestResourceGroup1"
247+
name = "acctest-rg-%d"
240248
location = "West US"
241249
}
242250
@@ -266,11 +274,13 @@ resource "azurerm_network_interface" "test" {
266274
private_ip_address_allocation = "dynamic"
267275
}
268276
}
269-
`
277+
`, rInt)
278+
}
270279

271-
var testAccAzureRMNetworkInterface_withTags = `
280+
func testAccAzureRMNetworkInterface_withTags(rInt int) string {
281+
return fmt.Sprintf(`
272282
resource "azurerm_resource_group" "test" {
273-
name = "acceptanceTestResourceGroup1"
283+
name = "acctest-rg-%d"
274284
location = "West US"
275285
}
276286
@@ -304,11 +314,13 @@ resource "azurerm_network_interface" "test" {
304314
cost_center = "MSFT"
305315
}
306316
}
307-
`
317+
`, rInt)
318+
}
308319

309-
var testAccAzureRMNetworkInterface_withTagsUpdate = `
320+
func testAccAzureRMNetworkInterface_withTagsUpdate(rInt int) string {
321+
return fmt.Sprintf(`
310322
resource "azurerm_resource_group" "test" {
311-
name = "acceptanceTestResourceGroup1"
323+
name = "acctest-rg-%d"
312324
location = "West US"
313325
}
314326
@@ -341,7 +353,8 @@ resource "azurerm_network_interface" "test" {
341353
environment = "staging"
342354
}
343355
}
344-
`
356+
`, rInt)
357+
}
345358

346359
//TODO: Re-enable this test when https://github.com/Azure/azure-sdk-for-go/issues/259 is fixed
347360
//var testAccAzureRMNetworkInterface_extraIpConfiguration = `

0 commit comments

Comments
 (0)