2020-10-18 01:09:12 +02:00
|
|
|
package sqlstore
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func SetupTests(t *testing.T) (*SQLStore, func()) {
|
|
|
|
dbType := os.Getenv("OT_STORE_TEST_DB_TYPE")
|
|
|
|
if dbType == "" {
|
|
|
|
dbType = "sqlite3"
|
|
|
|
}
|
|
|
|
connectionString := os.Getenv("OT_STORE_TEST_CONN_STRING")
|
|
|
|
if connectionString == "" {
|
|
|
|
connectionString = ":memory:"
|
|
|
|
}
|
|
|
|
|
|
|
|
store, err := New(dbType, connectionString)
|
|
|
|
require.Nil(t, err)
|
|
|
|
|
|
|
|
tearDown := func() {
|
2020-10-18 02:07:35 +02:00
|
|
|
err = store.Shutdown()
|
|
|
|
require.Nil(t, err)
|
2020-10-18 01:09:12 +02:00
|
|
|
}
|
|
|
|
return store, tearDown
|
|
|
|
}
|