Fix type conversion panic
etcdv3 acceptance tests fail due to attempting to pass slices of strings for the endpoints config to HCL2ValueFromConfigValue() which does not handle that type. Not a pretty solution but a helper function that converts the endpoints to a slice of empty interfaces satisfies the requirements of the HCL2ValueFromConfigValue function. fixes https://github.com/hashicorp/terraform/issues/28096
This commit is contained in:
parent
0750a16cce
commit
3e8ebd6f40
|
@ -60,12 +60,12 @@ func TestBackend(t *testing.T) {
|
|||
|
||||
// Get the backend. We need two to test locking.
|
||||
b1 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{
|
||||
"endpoints": etcdv3Endpoints,
|
||||
"endpoints": stringsToInterfaces(etcdv3Endpoints),
|
||||
"prefix": prefix,
|
||||
}))
|
||||
|
||||
b2 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{
|
||||
"endpoints": etcdv3Endpoints,
|
||||
"endpoints": stringsToInterfaces(etcdv3Endpoints),
|
||||
"prefix": prefix,
|
||||
}))
|
||||
|
||||
|
@ -83,13 +83,13 @@ func TestBackend_lockDisabled(t *testing.T) {
|
|||
|
||||
// Get the backend. We need two to test locking.
|
||||
b1 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{
|
||||
"endpoints": etcdv3Endpoints,
|
||||
"endpoints": stringsToInterfaces(etcdv3Endpoints),
|
||||
"prefix": prefix,
|
||||
"lock": false,
|
||||
}))
|
||||
|
||||
b2 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{
|
||||
"endpoints": etcdv3Endpoints,
|
||||
"endpoints": stringsToInterfaces(etcdv3Endpoints),
|
||||
"prefix": prefix + "/" + "different", // Diff so locking test would fail if it was locking
|
||||
"lock": false,
|
||||
}))
|
||||
|
@ -97,3 +97,11 @@ func TestBackend_lockDisabled(t *testing.T) {
|
|||
// Test
|
||||
backend.TestBackendStateLocks(t, b1, b2)
|
||||
}
|
||||
|
||||
func stringsToInterfaces(strSlice []string) []interface{} {
|
||||
var interfaceSlice []interface{}
|
||||
for _, v := range strSlice {
|
||||
interfaceSlice = append(interfaceSlice, v)
|
||||
}
|
||||
return interfaceSlice
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ func TestRemoteClient(t *testing.T) {
|
|||
|
||||
// Get the backend
|
||||
b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{
|
||||
"endpoints": etcdv3Endpoints,
|
||||
"endpoints": stringsToInterfaces(etcdv3Endpoints),
|
||||
"prefix": prefix,
|
||||
}))
|
||||
|
||||
|
@ -45,7 +45,7 @@ func TestEtcdv3_stateLock(t *testing.T) {
|
|||
|
||||
// Get the backend
|
||||
s1, err := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{
|
||||
"endpoints": etcdv3Endpoints,
|
||||
"endpoints": stringsToInterfaces(etcdv3Endpoints),
|
||||
"prefix": prefix,
|
||||
})).StateMgr(backend.DefaultStateName)
|
||||
if err != nil {
|
||||
|
@ -53,7 +53,7 @@ func TestEtcdv3_stateLock(t *testing.T) {
|
|||
}
|
||||
|
||||
s2, err := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{
|
||||
"endpoints": etcdv3Endpoints,
|
||||
"endpoints": stringsToInterfaces(etcdv3Endpoints),
|
||||
"prefix": prefix,
|
||||
})).StateMgr(backend.DefaultStateName)
|
||||
if err != nil {
|
||||
|
@ -71,7 +71,7 @@ func TestEtcdv3_destroyLock(t *testing.T) {
|
|||
|
||||
// Get the backend
|
||||
b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{
|
||||
"endpoints": etcdv3Endpoints,
|
||||
"endpoints": stringsToInterfaces(etcdv3Endpoints),
|
||||
"prefix": prefix,
|
||||
}))
|
||||
|
||||
|
|
Loading…
Reference in New Issue