From f4cf4e89e87cb263ffdae8d409c77cfe308c5c0e Mon Sep 17 00:00:00 2001 From: James Nugent Date: Fri, 8 Jan 2016 08:08:03 -0800 Subject: [PATCH] provider/azure: Fix acceptance test --- .../azure/resource_azure_instance_test.go | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/builtin/providers/azure/resource_azure_instance_test.go b/builtin/providers/azure/resource_azure_instance_test.go index acee634f5..43f7684fa 100644 --- a/builtin/providers/azure/resource_azure_instance_test.go +++ b/builtin/providers/azure/resource_azure_instance_test.go @@ -273,6 +273,63 @@ func testAccCheckAzureInstanceAdvancedAttributes( } } +func testAccCheckAzureInstanceAdvancedUpdatedAttributes( + dpmt *virtualmachine.DeploymentResponse) resource.TestCheckFunc { + return func(s *terraform.State) error { + + if dpmt.Name != "terraform-test1" { + return fmt.Errorf("Bad name: %s", dpmt.Name) + } + + if dpmt.VirtualNetworkName != "terraform-vnet-update-test" { + return fmt.Errorf("Bad virtual network: %s", dpmt.VirtualNetworkName) + } + + if len(dpmt.RoleList) != 1 { + return fmt.Errorf( + "Instance %s has an unexpected number of roles: %d", dpmt.Name, len(dpmt.RoleList)) + } + + if dpmt.RoleList[0].RoleSize != "Basic_A1" { + return fmt.Errorf("Bad size: %s", dpmt.RoleList[0].RoleSize) + } + + for _, c := range dpmt.RoleList[0].ConfigurationSets { + if c.ConfigurationSetType == virtualmachine.ConfigurationSetTypeNetwork { + if len(c.InputEndpoints) != 1 { + return fmt.Errorf( + "Instance %s has an unexpected number of endpoints %d", + dpmt.Name, len(c.InputEndpoints)) + } + + if c.InputEndpoints[0].Name != "RDP" { + return fmt.Errorf("Bad endpoint name: %s", c.InputEndpoints[0].Name) + } + + if c.InputEndpoints[0].Port != 3389 { + return fmt.Errorf("Bad endpoint port: %d", c.InputEndpoints[0].Port) + } + + if len(c.SubnetNames) != 1 { + return fmt.Errorf( + "Instance %s has an unexpected number of associated subnets %d", + dpmt.Name, len(c.SubnetNames)) + } + + if c.SubnetNames[0] != "subnet1" { + return fmt.Errorf("Bad subnet: %s", c.SubnetNames[0]) + } + + if c.NetworkSecurityGroup != "terraform-security-group1" { + return fmt.Errorf("Bad security group: %s", c.NetworkSecurityGroup) + } + } + } + + return nil + } +} + func testAccCheckAzureInstanceUpdatedAttributes( dpmt *virtualmachine.DeploymentResponse) resource.TestCheckFunc { return func(s *terraform.State) error {