2016-01-20 00:00:09 +00:00
|
|
|
package physical
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
_ "github.com/lib/pq"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestPostgreSQLBackend(t *testing.T) {
|
|
|
|
connURL := os.Getenv("PGURL")
|
|
|
|
if connURL == "" {
|
|
|
|
t.SkipNow()
|
|
|
|
}
|
|
|
|
|
|
|
|
table := os.Getenv("PGTABLE")
|
|
|
|
if table == "" {
|
2016-01-28 00:15:48 +00:00
|
|
|
table = "vault_kv_store"
|
2016-01-20 00:00:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Run vault tests
|
2016-01-23 00:15:10 +00:00
|
|
|
b, err := NewBackend("postgresql", map[string]string{
|
2016-01-20 00:00:09 +00:00
|
|
|
"connection_url": connURL,
|
|
|
|
"table": table,
|
|
|
|
})
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("Failed to create new backend: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
defer func() {
|
|
|
|
pg := b.(*PostgreSQLBackend)
|
|
|
|
_, err := pg.client.Exec("DROP TABLE " + pg.table)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("Failed to drop table: %v", err)
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
|
|
|
testBackend(t, b)
|
|
|
|
testBackend_ListPrefix(t, b)
|
|
|
|
|
|
|
|
}
|