terraform/backend/remote-state/consul/backend_test.go

65 lines
1.3 KiB
Go
Raw Normal View History

2017-03-02 07:58:51 +01:00
package consul
import (
"fmt"
"io/ioutil"
"os"
2017-03-02 07:58:51 +01:00
"testing"
"time"
"github.com/hashicorp/consul/testutil"
2017-03-02 07:58:51 +01:00
"github.com/hashicorp/terraform/backend"
)
func TestBackend_impl(t *testing.T) {
var _ backend.Backend = new(Backend)
}
func newConsulTestServer(t *testing.T) *testutil.TestServer {
skip := os.Getenv("TF_ACC") == "" && os.Getenv("TF_CONSUL_TEST") == ""
if skip {
t.Log("consul server tests require setting TF_ACC or TF_CONSUL_TEST")
t.Skip()
}
srv := testutil.NewTestServerConfig(t, func(c *testutil.TestServerConfig) {
c.LogLevel = "warn"
if !testing.Verbose() {
c.Stdout = ioutil.Discard
c.Stderr = ioutil.Discard
}
})
return srv
}
2017-03-02 07:58:51 +01:00
func TestBackend(t *testing.T) {
srv := newConsulTestServer(t)
defer srv.Stop()
2017-03-02 07:58:51 +01:00
// Get the backend
b := backend.TestBackendConfig(t, New(), map[string]interface{}{
"address": srv.HTTPAddr,
2017-03-02 07:58:51 +01:00
"path": fmt.Sprintf("tf-unit/%s", time.Now().String()),
})
// Test
backend.TestBackend(t, b)
}
2017-03-14 20:24:50 +01:00
func TestBackend_gzip(t *testing.T) {
srv := newConsulTestServer(t)
defer srv.Stop()
// Get the backend
b := backend.TestBackendConfig(t, New(), map[string]interface{}{
"address": srv.HTTPAddr,
"path": fmt.Sprintf("tf-unit/%s", time.Now().String()),
"gzip": true,
})
// Test
backend.TestBackend(t, b)
}