focalboard/server/services/store/sqlstore/sqlstore_test.go
Harshil Sharma 08db4fed61
Workspace switcher (#1052)
* API WIP

* WIP

* Finished changes

* Fixed colors:

* Don't enforce charset adn collation in migration, pick from database DSN

* Added MySQL query

* Updated mocks

* Added tests

* Lint fixes

* Fixed typo and removed unsed style

* Checked in a snapshot

* Updated snapshot

* Updated Cypress test

* Updated Cypress test

* Updated Cypress test

* Fixed review comments

* Fixed tests

* Added default collation for MySQL

* Added documentation for ensuring correct database collation

* Updated migrations

* Fixed a bug with collation

* Fixed lint errors

* Used correct collation

* debugging

* Updating css

* Minor UI changes

* USe inbuilt default collation

* Used only charset for mysql

* Fixed linter issue:

* Added migration for matching collation

* Reverted local config changes

* Reverted local config changes

* Handled the case of personal server running on MySQL

* WIP

* Now running collation matching migration onlyt for plugins

* Minor optimization

* Multiple review fixes

* Added group by clause to primary query

* Supported for subpacth

Co-authored-by: Asaad Mahmood <asaadmahmood@users.noreply.github.com>
2021-09-08 10:22:03 +05:30

51 lines
1.6 KiB
Go

package sqlstore
import (
"database/sql"
"os"
"testing"
"github.com/mattermost/focalboard/server/services/store"
"github.com/mattermost/focalboard/server/services/store/storetests"
"github.com/stretchr/testify/require"
"github.com/mattermost/mattermost-server/v6/shared/mlog"
)
func SetupTests(t *testing.T) (store.Store, func()) {
dbType := os.Getenv("FB_STORE_TEST_DB_TYPE")
if dbType == "" {
dbType = sqliteDBType
}
connectionString := os.Getenv("FB_STORE_TEST_CONN_STRING")
if connectionString == "" {
connectionString = ":memory:"
}
logger := mlog.CreateConsoleTestLogger(false, mlog.LvlDebug)
sqlDB, err := sql.Open(dbType, connectionString)
require.NoError(t, err)
err = sqlDB.Ping()
require.NoError(t, err)
store, err := New(dbType, connectionString, "test_", logger, sqlDB, false)
require.Nil(t, err)
tearDown := func() {
defer func() { _ = logger.Shutdown() }()
err = store.Shutdown()
require.Nil(t, err)
}
return store, tearDown
}
func TestBlocksStore(t *testing.T) {
t.Run("BlocksStore", func(t *testing.T) { storetests.StoreTestBlocksStore(t, SetupTests) })
t.Run("SharingStore", func(t *testing.T) { storetests.StoreTestSharingStore(t, SetupTests) })
t.Run("SystemStore", func(t *testing.T) { storetests.StoreTestSystemStore(t, SetupTests) })
t.Run("UserStore", func(t *testing.T) { storetests.StoreTestUserStore(t, SetupTests) })
t.Run("SessionStore", func(t *testing.T) { storetests.StoreTestSessionStore(t, SetupTests) })
t.Run("WorkspaceStore", func(t *testing.T) { storetests.StoreTestWorkspaceStore(t, SetupTests) })
}