provider/azure: Fix up acctest destroy checks

Some resources can only be queried via the network configuration - if
the network configuration does not exist we were failing, however that
is a desirable state since without a network configuration for the
subscription the resources in question cannot exist.
This commit is contained in:
James Nugent 2016-01-05 18:56:39 -06:00
parent 96976222bb
commit 42a3800ec2
3 changed files with 15 additions and 0 deletions

View File

@ -4,6 +4,7 @@ import (
"fmt"
"testing"
"github.com/Azure/azure-sdk-for-go/management"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
)
@ -98,6 +99,10 @@ func testAccCheckAzureDnsServerDestroy(s *terraform.State) error {
netConf, err := vnetClient.GetVirtualNetworkConfiguration()
if err != nil {
// This is desirable - if there is no network config there can't be any DNS Servers
if management.IsResourceNotFoundError(err) {
continue
}
return fmt.Errorf("Error retrieving networking configuration from Azure: %s", err)
}

View File

@ -4,6 +4,7 @@ import (
"fmt"
"testing"
"github.com/Azure/azure-sdk-for-go/management"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
)
@ -109,6 +110,10 @@ func testAccAzureLocalNetworkConnectionDestroyed(s *terraform.State) error {
netConf, err := vnetClient.GetVirtualNetworkConfiguration()
if err != nil {
// This is desirable - if there is no network config there can be no gateways
if management.IsResourceNotFoundError(err) {
continue
}
return err
}

View File

@ -4,6 +4,7 @@ import (
"fmt"
"testing"
"github.com/Azure/azure-sdk-for-go/management"
"github.com/Azure/azure-sdk-for-go/management/virtualnetwork"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
@ -185,6 +186,10 @@ func testAccCheckAzureVirtualNetworkDestroy(s *terraform.State) error {
nc, err := vnetClient.GetVirtualNetworkConfiguration()
if err != nil {
if management.IsResourceNotFoundError(err) {
// This is desirable - no configuration = no networks
continue
}
return fmt.Errorf("Error retrieving Virtual Network Configuration: %s", err)
}