github.com/danp/terraform@v0.9.5-0.20170426144147-39d740081351/builtin/providers/azure/utils_test.go (about)

     1  package azure
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/Azure/azure-sdk-for-go/management"
     7  )
     8  
     9  // testAccResourceDestroyedErrorFilter tests whether the given error is an azure ResourceNotFound
    10  // error and properly annotates it if otherwise:
    11  func testAccResourceDestroyedErrorFilter(resource string, err error) error {
    12  	switch {
    13  	case err == nil:
    14  		return fmt.Errorf("Azure %s still exists.", resource)
    15  	case err != nil && management.IsResourceNotFoundError(err):
    16  		return nil
    17  	default:
    18  		return err
    19  	}
    20  }