quiet the consul server during backend tests

Don't display logs unless using `-v`
This commit is contained in:
James Bardin 2017-03-14 10:49:38 -04:00
parent 9529bd3bf0
commit fa7743b627
2 changed files with 17 additions and 4 deletions

View File

@ -2,6 +2,7 @@ package consul
import (
"fmt"
"io/ioutil"
"testing"
"time"
@ -13,8 +14,21 @@ 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
}
func TestBackend(t *testing.T) {
srv := testutil.NewTestServer(t)
srv := newConsulTestServer(t)
defer srv.Stop()
// Get the backend

View File

@ -5,7 +5,6 @@ import (
"testing"
"time"
"github.com/hashicorp/consul/testutil"
"github.com/hashicorp/terraform/backend"
"github.com/hashicorp/terraform/state/remote"
)
@ -16,7 +15,7 @@ func TestRemoteClient_impl(t *testing.T) {
}
func TestRemoteClient(t *testing.T) {
srv := testutil.NewTestServer(t)
srv := newConsulTestServer(t)
defer srv.Stop()
// Get the backend
@ -36,7 +35,7 @@ func TestRemoteClient(t *testing.T) {
}
func TestConsul_stateLock(t *testing.T) {
srv := testutil.NewTestServer(t)
srv := newConsulTestServer(t)
defer srv.Stop()
path := fmt.Sprintf("tf-unit/%s", time.Now().String())