Merge pull request #4980 from hashicorp/b-asm-acceptance-test-randomization
provider/azure: Randomize name in acceptance tests
This commit is contained in:
commit
c1eceb82ee
|
@ -4,6 +4,7 @@ import (
|
|||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/acctest"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
@ -11,16 +12,19 @@ import (
|
|||
func TestAccAzureHostedServiceBasic(t *testing.T) {
|
||||
name := "azure_hosted_service.foo"
|
||||
|
||||
hostedServiceName := fmt.Sprintf("terraform-testing-service%d", acctest.RandInt())
|
||||
config := fmt.Sprintf(testAccAzureHostedServiceBasic, hostedServiceName)
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckAzureHostedServiceDestroyed,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccAzureHostedServiceBasic,
|
||||
Config: config,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckAzureHostedServiceExists(name),
|
||||
resource.TestCheckResourceAttr(name, "name", "terraform-testing-service"),
|
||||
resource.TestCheckResourceAttr(name, "name", hostedServiceName),
|
||||
resource.TestCheckResourceAttr(name, "location", "North Europe"),
|
||||
resource.TestCheckResourceAttr(name, "ephemeral_contents", "false"),
|
||||
resource.TestCheckResourceAttr(name, "description", "very discriptive"),
|
||||
|
@ -34,16 +38,21 @@ func TestAccAzureHostedServiceBasic(t *testing.T) {
|
|||
func TestAccAzureHostedServiceUpdate(t *testing.T) {
|
||||
name := "azure_hosted_service.foo"
|
||||
|
||||
hostedServiceName := fmt.Sprintf("terraform-testing-service%d", acctest.RandInt())
|
||||
|
||||
basicConfig := fmt.Sprintf(testAccAzureHostedServiceBasic, hostedServiceName)
|
||||
updateConfig := fmt.Sprintf(testAccAzureHostedServiceUpdate, hostedServiceName)
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckAzureHostedServiceDestroyed,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccAzureHostedServiceBasic,
|
||||
Config: basicConfig,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckAzureHostedServiceExists(name),
|
||||
resource.TestCheckResourceAttr(name, "name", "terraform-testing-service"),
|
||||
resource.TestCheckResourceAttr(name, "name", hostedServiceName),
|
||||
resource.TestCheckResourceAttr(name, "location", "North Europe"),
|
||||
resource.TestCheckResourceAttr(name, "ephemeral_contents", "false"),
|
||||
resource.TestCheckResourceAttr(name, "description", "very discriptive"),
|
||||
|
@ -52,10 +61,10 @@ func TestAccAzureHostedServiceUpdate(t *testing.T) {
|
|||
},
|
||||
|
||||
resource.TestStep{
|
||||
Config: testAccAzureHostedServiceUpdate,
|
||||
Config: updateConfig,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckAzureHostedServiceExists(name),
|
||||
resource.TestCheckResourceAttr(name, "name", "terraform-testing-service"),
|
||||
resource.TestCheckResourceAttr(name, "name", hostedServiceName),
|
||||
resource.TestCheckResourceAttr(name, "location", "North Europe"),
|
||||
resource.TestCheckResourceAttr(name, "ephemeral_contents", "true"),
|
||||
resource.TestCheckResourceAttr(name, "description", "very discriptive"),
|
||||
|
@ -105,7 +114,7 @@ func testAccCheckAzureHostedServiceDestroyed(s *terraform.State) error {
|
|||
|
||||
const testAccAzureHostedServiceBasic = `
|
||||
resource "azure_hosted_service" "foo" {
|
||||
name = "terraform-testing-service"
|
||||
name = "%s"
|
||||
location = "North Europe"
|
||||
ephemeral_contents = false
|
||||
description = "very discriptive"
|
||||
|
@ -114,7 +123,7 @@ resource "azure_hosted_service" "foo" {
|
|||
`
|
||||
const testAccAzureHostedServiceUpdate = `
|
||||
resource "azure_hosted_service" "foo" {
|
||||
name = "terraform-testing-service"
|
||||
name = "%s"
|
||||
location = "North Europe"
|
||||
ephemeral_contents = true
|
||||
description = "very discriptive"
|
||||
|
|
|
@ -8,6 +8,7 @@ import (
|
|||
|
||||
"github.com/Azure/azure-sdk-for-go/management"
|
||||
"github.com/Azure/azure-sdk-for-go/management/virtualmachine"
|
||||
"github.com/hashicorp/terraform/helper/acctest"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
@ -46,21 +47,25 @@ func TestAccAzureInstance_basic(t *testing.T) {
|
|||
func TestAccAzureInstance_separateHostedService(t *testing.T) {
|
||||
var dpmt virtualmachine.DeploymentResponse
|
||||
|
||||
hostedServiceName := fmt.Sprintf("terraform-testing-service%d", acctest.RandInt())
|
||||
|
||||
config := fmt.Sprintf(testAccAzureInstance_separateHostedService, hostedServiceName, instanceName, testAccStorageServiceName)
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckAzureInstanceDestroyed(testAccHostedServiceName),
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccAzureInstance_separateHostedService,
|
||||
Config: config,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckAzureInstanceExists(
|
||||
"azure_instance.foo", testAccHostedServiceName, &dpmt),
|
||||
"azure_instance.foo", hostedServiceName, &dpmt),
|
||||
testAccCheckAzureInstanceBasicAttributes(&dpmt),
|
||||
resource.TestCheckResourceAttr(
|
||||
"azure_instance.foo", "name", instanceName),
|
||||
resource.TestCheckResourceAttr(
|
||||
"azure_instance.foo", "hosted_service_name", "terraform-testing-service"),
|
||||
"azure_instance.foo", "hosted_service_name", hostedServiceName),
|
||||
resource.TestCheckResourceAttr(
|
||||
"azure_instance.foo", "location", "West US"),
|
||||
resource.TestCheckResourceAttr(
|
||||
|
@ -441,7 +446,7 @@ resource "azure_instance" "foo" {
|
|||
}
|
||||
}`, instanceName, testAccStorageServiceName)
|
||||
|
||||
var testAccAzureInstance_separateHostedService = fmt.Sprintf(`
|
||||
var testAccAzureInstance_separateHostedService = `
|
||||
resource "azure_hosted_service" "foo" {
|
||||
name = "%s"
|
||||
location = "West US"
|
||||
|
@ -464,7 +469,7 @@ resource "azure_instance" "foo" {
|
|||
public_port = 22
|
||||
private_port = 22
|
||||
}
|
||||
}`, testAccHostedServiceName, instanceName, testAccStorageServiceName)
|
||||
}`
|
||||
|
||||
var testAccAzureInstance_advanced = fmt.Sprintf(`
|
||||
resource "azure_virtual_network" "foo" {
|
||||
|
|
Loading…
Reference in New Issue