github.com/acm1/terraform@v0.6.2-0.20150729164239-1f314444f45c/builtin/providers/azure/provider_test.go (about)

     1  package azure
     2  
     3  import (
     4  	"os"
     5  	"testing"
     6  
     7  	"github.com/hashicorp/terraform/helper/schema"
     8  	"github.com/hashicorp/terraform/terraform"
     9  )
    10  
    11  var testAccProviders map[string]terraform.ResourceProvider
    12  var testAccProvider *schema.Provider
    13  
    14  const (
    15  	testAccSecurityGroupName = "terraform-security-group"
    16  	testAccHostedServiceName = "terraform-testing-service"
    17  )
    18  
    19  // testAccStorageServiceName is used as the name for the Storage Service
    20  // created in all storage-related tests.
    21  // It is much more convenient to provide a Storage Service which
    22  // has been created beforehand as the creation of one takes a lot
    23  // and would greatly impede the multitude of tests which rely on one.
    24  // NOTE: the storage container should be located in `West US`.
    25  var testAccStorageServiceName = os.Getenv("AZURE_STORAGE")
    26  
    27  const testAccStorageContainerName = "terraform-testing-container"
    28  
    29  func init() {
    30  	testAccProvider = Provider().(*schema.Provider)
    31  	testAccProviders = map[string]terraform.ResourceProvider{
    32  		"azure": testAccProvider,
    33  	}
    34  }
    35  
    36  func TestProvider(t *testing.T) {
    37  	if err := Provider().(*schema.Provider).InternalValidate(); err != nil {
    38  		t.Fatalf("err: %s", err)
    39  	}
    40  }
    41  
    42  func TestProvider_impl(t *testing.T) {
    43  	var _ terraform.ResourceProvider = Provider()
    44  }
    45  
    46  func testAccPreCheck(t *testing.T) {
    47  	if v := os.Getenv("AZURE_SETTINGS_FILE"); v == "" {
    48  		subscriptionID := os.Getenv("AZURE_SUBSCRIPTION_ID")
    49  		certificate := os.Getenv("AZURE_CERTIFICATE")
    50  
    51  		if subscriptionID == "" || certificate == "" {
    52  			t.Fatal("either AZURE_SETTINGS_FILE, or AZURE_SUBSCRIPTION_ID " +
    53  				"and AZURE_CERTIFICATE must be set for acceptance tests")
    54  		}
    55  	}
    56  
    57  	if v := os.Getenv("AZURE_STORAGE"); v == "" {
    58  		t.Fatal("AZURE_STORAGE must be set for acceptance tests")
    59  	}
    60  }