Skip to content

Commit 42a3800

Browse files
committed
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.
1 parent 9697622 commit 42a3800

3 files changed

Lines changed: 15 additions & 0 deletions

File tree

builtin/providers/azure/resource_azure_dns_server_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"testing"
66

7+
"github.com/Azure/azure-sdk-for-go/management"
78
"github.com/hashicorp/terraform/helper/resource"
89
"github.com/hashicorp/terraform/terraform"
910
)
@@ -98,6 +99,10 @@ func testAccCheckAzureDnsServerDestroy(s *terraform.State) error {
9899

99100
netConf, err := vnetClient.GetVirtualNetworkConfiguration()
100101
if err != nil {
102+
// This is desirable - if there is no network config there can't be any DNS Servers
103+
if management.IsResourceNotFoundError(err) {
104+
continue
105+
}
101106
return fmt.Errorf("Error retrieving networking configuration from Azure: %s", err)
102107
}
103108

builtin/providers/azure/resource_azure_local_network_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"testing"
66

7+
"github.com/Azure/azure-sdk-for-go/management"
78
"github.com/hashicorp/terraform/helper/resource"
89
"github.com/hashicorp/terraform/terraform"
910
)
@@ -109,6 +110,10 @@ func testAccAzureLocalNetworkConnectionDestroyed(s *terraform.State) error {
109110

110111
netConf, err := vnetClient.GetVirtualNetworkConfiguration()
111112
if err != nil {
113+
// This is desirable - if there is no network config there can be no gateways
114+
if management.IsResourceNotFoundError(err) {
115+
continue
116+
}
112117
return err
113118
}
114119

builtin/providers/azure/resource_azure_virtual_network_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"testing"
66

7+
"github.com/Azure/azure-sdk-for-go/management"
78
"github.com/Azure/azure-sdk-for-go/management/virtualnetwork"
89
"github.com/hashicorp/terraform/helper/resource"
910
"github.com/hashicorp/terraform/terraform"
@@ -185,6 +186,10 @@ func testAccCheckAzureVirtualNetworkDestroy(s *terraform.State) error {
185186

186187
nc, err := vnetClient.GetVirtualNetworkConfiguration()
187188
if err != nil {
189+
if management.IsResourceNotFoundError(err) {
190+
// This is desirable - no configuration = no networks
191+
continue
192+
}
188193
return fmt.Errorf("Error retrieving Virtual Network Configuration: %s", err)
189194
}
190195

0 commit comments

Comments
 (0)