2015-06-08 10:32:44 +00:00
|
|
|
package physical
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
_ "github.com/go-sql-driver/mysql"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestMySQLBackend(t *testing.T) {
|
|
|
|
address := os.Getenv("MYSQL_ADDR")
|
|
|
|
if address == "" {
|
|
|
|
t.SkipNow()
|
|
|
|
}
|
|
|
|
|
|
|
|
database := os.Getenv("MYSQL_DB")
|
|
|
|
if database == "" {
|
|
|
|
database = "test"
|
|
|
|
}
|
|
|
|
|
|
|
|
table := os.Getenv("MYSQL_TABLE")
|
|
|
|
if table == "" {
|
|
|
|
table = "test"
|
|
|
|
}
|
|
|
|
|
|
|
|
username := os.Getenv("MYSQL_USERNAME")
|
|
|
|
password := os.Getenv("MYSQL_PASSWORD")
|
|
|
|
|
2015-06-12 17:31:46 +00:00
|
|
|
// Run vault tests
|
2015-06-12 09:47:45 +00:00
|
|
|
b, err := NewBackend("mysql", map[string]string{
|
|
|
|
"address": address,
|
|
|
|
"database": database,
|
|
|
|
"table": table,
|
|
|
|
"username": username,
|
|
|
|
"password": password,
|
|
|
|
})
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("Failed to create new backend: %v", err)
|
|
|
|
}
|
|
|
|
|
2015-06-18 21:31:00 +00:00
|
|
|
defer func() {
|
|
|
|
mysql := b.(*MySQLBackend)
|
|
|
|
_, err := mysql.client.Exec("DROP TABLE " + mysql.dbTable)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("Failed to drop table: %v", err)
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
2015-06-12 09:47:45 +00:00
|
|
|
testBackend(t, b)
|
|
|
|
testBackend_ListPrefix(t, b)
|
2015-06-13 02:19:40 +00:00
|
|
|
|
2015-06-08 10:32:44 +00:00
|
|
|
}
|