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

     1  package kubernetes
     2  
     3  import (
     4  	"os"
     5  	"strings"
     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  		"kubernetes": 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  	hasFileCfg := (os.Getenv("KUBE_CTX_AUTH_INFO") != "" && os.Getenv("KUBE_CTX_CLUSTER") != "")
    34  	hasStaticCfg := (os.Getenv("KUBE_HOST") != "" &&
    35  		os.Getenv("KUBE_USER") != "" &&
    36  		os.Getenv("KUBE_PASSWORD") != "" &&
    37  		os.Getenv("KUBE_CLIENT_CERT_DATA") != "" &&
    38  		os.Getenv("KUBE_CLIENT_KEY_DATA") != "" &&
    39  		os.Getenv("KUBE_CLUSTER_CA_CERT_DATA") != "")
    40  
    41  	if !hasFileCfg && !hasStaticCfg {
    42  		t.Fatalf("File config (KUBE_CTX_AUTH_INFO and KUBE_CTX_CLUSTER) or static configuration"+
    43  			" (%s) must be set for acceptance tests",
    44  			strings.Join([]string{
    45  				"KUBE_HOST",
    46  				"KUBE_USER",
    47  				"KUBE_PASSWORD",
    48  				"KUBE_CLIENT_CERT_DATA",
    49  				"KUBE_CLIENT_KEY_DATA",
    50  				"KUBE_CLUSTER_CA_CERT_DATA",
    51  			}, ", "))
    52  	}
    53  }