terraform/backend/remote-state/etcdv2/client_test.go

46 lines
1.1 KiB
Go
Raw Normal View History

package etcdv2
2015-10-12 23:04:58 +02:00
import (
"fmt"
"os"
"testing"
"time"
"github.com/hashicorp/terraform/backend"
"github.com/hashicorp/terraform/configs"
"github.com/hashicorp/terraform/states/remote"
"github.com/zclconf/go-cty/cty"
2015-10-12 23:04:58 +02:00
)
func TestEtcdClient_impl(t *testing.T) {
var _ remote.Client = new(EtcdClient)
2015-10-12 23:04:58 +02:00
}
func TestEtcdClient(t *testing.T) {
endpoint := os.Getenv("ETCD_ENDPOINT")
if endpoint == "" {
t.Skipf("skipping; ETCD_ENDPOINT must be set")
}
// Get the backend
config := map[string]cty.Value{
"endpoints": cty.StringVal(endpoint),
"path": cty.StringVal(fmt.Sprintf("tf-unit/%s", time.Now().String())),
2015-10-12 23:04:58 +02:00
}
if username := os.Getenv("ETCD_USERNAME"); username != "" {
config["username"] = cty.StringVal(username)
2015-10-12 23:04:58 +02:00
}
if password := os.Getenv("ETCD_PASSWORD"); password != "" {
config["password"] = cty.StringVal(password)
2015-10-12 23:04:58 +02:00
}
b := backend.TestBackendConfig(t, New(), configs.SynthBody("synth", config))
state, err := b.StateMgr(backend.DefaultStateName)
2015-10-12 23:04:58 +02:00
if err != nil {
t.Fatalf("Error for valid config: %s", err)
}
remote.TestClient(t, state.(*remote.State).Client)
2015-10-12 23:04:58 +02:00
}