package consul import ( "os" "testing" "github.com/hashicorp/terraform/config" "github.com/hashicorp/terraform/helper/schema" "github.com/hashicorp/terraform/terraform" ) var testAccProviders map[string]terraform.ResourceProvider var testAccProvider *schema.Provider func init() { testAccProvider = Provider().(*schema.Provider) testAccProviders = map[string]terraform.ResourceProvider{ "consul": testAccProvider, } } func TestResourceProvider(t *testing.T) { if err := Provider().(*schema.Provider).InternalValidate(); err != nil { t.Fatalf("err: %s", err) } } func TestResourceProvider_impl(t *testing.T) { var _ terraform.ResourceProvider = Provider() } func TestResourceProvider_Configure(t *testing.T) { rp := Provider() raw := map[string]interface{}{ "address": "demo.consul.io:80", "datacenter": "nyc3", "scheme": "https", } rawConfig, err := config.NewRawConfig(raw) if err != nil { t.Fatalf("err: %s", err) } err = rp.Configure(terraform.NewResourceConfig(rawConfig)) if err != nil { t.Fatalf("err: %s", err) } } func TestResourceProvider_ConfigureTLS(t *testing.T) { rp := Provider() raw := map[string]interface{}{ "address": "demo.consul.io:80", "ca_file": "test-fixtures/cacert.pem", "cert_file": "test-fixtures/usercert.pem", "datacenter": "nyc3", "key_file": "test-fixtures/userkey.pem", "scheme": "https", } rawConfig, err := config.NewRawConfig(raw) if err != nil { t.Fatalf("err: %s", err) } err = rp.Configure(terraform.NewResourceConfig(rawConfig)) if err != nil { t.Fatalf("err: %s", err) } } func testAccPreCheck(t *testing.T) { if v := os.Getenv("CONSUL_HTTP_ADDR"); v != "" { return } if v := os.Getenv("CONSUL_ADDRESS"); v != "" { return } t.Fatal("Either CONSUL_ADDRESS or CONSUL_HTTP_ADDR must be set for acceptance tests") }