2020-10-18 01:09:12 +02:00
|
|
|
package sqlstore
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"testing"
|
|
|
|
|
2021-01-29 17:50:20 +01:00
|
|
|
"github.com/mattermost/focalboard/server/services/store"
|
|
|
|
"github.com/mattermost/focalboard/server/services/store/storetests"
|
2020-10-18 01:09:12 +02:00
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
2021-01-29 17:50:20 +01:00
|
|
|
func SetupTests(t *testing.T) (store.Store, func()) {
|
2021-04-17 09:06:57 +02:00
|
|
|
dbType := os.Getenv("FB_STORE_TEST_DB_TYPE")
|
2020-10-18 01:09:12 +02:00
|
|
|
if dbType == "" {
|
|
|
|
dbType = "sqlite3"
|
|
|
|
}
|
2020-10-22 15:22:36 +02:00
|
|
|
|
2021-04-17 09:06:57 +02:00
|
|
|
connectionString := os.Getenv("FB_STORE_TEST_CONN_STRING")
|
2020-10-18 01:09:12 +02:00
|
|
|
if connectionString == "" {
|
|
|
|
connectionString = ":memory:"
|
|
|
|
}
|
|
|
|
|
2021-04-17 09:06:57 +02:00
|
|
|
store, err := New(dbType, connectionString, "test_")
|
2020-10-18 01:09:12 +02:00
|
|
|
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
|
|
|
}
|
2020-10-22 15:22:36 +02:00
|
|
|
|
2020-10-18 01:09:12 +02:00
|
|
|
return store, tearDown
|
|
|
|
}
|
2020-11-12 19:48:08 +01:00
|
|
|
|
2021-01-29 17:50:20 +01:00
|
|
|
func TestBlocksStore(t *testing.T) {
|
|
|
|
t.Run("BlocksStore", func(t *testing.T) { storetests.StoreTestBlocksStore(t, SetupTests) })
|
2021-01-29 20:27:43 +01:00
|
|
|
t.Run("SharingStore", func(t *testing.T) { storetests.StoreTestSharingStore(t, SetupTests) })
|
2020-11-12 19:48:08 +01:00
|
|
|
}
|