@@ -4,23 +4,27 @@ import (
44 "fmt"
55 "testing"
66
7+ "github.com/hashicorp/terraform/helper/acctest"
78 "github.com/hashicorp/terraform/helper/resource"
89 "github.com/hashicorp/terraform/terraform"
910)
1011
1112func TestAccAzureHostedServiceBasic (t * testing.T ) {
1213 name := "azure_hosted_service.foo"
1314
15+ hostedServiceName := fmt .Sprintf ("terraform-testing-service%d" , acctest .RandInt ())
16+ config := fmt .Sprintf (testAccAzureHostedServiceBasic , hostedServiceName )
17+
1418 resource .Test (t , resource.TestCase {
1519 PreCheck : func () { testAccPreCheck (t ) },
1620 Providers : testAccProviders ,
1721 CheckDestroy : testAccCheckAzureHostedServiceDestroyed ,
1822 Steps : []resource.TestStep {
1923 resource.TestStep {
20- Config : testAccAzureHostedServiceBasic ,
24+ Config : config ,
2125 Check : resource .ComposeTestCheckFunc (
2226 testAccCheckAzureHostedServiceExists (name ),
23- resource .TestCheckResourceAttr (name , "name" , "terraform-testing-service" ),
27+ resource .TestCheckResourceAttr (name , "name" , hostedServiceName ),
2428 resource .TestCheckResourceAttr (name , "location" , "North Europe" ),
2529 resource .TestCheckResourceAttr (name , "ephemeral_contents" , "false" ),
2630 resource .TestCheckResourceAttr (name , "description" , "very discriptive" ),
@@ -34,16 +38,21 @@ func TestAccAzureHostedServiceBasic(t *testing.T) {
3438func TestAccAzureHostedServiceUpdate (t * testing.T ) {
3539 name := "azure_hosted_service.foo"
3640
41+ hostedServiceName := fmt .Sprintf ("terraform-testing-service%d" , acctest .RandInt ())
42+
43+ basicConfig := fmt .Sprintf (testAccAzureHostedServiceBasic , hostedServiceName )
44+ updateConfig := fmt .Sprintf (testAccAzureHostedServiceUpdate , hostedServiceName )
45+
3746 resource .Test (t , resource.TestCase {
3847 PreCheck : func () { testAccPreCheck (t ) },
3948 Providers : testAccProviders ,
4049 CheckDestroy : testAccCheckAzureHostedServiceDestroyed ,
4150 Steps : []resource.TestStep {
4251 resource.TestStep {
43- Config : testAccAzureHostedServiceBasic ,
52+ Config : basicConfig ,
4453 Check : resource .ComposeTestCheckFunc (
4554 testAccCheckAzureHostedServiceExists (name ),
46- resource .TestCheckResourceAttr (name , "name" , "terraform-testing-service" ),
55+ resource .TestCheckResourceAttr (name , "name" , hostedServiceName ),
4756 resource .TestCheckResourceAttr (name , "location" , "North Europe" ),
4857 resource .TestCheckResourceAttr (name , "ephemeral_contents" , "false" ),
4958 resource .TestCheckResourceAttr (name , "description" , "very discriptive" ),
@@ -52,10 +61,10 @@ func TestAccAzureHostedServiceUpdate(t *testing.T) {
5261 },
5362
5463 resource.TestStep {
55- Config : testAccAzureHostedServiceUpdate ,
64+ Config : updateConfig ,
5665 Check : resource .ComposeTestCheckFunc (
5766 testAccCheckAzureHostedServiceExists (name ),
58- resource .TestCheckResourceAttr (name , "name" , "terraform-testing-service" ),
67+ resource .TestCheckResourceAttr (name , "name" , hostedServiceName ),
5968 resource .TestCheckResourceAttr (name , "location" , "North Europe" ),
6069 resource .TestCheckResourceAttr (name , "ephemeral_contents" , "true" ),
6170 resource .TestCheckResourceAttr (name , "description" , "very discriptive" ),
@@ -105,7 +114,7 @@ func testAccCheckAzureHostedServiceDestroyed(s *terraform.State) error {
105114
106115const testAccAzureHostedServiceBasic = `
107116resource "azure_hosted_service" "foo" {
108- name = "terraform-testing-service "
117+ name = "%s "
109118 location = "North Europe"
110119 ephemeral_contents = false
111120 description = "very discriptive"
@@ -114,7 +123,7 @@ resource "azure_hosted_service" "foo" {
114123`
115124const testAccAzureHostedServiceUpdate = `
116125resource "azure_hosted_service" "foo" {
117- name = "terraform-testing-service "
126+ name = "%s "
118127 location = "North Europe"
119128 ephemeral_contents = true
120129 description = "very discriptive"
0 commit comments