github.com/turtlemonvh/terraform@v0.6.9-0.20151204001754-8e40b6b855e8/builtin/providers/consul/resource_provider_test.go (about)

     1  package consul
     2  
     3  import (
     4  	"testing"
     5  
     6  	consulapi "github.com/hashicorp/consul/api"
     7  	"github.com/hashicorp/terraform/config"
     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  		"consul": testAccProvider,
    19  	}
    20  
    21  	// Use the demo address for the acceptance tests
    22  	testAccProvider.ConfigureFunc = func(d *schema.ResourceData) (interface{}, error) {
    23  		conf := consulapi.DefaultConfig()
    24  		conf.Address = "demo.consul.io:80"
    25  		return consulapi.NewClient(conf)
    26  	}
    27  }
    28  
    29  func TestResourceProvider(t *testing.T) {
    30  	if err := Provider().(*schema.Provider).InternalValidate(); err != nil {
    31  		t.Fatalf("err: %s", err)
    32  	}
    33  }
    34  
    35  func TestResourceProvider_impl(t *testing.T) {
    36  	var _ terraform.ResourceProvider = Provider()
    37  }
    38  
    39  func TestResourceProvider_Configure(t *testing.T) {
    40  	rp := Provider()
    41  
    42  	raw := map[string]interface{}{
    43  		"address":    "demo.consul.io:80",
    44  		"datacenter": "nyc3",
    45  		"scheme":     "https",
    46  	}
    47  
    48  	rawConfig, err := config.NewRawConfig(raw)
    49  	if err != nil {
    50  		t.Fatalf("err: %s", err)
    51  	}
    52  
    53  	err = rp.Configure(terraform.NewResourceConfig(rawConfig))
    54  	if err != nil {
    55  		t.Fatalf("err: %s", err)
    56  	}
    57  }