Migrate physical backends into separate packages (#3106)

This commit is contained in:
Jeff Mitchell
2017-08-03 13:24:27 -04:00
committed by GitHub
parent 36998a55e6
commit 0ac531d3f4
59 changed files with 875 additions and 671 deletions

View File

@@ -0,0 +1,46 @@
package postgresql
import (
"os"
"testing"
"github.com/hashicorp/vault/helper/logformat"
"github.com/hashicorp/vault/physical"
log "github.com/mgutz/logxi/v1"
_ "github.com/lib/pq"
)
func TestPostgreSQLBackend(t *testing.T) {
connURL := os.Getenv("PGURL")
if connURL == "" {
t.SkipNow()
}
table := os.Getenv("PGTABLE")
if table == "" {
table = "vault_kv_store"
}
// Run vault tests
logger := logformat.NewVaultLogger(log.LevelTrace)
b, err := NewPostgreSQLBackend(map[string]string{
"connection_url": connURL,
"table": table,
}, logger)
if err != nil {
t.Fatalf("Failed to create new backend: %v", err)
}
defer func() {
pg := b.(*PostgreSQLBackend)
_, err := pg.client.Exec("TRUNCATE TABLE " + pg.table)
if err != nil {
t.Fatalf("Failed to drop table: %v", err)
}
}()
physical.ExerciseBackend(t, b)
physical.ExerciseBackend_ListPrefix(t, b)
}