mirror of
https://github.com/opentofu/opentofu.git
synced 2025-01-18 20:52:58 -06:00
6621501ae3
Most of the state package has been deprecated by the states package. This PR replaces all the references to the old state package that can be done simply - the low-hanging fruit. * states: move state.Locker to statemgr The state.Locker interface was a wrapper around a statemgr.Full, so moving this was relatively straightforward. * command: remove unnecessary use of state package for writing local terraform state files * move state.LocalState into terraform package state.LocalState is responsible for managing terraform.States, so it made sense (to me) to move it into the terraform package. * slight change of heart: move state.LocalState into clistate instead of terraform
46 lines
1.1 KiB
Go
46 lines
1.1 KiB
Go
package etcdv2
|
|
|
|
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"
|
|
)
|
|
|
|
func TestEtcdClient_impl(t *testing.T) {
|
|
var _ remote.Client = new(EtcdClient)
|
|
}
|
|
|
|
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())),
|
|
}
|
|
|
|
if username := os.Getenv("ETCD_USERNAME"); username != "" {
|
|
config["username"] = cty.StringVal(username)
|
|
}
|
|
if password := os.Getenv("ETCD_PASSWORD"); password != "" {
|
|
config["password"] = cty.StringVal(password)
|
|
}
|
|
|
|
b := backend.TestBackendConfig(t, New(), configs.SynthBody("synth", config))
|
|
state, err := b.StateMgr(backend.DefaultStateName)
|
|
if err != nil {
|
|
t.Fatalf("Error for valid config: %s", err)
|
|
}
|
|
|
|
remote.TestClient(t, state.(*remote.State).Client)
|
|
}
|