Merge pull request #12699 from hashicorp/jbardin/consul-gzip-tests

add gzip to consul backend tests
This commit is contained in:
James Bardin 2017-03-14 20:12:01 -04:00 committed by GitHub
commit 6a286e4aed
2 changed files with 54 additions and 0 deletions

View File

@ -47,3 +47,18 @@ func TestBackend(t *testing.T) {
// Test // Test
backend.TestBackend(t, b) 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)
}

View File

@ -34,6 +34,45 @@ func TestRemoteClient(t *testing.T) {
remote.TestClient(t, state.(*remote.State).Client) 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) { func TestConsul_stateLock(t *testing.T) {
srv := newConsulTestServer(t) srv := newConsulTestServer(t)
defer srv.Stop() defer srv.Stop()