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"
|
|
|
|
|
|
|
|
b := backend.TestBackendConfig(t, New(), map[string]interface{}{
|
2018-08-29 20:20:32 +02:00
|
|
|
"path": directory,
|
|
|
|
"object_name": keyName,
|
2017-10-09 13:46:54 +02:00
|
|
|
}).(*Backend)
|
|
|
|
|
|
|
|
createMantaFolder(t, b.storageClient, directory)
|
|
|
|
defer deleteMantaFolder(t, b.storageClient, directory)
|
|
|
|
|
|
|
|
state, err := b.State(backend.DefaultStateName)
|
|
|
|
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"
|
|
|
|
|
|
|
|
b1 := backend.TestBackendConfig(t, New(), map[string]interface{}{
|
2018-08-29 20:20:32 +02:00
|
|
|
"path": directory,
|
|
|
|
"object_name": keyName,
|
2017-10-09 13:46:54 +02:00
|
|
|
}).(*Backend)
|
|
|
|
|
|
|
|
b2 := backend.TestBackendConfig(t, New(), map[string]interface{}{
|
2018-08-29 20:20:32 +02:00
|
|
|
"path": directory,
|
|
|
|
"object_name": keyName,
|
2017-10-09 13:46:54 +02:00
|
|
|
}).(*Backend)
|
|
|
|
|
|
|
|
createMantaFolder(t, b1.storageClient, directory)
|
|
|
|
defer deleteMantaFolder(t, b1.storageClient, directory)
|
|
|
|
|
|
|
|
s1, err := b1.State(backend.DefaultStateName)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
s2, err := b2.State(backend.DefaultStateName)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
remote.TestRemoteLocks(t, s1.(*remote.State).Client, s2.(*remote.State).Client)
|
|
|
|
}
|