From 08d2b44ada5c8e47d46a5bb8b26414e6dc15e83b Mon Sep 17 00:00:00 2001 From: James Bardin Date: Tue, 14 Mar 2017 15:24:50 -0400 Subject: [PATCH] add gzip to consul backend tests --- backend/remote-state/consul/backend_test.go | 15 ++++++++ backend/remote-state/consul/client_test.go | 39 +++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/backend/remote-state/consul/backend_test.go b/backend/remote-state/consul/backend_test.go index 6a8566e0c..14133d44f 100644 --- a/backend/remote-state/consul/backend_test.go +++ b/backend/remote-state/consul/backend_test.go @@ -47,3 +47,18 @@ func TestBackend(t *testing.T) { // Test backend.TestBackend(t, b) } + +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) +} diff --git a/backend/remote-state/consul/client_test.go b/backend/remote-state/consul/client_test.go index 8978755ec..57b7c452e 100644 --- a/backend/remote-state/consul/client_test.go +++ b/backend/remote-state/consul/client_test.go @@ -34,6 +34,45 @@ func TestRemoteClient(t *testing.T) { remote.TestClient(t, state.(*remote.State).Client) } +// test the gzip functionality of the client +func TestRemoteClient_gzipUpgrade(t *testing.T) { + srv := newConsulTestServer(t) + defer srv.Stop() + + statePath := fmt.Sprintf("tf-unit/%s", time.Now().String()) + + // Get the backend + b := backend.TestBackendConfig(t, New(), map[string]interface{}{ + "address": srv.HTTPAddr, + "path": statePath, + }) + + // Grab the client + state, err := b.State(backend.DefaultStateName) + if err != nil { + t.Fatalf("err: %s", err) + } + + // Test + remote.TestClient(t, state.(*remote.State).Client) + + // create a new backend with gzip + b = backend.TestBackendConfig(t, New(), map[string]interface{}{ + "address": srv.HTTPAddr, + "path": statePath, + "gzip": true, + }) + + // Grab the client + state, err = b.State(backend.DefaultStateName) + if err != nil { + t.Fatalf("err: %s", err) + } + + // Test + remote.TestClient(t, state.(*remote.State).Client) +} + func TestConsul_stateLock(t *testing.T) { srv := newConsulTestServer(t) defer srv.Stop()