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

43 lines
799 B
Go
Raw Normal View History

2017-03-02 07:58:51 +01:00
package consul
import (
"fmt"
"io/ioutil"
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 {
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)
}