terraform/builtin/providers/consul/resource_provider_test.go

57 lines
1.3 KiB
Go
Raw Normal View History

2014-07-26 04:14:48 +02:00
package consul
import (
"testing"
2014-10-20 21:02:37 +02:00
"github.com/armon/consul-api"
2014-07-26 04:14:48 +02:00
"github.com/hashicorp/terraform/config"
"github.com/hashicorp/terraform/helper/schema"
2014-07-26 04:14:48 +02:00
"github.com/hashicorp/terraform/terraform"
)
var testAccProviders map[string]terraform.ResourceProvider
var testAccProvider *schema.Provider
2014-07-26 04:14:48 +02:00
func init() {
testAccProvider = Provider().(*schema.Provider)
2014-07-26 04:14:48 +02:00
testAccProviders = map[string]terraform.ResourceProvider{
"consul": testAccProvider,
}
2014-10-20 21:02:37 +02:00
// Use the demo address for the acceptance tests
testAccProvider.ConfigureFunc = func(d *schema.ResourceData) (interface{}, error) {
conf := consulapi.DefaultConfig()
conf.Address = "demo.consul.io:80"
return consulapi.NewClient(conf)
}
2014-07-26 04:14:48 +02:00
}
func TestResourceProvider(t *testing.T) {
if err := Provider().(*schema.Provider).InternalValidate(); err != nil {
t.Fatalf("err: %s", err)
}
}
2014-07-26 04:14:48 +02:00
func TestResourceProvider_impl(t *testing.T) {
var _ terraform.ResourceProvider = Provider()
2014-07-26 04:14:48 +02:00
}
func TestResourceProvider_Configure(t *testing.T) {
rp := Provider()
2014-07-26 04:14:48 +02:00
raw := map[string]interface{}{
"address": "demo.consul.io:80",
2014-10-20 21:02:37 +02:00
"datacenter": "nyc3",
2014-07-26 04:14:48 +02:00
}
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)
}
}