2017-10-09 13:46:54 +02:00
|
|
|
package manta
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"fmt"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/hashicorp/terraform/backend"
|
|
|
|
"github.com/hashicorp/terraform/state/remote"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestRemoteClient_impl(t *testing.T) {
|
|
|
|
var _ remote.Client = new(RemoteClient)
|
|
|
|
var _ remote.ClientLocker = new(RemoteClient)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestRemoteClient(t *testing.T) {
|
|
|
|
testACC(t)
|
|
|
|
directory := fmt.Sprintf("terraform-remote-manta-test-%x", time.Now().Unix())
|
|
|
|
keyName := "testState"
|
|
|
|
|
2018-03-21 02:43:02 +01:00
|
|
|
b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{
|
|
|
|
"path": directory,
|
|
|
|
"objectName": keyName,
|
|
|
|
})).(*Backend)
|
2017-10-09 13:46:54 +02:00
|
|
|
|
|
|
|
createMantaFolder(t, b.storageClient, directory)
|
|
|
|
defer deleteMantaFolder(t, b.storageClient, directory)
|
|
|
|
|
2018-10-01 23:35:23 +02:00
|
|
|
state, err := b.StateMgr(backend.DefaultStateName)
|
2017-10-09 13:46:54 +02:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
remote.TestClient(t, state.(*remote.State).Client)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestRemoteClientLocks(t *testing.T) {
|
|
|
|
testACC(t)
|
|
|
|
directory := fmt.Sprintf("terraform-remote-manta-test-%x", time.Now().Unix())
|
|
|
|
keyName := "testState"
|
|
|
|
|
2018-03-21 02:43:02 +01:00
|
|
|
b1 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{
|
|
|
|
"path": directory,
|
|
|
|
"objectName": keyName,
|
|
|
|
})).(*Backend)
|
2017-10-09 13:46:54 +02:00
|
|
|
|
2018-03-21 02:43:02 +01:00
|
|
|
b2 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{
|
|
|
|
"path": directory,
|
|
|
|
"objectName": keyName,
|
|
|
|
})).(*Backend)
|
2017-10-09 13:46:54 +02:00
|
|
|
|
|
|
|
createMantaFolder(t, b1.storageClient, directory)
|
|
|
|
defer deleteMantaFolder(t, b1.storageClient, directory)
|
|
|
|
|
2018-10-01 23:35:23 +02:00
|
|
|
s1, err := b1.StateMgr(backend.DefaultStateName)
|
2017-10-09 13:46:54 +02:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2018-10-01 23:35:23 +02:00
|
|
|
s2, err := b2.StateMgr(backend.DefaultStateName)
|
2017-10-09 13:46:54 +02:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
remote.TestRemoteLocks(t, s1.(*remote.State).Client, s2.(*remote.State).Client)
|
|
|
|
}
|