github.com/leeprovoost/terraform@v0.6.10-0.20160119085442-96f3f76118e7/builtin/providers/google/provider_test.go (about)

     1  package google
     2  
     3  import (
     4  	"io/ioutil"
     5  	"os"
     6  	"testing"
     7  
     8  	"github.com/hashicorp/terraform/helper/schema"
     9  	"github.com/hashicorp/terraform/terraform"
    10  )
    11  
    12  var testAccProviders map[string]terraform.ResourceProvider
    13  var testAccProvider *schema.Provider
    14  
    15  func init() {
    16  	testAccProvider = Provider().(*schema.Provider)
    17  	testAccProviders = map[string]terraform.ResourceProvider{
    18  		"google": testAccProvider,
    19  	}
    20  }
    21  
    22  func TestProvider(t *testing.T) {
    23  	if err := Provider().(*schema.Provider).InternalValidate(); err != nil {
    24  		t.Fatalf("err: %s", err)
    25  	}
    26  }
    27  
    28  func TestProvider_impl(t *testing.T) {
    29  	var _ terraform.ResourceProvider = Provider()
    30  }
    31  
    32  func testAccPreCheck(t *testing.T) {
    33  	if v := os.Getenv("GOOGLE_CREDENTIALS_FILE"); v != "" {
    34  		creds, err := ioutil.ReadFile(v)
    35  		if err != nil {
    36  			t.Fatalf("Error reading GOOGLE_CREDENTIALS_FILE path: %s", err)
    37  		}
    38  		os.Setenv("GOOGLE_CREDENTIALS", string(creds))
    39  	}
    40  
    41  	if v := os.Getenv("GOOGLE_CREDENTIALS"); v == "" {
    42  		t.Fatal("GOOGLE_CREDENTIALS must be set for acceptance tests")
    43  	}
    44  
    45  	if v := os.Getenv("GOOGLE_PROJECT"); v == "" {
    46  		t.Fatal("GOOGLE_PROJECT must be set for acceptance tests")
    47  	}
    48  
    49  	if v := os.Getenv("GOOGLE_REGION"); v != "us-central1" {
    50  		t.Fatal("GOOGLE_REGION must be set to us-central1 for acceptance tests")
    51  	}
    52  }