From fa7743b627ff8a3985589cbee6debf73bfbfb92a Mon Sep 17 00:00:00 2001 From: James Bardin Date: Tue, 14 Mar 2017 10:49:38 -0400 Subject: [PATCH] quiet the consul server during backend tests Don't display logs unless using `-v` --- backend/remote-state/consul/backend_test.go | 16 +++++++++++++++- backend/remote-state/consul/client_test.go | 5 ++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/backend/remote-state/consul/backend_test.go b/backend/remote-state/consul/backend_test.go index 2fcb1c6a71..819e790d7e 100644 --- a/backend/remote-state/consul/backend_test.go +++ b/backend/remote-state/consul/backend_test.go @@ -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 diff --git a/backend/remote-state/consul/client_test.go b/backend/remote-state/consul/client_test.go index 6109c4c0f4..8978755ec9 100644 --- a/backend/remote-state/consul/client_test.go +++ b/backend/remote-state/consul/client_test.go @@ -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())