github.com/koding/terraform@v0.6.4-0.20170608090606-5d7e0339779d/builtin/providers/google/gcp_sweeper_test.go (about)

     1  package google
     2  
     3  import (
     4  	"fmt"
     5  	"os"
     6  	"testing"
     7  
     8  	"github.com/hashicorp/terraform/helper/resource"
     9  )
    10  
    11  func TestMain(m *testing.M) {
    12  	resource.TestMain(m)
    13  }
    14  
    15  // sharedConfigForRegion returns a common config setup needed for the sweeper
    16  // functions for a given region
    17  func sharedConfigForRegion(region string) (*Config, error) {
    18  	project := os.Getenv("GOOGLE_PROJECT")
    19  	if project == "" {
    20  		return nil, fmt.Errorf("empty GOOGLE_PROJECT")
    21  	}
    22  
    23  	creds := os.Getenv("GOOGLE_CREDENTIALS")
    24  	if creds == "" {
    25  		return nil, fmt.Errorf("empty GOOGLE_CREDENTIALS")
    26  	}
    27  
    28  	conf := &Config{
    29  		Credentials: creds,
    30  		Region:      region,
    31  		Project:     project,
    32  	}
    33  
    34  	return conf, nil
    35  }