Removing supplier concept from the sql store (#16355)
* Removing supplier concept from the sql store * Removing other metions to supplier * Fixing gofmt * Fixing gofmt * Renaming NewSqlStore to New * Fixing tests Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
11248831b8
Коммит
a74fe05695
@@ -328,7 +328,7 @@ func (me *TestHelper) InitLogin() *TestHelper {
|
|||||||
me.TeamAdminUser = userCache.TeamAdminUser.DeepCopy()
|
me.TeamAdminUser = userCache.TeamAdminUser.DeepCopy()
|
||||||
me.BasicUser = userCache.BasicUser.DeepCopy()
|
me.BasicUser = userCache.BasicUser.DeepCopy()
|
||||||
me.BasicUser2 = userCache.BasicUser2.DeepCopy()
|
me.BasicUser2 = userCache.BasicUser2.DeepCopy()
|
||||||
mainHelper.GetSQLSupplier().GetMaster().Insert(me.SystemAdminUser, me.TeamAdminUser, me.BasicUser, me.BasicUser2)
|
mainHelper.GetSQLStore().GetMaster().Insert(me.SystemAdminUser, me.TeamAdminUser, me.BasicUser, me.BasicUser2)
|
||||||
// restore non hashed password for login
|
// restore non hashed password for login
|
||||||
me.SystemAdminUser.Password = "Pa$$word11"
|
me.SystemAdminUser.Password = "Pa$$word11"
|
||||||
me.TeamAdminUser.Password = "Pa$$word11"
|
me.TeamAdminUser.Password = "Pa$$word11"
|
||||||
|
|||||||
@@ -122,11 +122,11 @@ func TestGetSidebarCategories(t *testing.T) {
|
|||||||
defer th.TearDown()
|
defer th.TearDown()
|
||||||
|
|
||||||
// Temporarily renaming a table to force a DB error.
|
// Temporarily renaming a table to force a DB error.
|
||||||
sqlSupplier := mainHelper.GetSQLSupplier()
|
sqlStore := mainHelper.GetSQLStore()
|
||||||
_, err := sqlSupplier.GetMaster().Exec("ALTER TABLE SidebarCategories RENAME TO SidebarCategoriesTest")
|
_, err := sqlStore.GetMaster().Exec("ALTER TABLE SidebarCategories RENAME TO SidebarCategoriesTest")
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
defer func() {
|
defer func() {
|
||||||
_, err := sqlSupplier.GetMaster().Exec("ALTER TABLE SidebarCategoriesTest RENAME TO SidebarCategories")
|
_, err := sqlStore.GetMaster().Exec("ALTER TABLE SidebarCategoriesTest RENAME TO SidebarCategories")
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ func TestEnsureInstallationDate(t *testing.T) {
|
|||||||
|
|
||||||
for _, tc := range tt {
|
for _, tc := range tt {
|
||||||
t.Run(tc.Name, func(t *testing.T) {
|
t.Run(tc.Name, func(t *testing.T) {
|
||||||
sqlStore := th.GetSqlSupplier()
|
sqlStore := th.GetSqlStore()
|
||||||
sqlStore.GetMaster().Exec("DELETE FROM Users")
|
sqlStore.GetMaster().Exec("DELETE FROM Users")
|
||||||
|
|
||||||
for _, createAt := range tc.UsersCreationDates {
|
for _, createAt := range tc.UsersCreationDates {
|
||||||
|
|||||||
@@ -208,7 +208,7 @@ func (th *TestHelper) InitBasic() *TestHelper {
|
|||||||
th.SystemAdminUser = userCache.SystemAdminUser.DeepCopy()
|
th.SystemAdminUser = userCache.SystemAdminUser.DeepCopy()
|
||||||
th.BasicUser = userCache.BasicUser.DeepCopy()
|
th.BasicUser = userCache.BasicUser.DeepCopy()
|
||||||
th.BasicUser2 = userCache.BasicUser2.DeepCopy()
|
th.BasicUser2 = userCache.BasicUser2.DeepCopy()
|
||||||
mainHelper.GetSQLSupplier().GetMaster().Insert(th.SystemAdminUser, th.BasicUser, th.BasicUser2)
|
mainHelper.GetSQLStore().GetMaster().Insert(th.SystemAdminUser, th.BasicUser, th.BasicUser2)
|
||||||
|
|
||||||
th.BasicTeam = th.CreateTeam()
|
th.BasicTeam = th.CreateTeam()
|
||||||
|
|
||||||
@@ -574,40 +574,40 @@ func (th *TestHelper) TearDown() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*TestHelper) GetSqlSupplier() *sqlstore.SqlSupplier {
|
func (*TestHelper) GetSqlStore() *sqlstore.SqlStore {
|
||||||
return mainHelper.GetSQLSupplier()
|
return mainHelper.GetSQLStore()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*TestHelper) ResetRoleMigration() {
|
func (*TestHelper) ResetRoleMigration() {
|
||||||
sqlSupplier := mainHelper.GetSQLSupplier()
|
sqlStore := mainHelper.GetSQLStore()
|
||||||
if _, err := sqlSupplier.GetMaster().Exec("DELETE from Roles"); err != nil {
|
if _, err := sqlStore.GetMaster().Exec("DELETE from Roles"); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
mainHelper.GetClusterInterface().SendClearRoleCacheMessage()
|
mainHelper.GetClusterInterface().SendClearRoleCacheMessage()
|
||||||
|
|
||||||
if _, err := sqlSupplier.GetMaster().Exec("DELETE from Systems where Name = :Name", map[string]interface{}{"Name": model.ADVANCED_PERMISSIONS_MIGRATION_KEY}); err != nil {
|
if _, err := sqlStore.GetMaster().Exec("DELETE from Systems where Name = :Name", map[string]interface{}{"Name": model.ADVANCED_PERMISSIONS_MIGRATION_KEY}); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*TestHelper) ResetEmojisMigration() {
|
func (*TestHelper) ResetEmojisMigration() {
|
||||||
sqlSupplier := mainHelper.GetSQLSupplier()
|
sqlStore := mainHelper.GetSQLStore()
|
||||||
if _, err := sqlSupplier.GetMaster().Exec("UPDATE Roles SET Permissions=REPLACE(Permissions, ' create_emojis', '') WHERE builtin=True"); err != nil {
|
if _, err := sqlStore.GetMaster().Exec("UPDATE Roles SET Permissions=REPLACE(Permissions, ' create_emojis', '') WHERE builtin=True"); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := sqlSupplier.GetMaster().Exec("UPDATE Roles SET Permissions=REPLACE(Permissions, ' delete_emojis', '') WHERE builtin=True"); err != nil {
|
if _, err := sqlStore.GetMaster().Exec("UPDATE Roles SET Permissions=REPLACE(Permissions, ' delete_emojis', '') WHERE builtin=True"); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := sqlSupplier.GetMaster().Exec("UPDATE Roles SET Permissions=REPLACE(Permissions, ' delete_others_emojis', '') WHERE builtin=True"); err != nil {
|
if _, err := sqlStore.GetMaster().Exec("UPDATE Roles SET Permissions=REPLACE(Permissions, ' delete_others_emojis', '') WHERE builtin=True"); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
mainHelper.GetClusterInterface().SendClearRoleCacheMessage()
|
mainHelper.GetClusterInterface().SendClearRoleCacheMessage()
|
||||||
|
|
||||||
if _, err := sqlSupplier.GetMaster().Exec("DELETE from Systems where Name = :Name", map[string]interface{}{"Name": EMOJIS_PERMISSIONS_MIGRATION_KEY}); err != nil {
|
if _, err := sqlStore.GetMaster().Exec("DELETE from Systems where Name = :Name", map[string]interface{}{"Name": EMOJIS_PERMISSIONS_MIGRATION_KEY}); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ var MaxNotificationsPerChannelDefault int64 = 1000000
|
|||||||
var SENTRY_DSN = "placeholder_sentry_dsn"
|
var SENTRY_DSN = "placeholder_sentry_dsn"
|
||||||
|
|
||||||
type Server struct {
|
type Server struct {
|
||||||
sqlStore *sqlstore.SqlSupplier
|
sqlStore *sqlstore.SqlStore
|
||||||
Store store.Store
|
Store store.Store
|
||||||
WebSocketRouter *WebSocketRouter
|
WebSocketRouter *WebSocketRouter
|
||||||
AppInitializedOnce sync.Once
|
AppInitializedOnce sync.Once
|
||||||
@@ -306,7 +306,7 @@ func NewServer(options ...Option) (*Server, error) {
|
|||||||
|
|
||||||
if s.newStore == nil {
|
if s.newStore == nil {
|
||||||
s.newStore = func() store.Store {
|
s.newStore = func() store.Store {
|
||||||
s.sqlStore = sqlstore.NewSqlSupplier(s.Config().SqlSettings, s.Metrics)
|
s.sqlStore = sqlstore.New(s.Config().SqlSettings, s.Metrics)
|
||||||
searchStore := searchlayer.NewSearchLayer(
|
searchStore := searchlayer.NewSearchLayer(
|
||||||
localcachelayer.NewLocalCacheLayer(
|
localcachelayer.NewLocalCacheLayer(
|
||||||
retrylayer.New(s.sqlStore),
|
retrylayer.New(s.sqlStore),
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ func (me *TestHelper) initBasic() *TestHelper {
|
|||||||
me.SystemAdminUser = userCache.SystemAdminUser.DeepCopy()
|
me.SystemAdminUser = userCache.SystemAdminUser.DeepCopy()
|
||||||
me.BasicUser = userCache.BasicUser.DeepCopy()
|
me.BasicUser = userCache.BasicUser.DeepCopy()
|
||||||
me.BasicUser2 = userCache.BasicUser2.DeepCopy()
|
me.BasicUser2 = userCache.BasicUser2.DeepCopy()
|
||||||
mainHelper.GetSQLSupplier().GetMaster().Insert(me.SystemAdminUser, me.BasicUser, me.BasicUser2)
|
mainHelper.GetSQLStore().GetMaster().Insert(me.SystemAdminUser, me.BasicUser, me.BasicUser2)
|
||||||
|
|
||||||
me.BasicTeam = me.createTeam()
|
me.BasicTeam = me.createTeam()
|
||||||
|
|
||||||
|
|||||||
@@ -886,8 +886,8 @@ func TestPermanentDeleteUser(t *testing.T) {
|
|||||||
var bots1 []*model.Bot
|
var bots1 []*model.Bot
|
||||||
var bots2 []*model.Bot
|
var bots2 []*model.Bot
|
||||||
|
|
||||||
sqlSupplier := mainHelper.GetSQLSupplier()
|
sqlStore := mainHelper.GetSQLStore()
|
||||||
_, err1 := sqlSupplier.GetMaster().Select(&bots1, "SELECT * FROM Bots")
|
_, err1 := sqlStore.GetMaster().Select(&bots1, "SELECT * FROM Bots")
|
||||||
assert.Nil(t, err1)
|
assert.Nil(t, err1)
|
||||||
assert.Equal(t, 1, len(bots1))
|
assert.Equal(t, 1, len(bots1))
|
||||||
|
|
||||||
@@ -898,7 +898,7 @@ func TestPermanentDeleteUser(t *testing.T) {
|
|||||||
err = th.App.PermanentDeleteUser(retUser1)
|
err = th.App.PermanentDeleteUser(retUser1)
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
|
|
||||||
_, err1 = sqlSupplier.GetMaster().Select(&bots2, "SELECT * FROM Bots")
|
_, err1 = sqlStore.GetMaster().Select(&bots2, "SELECT * FROM Bots")
|
||||||
assert.Nil(t, err1)
|
assert.Nil(t, err1)
|
||||||
assert.Equal(t, 0, len(bots2))
|
assert.Equal(t, 0, len(bots2))
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ func setupConfigDatabase(t *testing.T, cfg *model.Config, files map[string][]byt
|
|||||||
cfgData, err := config.MarshalConfig(cfg)
|
cfgData, err := config.MarshalConfig(cfg)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
db := sqlx.NewDb(mainHelper.GetSQLSupplier().GetMaster().Db, *mainHelper.GetSQLSettings().DriverName)
|
db := sqlx.NewDb(mainHelper.GetSQLStore().GetMaster().Db, *mainHelper.GetSQLSettings().DriverName)
|
||||||
err = config.InitializeConfigurationsTable(db)
|
err = config.InitializeConfigurationsTable(db)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
@@ -76,7 +76,7 @@ func getActualDatabaseConfig(t *testing.T) (string, *model.Config) {
|
|||||||
ID string `db:"id"`
|
ID string `db:"id"`
|
||||||
Value []byte `db:"value"`
|
Value []byte `db:"value"`
|
||||||
}
|
}
|
||||||
db := sqlx.NewDb(mainHelper.GetSQLSupplier().GetMaster().Db, *mainHelper.GetSQLSettings().DriverName)
|
db := sqlx.NewDb(mainHelper.GetSQLStore().GetMaster().Db, *mainHelper.GetSQLSettings().DriverName)
|
||||||
err := db.Get(&actual, "SELECT Id, Value FROM Configurations WHERE Active")
|
err := db.Get(&actual, "SELECT Id, Value FROM Configurations WHERE Active")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
@@ -89,7 +89,7 @@ func getActualDatabaseConfig(t *testing.T) (string, *model.Config) {
|
|||||||
ID string `db:"Id"`
|
ID string `db:"Id"`
|
||||||
Value []byte `db:"Value"`
|
Value []byte `db:"Value"`
|
||||||
}
|
}
|
||||||
db := sqlx.NewDb(mainHelper.GetSQLSupplier().GetMaster().Db, *mainHelper.GetSQLSettings().DriverName)
|
db := sqlx.NewDb(mainHelper.GetSQLStore().GetMaster().Db, *mainHelper.GetSQLSettings().DriverName)
|
||||||
err := db.Get(&actual, "SELECT Id, Value FROM Configurations WHERE Active")
|
err := db.Get(&actual, "SELECT Id, Value FROM Configurations WHERE Active")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
@@ -546,7 +546,7 @@ func TestDatabaseStoreSet(t *testing.T) {
|
|||||||
defer ds.Close()
|
defer ds.Close()
|
||||||
|
|
||||||
sqlSettings := mainHelper.GetSQLSettings()
|
sqlSettings := mainHelper.GetSQLSettings()
|
||||||
db := sqlx.NewDb(mainHelper.GetSQLSupplier().GetMaster().Db, *sqlSettings.DriverName)
|
db := sqlx.NewDb(mainHelper.GetSQLStore().GetMaster().Db, *sqlSettings.DriverName)
|
||||||
_, err = db.Exec("DROP TABLE Configurations")
|
_, err = db.Exec("DROP TABLE Configurations")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
@@ -794,7 +794,7 @@ func TestDatabaseStoreLoad(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
sqlSettings := mainHelper.GetSQLSettings()
|
sqlSettings := mainHelper.GetSQLSettings()
|
||||||
db := sqlx.NewDb(mainHelper.GetSQLSupplier().GetMaster().Db, *sqlSettings.DriverName)
|
db := sqlx.NewDb(mainHelper.GetSQLStore().GetMaster().Db, *sqlSettings.DriverName)
|
||||||
truncateTables(t)
|
truncateTables(t)
|
||||||
id := model.NewId()
|
id := model.NewId()
|
||||||
_, err = db.NamedExec("INSERT INTO Configurations (Id, Value, CreateAt, Active) VALUES(:Id, :Value, :CreateAt, TRUE)", map[string]interface{}{
|
_, err = db.NamedExec("INSERT INTO Configurations (Id, Value, CreateAt, Active) VALUES(:Id, :Value, :CreateAt, TRUE)", map[string]interface{}{
|
||||||
|
|||||||
@@ -34,11 +34,11 @@ func TestMain(m *testing.M) {
|
|||||||
func truncateTable(t *testing.T, table string) {
|
func truncateTable(t *testing.T, table string) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
sqlSetting := mainHelper.GetSQLSettings()
|
sqlSetting := mainHelper.GetSQLSettings()
|
||||||
sqlSupplier := mainHelper.GetSQLSupplier()
|
sqlStore := mainHelper.GetSQLStore()
|
||||||
|
|
||||||
switch *sqlSetting.DriverName {
|
switch *sqlSetting.DriverName {
|
||||||
case model.DATABASE_DRIVER_MYSQL:
|
case model.DATABASE_DRIVER_MYSQL:
|
||||||
_, err := sqlSupplier.GetMaster().Db.Exec(fmt.Sprintf("TRUNCATE TABLE %s", table))
|
_, err := sqlStore.GetMaster().Db.Exec(fmt.Sprintf("TRUNCATE TABLE %s", table))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if driverErr, ok := err.(*mysql.MySQLError); ok {
|
if driverErr, ok := err.(*mysql.MySQLError); ok {
|
||||||
// Ignore if the Configurations table does not exist.
|
// Ignore if the Configurations table does not exist.
|
||||||
@@ -50,7 +50,7 @@ func truncateTable(t *testing.T, table string) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
case model.DATABASE_DRIVER_POSTGRES:
|
case model.DATABASE_DRIVER_POSTGRES:
|
||||||
_, err := sqlSupplier.GetMaster().Db.Exec(fmt.Sprintf("TRUNCATE TABLE %s", table))
|
_, err := sqlStore.GetMaster().Db.Exec(fmt.Sprintf("TRUNCATE TABLE %s", table))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if driverErr, ok := err.(*pq.Error); ok {
|
if driverErr, ok := err.(*pq.Error); ok {
|
||||||
// Ignore if the Configurations table does not exist.
|
// Ignore if the Configurations table does not exist.
|
||||||
|
|||||||
@@ -252,14 +252,14 @@ func (me *TestHelper) TearDown() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (me *TestHelper) ResetRoleMigration() {
|
func (me *TestHelper) ResetRoleMigration() {
|
||||||
sqlSupplier := mainHelper.GetSQLSupplier()
|
sqlStore := mainHelper.GetSQLStore()
|
||||||
if _, err := sqlSupplier.GetMaster().Exec("DELETE from Roles"); err != nil {
|
if _, err := sqlStore.GetMaster().Exec("DELETE from Roles"); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
mainHelper.GetClusterInterface().SendClearRoleCacheMessage()
|
mainHelper.GetClusterInterface().SendClearRoleCacheMessage()
|
||||||
|
|
||||||
if _, err := sqlSupplier.GetMaster().Exec("DELETE from Systems where Name = :Name", map[string]interface{}{"Name": model.ADVANCED_PERMISSIONS_MIGRATION_KEY}); err != nil {
|
if _, err := sqlStore.GetMaster().Exec("DELETE from Systems where Name = :Name", map[string]interface{}{"Name": model.ADVANCED_PERMISSIONS_MIGRATION_KEY}); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ type BleveEngineTestSuite struct {
|
|||||||
suite.Suite
|
suite.Suite
|
||||||
|
|
||||||
SQLSettings *model.SqlSettings
|
SQLSettings *model.SqlSettings
|
||||||
SQLSupplier *sqlstore.SqlSupplier
|
SQLStore *sqlstore.SqlStore
|
||||||
SearchEngine *searchengine.Broker
|
SearchEngine *searchengine.Broker
|
||||||
Store *searchlayer.SearchStore
|
Store *searchlayer.SearchStore
|
||||||
BleveEngine *BleveEngine
|
BleveEngine *BleveEngine
|
||||||
@@ -50,7 +50,7 @@ func (s *BleveEngineTestSuite) setupStore() {
|
|||||||
driverName = model.DATABASE_DRIVER_POSTGRES
|
driverName = model.DATABASE_DRIVER_POSTGRES
|
||||||
}
|
}
|
||||||
s.SQLSettings = storetest.MakeSqlSettings(driverName)
|
s.SQLSettings = storetest.MakeSqlSettings(driverName)
|
||||||
s.SQLSupplier = sqlstore.NewSqlSupplier(*s.SQLSettings, nil)
|
s.SQLStore = sqlstore.New(*s.SQLSettings, nil)
|
||||||
|
|
||||||
cfg := &model.Config{}
|
cfg := &model.Config{}
|
||||||
cfg.SetDefaults()
|
cfg.SetDefaults()
|
||||||
@@ -61,7 +61,7 @@ func (s *BleveEngineTestSuite) setupStore() {
|
|||||||
cfg.SqlSettings.DisableDatabaseSearch = model.NewBool(true)
|
cfg.SqlSettings.DisableDatabaseSearch = model.NewBool(true)
|
||||||
|
|
||||||
s.SearchEngine = searchengine.NewBroker(cfg, nil)
|
s.SearchEngine = searchengine.NewBroker(cfg, nil)
|
||||||
s.Store = searchlayer.NewSearchLayer(&testlib.TestStore{Store: s.SQLSupplier}, s.SearchEngine, cfg)
|
s.Store = searchlayer.NewSearchLayer(&testlib.TestStore{Store: s.SQLStore}, s.SearchEngine, cfg)
|
||||||
|
|
||||||
s.BleveEngine = NewBleveEngine(cfg, nil)
|
s.BleveEngine = NewBleveEngine(cfg, nil)
|
||||||
s.BleveEngine.indexSync = true
|
s.BleveEngine.indexSync = true
|
||||||
@@ -78,7 +78,7 @@ func (s *BleveEngineTestSuite) SetupSuite() {
|
|||||||
|
|
||||||
func (s *BleveEngineTestSuite) TearDownSuite() {
|
func (s *BleveEngineTestSuite) TearDownSuite() {
|
||||||
os.RemoveAll(s.IndexDir)
|
os.RemoveAll(s.IndexDir)
|
||||||
s.SQLSupplier.Close()
|
s.SQLStore.Close()
|
||||||
storetest.CleanupSqlSettings(s.SQLSettings)
|
storetest.CleanupSqlSettings(s.SQLSettings)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import (
|
|||||||
type storeType struct {
|
type storeType struct {
|
||||||
Name string
|
Name string
|
||||||
SqlSettings *model.SqlSettings
|
SqlSettings *model.SqlSettings
|
||||||
SqlSupplier *sqlstore.SqlSupplier
|
SqlStore *sqlstore.SqlStore
|
||||||
Store store.Store
|
Store store.Store
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ func StoreTest(t *testing.T, f func(*testing.T, store.Store)) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func StoreTestWithSqlSupplier(t *testing.T, f func(*testing.T, store.Store, storetest.SqlSupplier)) {
|
func StoreTestWithSqlStore(t *testing.T, f func(*testing.T, store.Store, storetest.SqlStore)) {
|
||||||
defer func() {
|
defer func() {
|
||||||
if err := recover(); err != nil {
|
if err := recover(); err != nil {
|
||||||
tearDownStores()
|
tearDownStores()
|
||||||
@@ -61,7 +61,7 @@ func StoreTestWithSqlSupplier(t *testing.T, f func(*testing.T, store.Store, stor
|
|||||||
if testing.Short() {
|
if testing.Short() {
|
||||||
t.SkipNow()
|
t.SkipNow()
|
||||||
}
|
}
|
||||||
f(t, st.Store, st.SqlSupplier)
|
f(t, st.Store, st.SqlStore)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -97,8 +97,8 @@ func initStores() {
|
|||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
st.SqlSupplier = sqlstore.NewSqlSupplier(*st.SqlSettings, nil)
|
st.SqlStore = sqlstore.New(*st.SqlSettings, nil)
|
||||||
st.Store = NewLocalCacheLayer(st.SqlSupplier, nil, nil, getMockCacheProvider())
|
st.Store = NewLocalCacheLayer(st.SqlStore, nil, nil, getMockCacheProvider())
|
||||||
st.Store.DropAllTables()
|
st.Store.DropAllTables()
|
||||||
st.Store.MarkSystemRanUnitTests()
|
st.Store.MarkSystemRanUnitTests()
|
||||||
}()
|
}()
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestPostStore(t *testing.T) {
|
func TestPostStore(t *testing.T) {
|
||||||
StoreTestWithSqlSupplier(t, storetest.TestPostStore)
|
StoreTestWithSqlStore(t, storetest.TestPostStore)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPostStoreLastPostTimeCache(t *testing.T) {
|
func TestPostStoreLastPostTimeCache(t *testing.T) {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestRoleStore(t *testing.T) {
|
func TestRoleStore(t *testing.T) {
|
||||||
StoreTestWithSqlSupplier(t, storetest.TestRoleStore)
|
StoreTestWithSqlStore(t, storetest.TestRoleStore)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRoleStoreCache(t *testing.T) {
|
func TestRoleStoreCache(t *testing.T) {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestUserStore(t *testing.T) {
|
func TestUserStore(t *testing.T) {
|
||||||
StoreTestWithSqlSupplier(t, storetest.TestUserStore)
|
StoreTestWithSqlStore(t, storetest.TestUserStore)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestUserStoreCache(t *testing.T) {
|
func TestUserStoreCache(t *testing.T) {
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ func TestUpdateConfigRace(t *testing.T) {
|
|||||||
driverName = model.DATABASE_DRIVER_POSTGRES
|
driverName = model.DATABASE_DRIVER_POSTGRES
|
||||||
}
|
}
|
||||||
settings := storetest.MakeSqlSettings(driverName)
|
settings := storetest.MakeSqlSettings(driverName)
|
||||||
store := sqlstore.NewSqlSupplier(*settings, nil)
|
store := sqlstore.New(*settings, nil)
|
||||||
|
|
||||||
cfg := &model.Config{}
|
cfg := &model.Config{}
|
||||||
cfg.SetDefaults()
|
cfg.SetDefaults()
|
||||||
|
|||||||
@@ -12,13 +12,13 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type SqlAuditStore struct {
|
type SqlAuditStore struct {
|
||||||
*SqlSupplier
|
*SqlStore
|
||||||
}
|
}
|
||||||
|
|
||||||
func newSqlAuditStore(sqlSupplier *SqlSupplier) store.AuditStore {
|
func newSqlAuditStore(sqlStore *SqlStore) store.AuditStore {
|
||||||
s := &SqlAuditStore{sqlSupplier}
|
s := &SqlAuditStore{sqlStore}
|
||||||
|
|
||||||
for _, db := range sqlSupplier.GetAllConns() {
|
for _, db := range sqlStore.GetAllConns() {
|
||||||
table := db.AddTableWithName(model.Audit{}, "Audits").SetKeys(false, "Id")
|
table := db.AddTableWithName(model.Audit{}, "Audits").SetKeys(false, "Id")
|
||||||
table.ColMap("Id").SetMaxSize(26)
|
table.ColMap("Id").SetMaxSize(26)
|
||||||
table.ColMap("UserId").SetMaxSize(26)
|
table.ColMap("UserId").SetMaxSize(26)
|
||||||
|
|||||||
@@ -42,18 +42,18 @@ func botFromModel(b *model.Bot) *bot {
|
|||||||
// Bots are otherwise normal users with extra metadata record in the Bots table. The primary key
|
// Bots are otherwise normal users with extra metadata record in the Bots table. The primary key
|
||||||
// for a bot matches the primary key value for corresponding User record.
|
// for a bot matches the primary key value for corresponding User record.
|
||||||
type SqlBotStore struct {
|
type SqlBotStore struct {
|
||||||
*SqlSupplier
|
*SqlStore
|
||||||
metrics einterfaces.MetricsInterface
|
metrics einterfaces.MetricsInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
// newSqlBotStore creates an instance of SqlBotStore, registering the table schema in question.
|
// newSqlBotStore creates an instance of SqlBotStore, registering the table schema in question.
|
||||||
func newSqlBotStore(sqlSupplier *SqlSupplier, metrics einterfaces.MetricsInterface) store.BotStore {
|
func newSqlBotStore(sqlStore *SqlStore, metrics einterfaces.MetricsInterface) store.BotStore {
|
||||||
us := &SqlBotStore{
|
us := &SqlBotStore{
|
||||||
SqlSupplier: sqlSupplier,
|
SqlStore: sqlStore,
|
||||||
metrics: metrics,
|
metrics: metrics,
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, db := range sqlSupplier.GetAllConns() {
|
for _, db := range sqlStore.GetAllConns() {
|
||||||
table := db.AddTableWithName(bot{}, "Bots").SetKeys(false, "UserId")
|
table := db.AddTableWithName(bot{}, "Bots").SetKeys(false, "UserId")
|
||||||
table.ColMap("UserId").SetMaxSize(26)
|
table.ColMap("UserId").SetMaxSize(26)
|
||||||
table.ColMap("Description").SetMaxSize(1024)
|
table.ColMap("Description").SetMaxSize(1024)
|
||||||
|
|||||||
@@ -10,5 +10,5 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestBotStore(t *testing.T) {
|
func TestBotStore(t *testing.T) {
|
||||||
StoreTestWithSqlSupplier(t, storetest.TestBotStore)
|
StoreTestWithSqlStore(t, storetest.TestBotStore)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,15 +17,15 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type SqlChannelMemberHistoryStore struct {
|
type SqlChannelMemberHistoryStore struct {
|
||||||
*SqlSupplier
|
*SqlStore
|
||||||
}
|
}
|
||||||
|
|
||||||
func newSqlChannelMemberHistoryStore(sqlSupplier *SqlSupplier) store.ChannelMemberHistoryStore {
|
func newSqlChannelMemberHistoryStore(sqlStore *SqlStore) store.ChannelMemberHistoryStore {
|
||||||
s := &SqlChannelMemberHistoryStore{
|
s := &SqlChannelMemberHistoryStore{
|
||||||
SqlSupplier: sqlSupplier,
|
SqlStore: sqlStore,
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, db := range sqlSupplier.GetAllConns() {
|
for _, db := range sqlStore.GetAllConns() {
|
||||||
table := db.AddTableWithName(model.ChannelMemberHistory{}, "ChannelMemberHistory").SetKeys(false, "ChannelId", "UserId", "JoinTime")
|
table := db.AddTableWithName(model.ChannelMemberHistory{}, "ChannelMemberHistory").SetKeys(false, "ChannelId", "UserId", "JoinTime")
|
||||||
table.ColMap("ChannelId").SetMaxSize(26)
|
table.ColMap("ChannelId").SetMaxSize(26)
|
||||||
table.ColMap("UserId").SetMaxSize(26)
|
table.ColMap("UserId").SetMaxSize(26)
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type SqlChannelStore struct {
|
type SqlChannelStore struct {
|
||||||
*SqlSupplier
|
*SqlStore
|
||||||
metrics einterfaces.MetricsInterface
|
metrics einterfaces.MetricsInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -356,13 +356,13 @@ func (s SqlChannelStore) ClearCaches() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func newSqlChannelStore(sqlSupplier *SqlSupplier, metrics einterfaces.MetricsInterface) store.ChannelStore {
|
func newSqlChannelStore(sqlStore *SqlStore, metrics einterfaces.MetricsInterface) store.ChannelStore {
|
||||||
s := &SqlChannelStore{
|
s := &SqlChannelStore{
|
||||||
SqlSupplier: sqlSupplier,
|
SqlStore: sqlStore,
|
||||||
metrics: metrics,
|
metrics: metrics,
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, db := range sqlSupplier.GetAllConns() {
|
for _, db := range sqlStore.GetAllConns() {
|
||||||
table := db.AddTableWithName(model.Channel{}, "Channels").SetKeys(false, "Id")
|
table := db.AddTableWithName(model.Channel{}, "Channels").SetKeys(false, "Id")
|
||||||
table.ColMap("Id").SetMaxSize(26)
|
table.ColMap("Id").SetMaxSize(26)
|
||||||
table.ColMap("TeamId").SetMaxSize(26)
|
table.ColMap("TeamId").SetMaxSize(26)
|
||||||
|
|||||||
@@ -10,5 +10,5 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestChannelStoreCategories(t *testing.T) {
|
func TestChannelStoreCategories(t *testing.T) {
|
||||||
StoreTestWithSqlSupplier(t, storetest.TestChannelStoreCategories)
|
StoreTestWithSqlStore(t, storetest.TestChannelStoreCategories)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestChannelStore(t *testing.T) {
|
func TestChannelStore(t *testing.T) {
|
||||||
StoreTestWithSqlSupplier(t, storetest.TestChannelStore)
|
StoreTestWithSqlStore(t, storetest.TestChannelStore)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSearchChannelStore(t *testing.T) {
|
func TestSearchChannelStore(t *testing.T) {
|
||||||
@@ -28,7 +28,7 @@ func TestChannelSearchQuerySQLInjection(t *testing.T) {
|
|||||||
for _, st := range storeTypes {
|
for _, st := range storeTypes {
|
||||||
t.Run(st.Name, func(t *testing.T) {
|
t.Run(st.Name, func(t *testing.T) {
|
||||||
s := &SqlChannelStore{
|
s := &SqlChannelStore{
|
||||||
SqlSupplier: st.SqlSupplier,
|
SqlStore: st.SqlStore,
|
||||||
}
|
}
|
||||||
|
|
||||||
opts := store.ChannelSearchOpts{}
|
opts := store.ChannelSearchOpts{}
|
||||||
|
|||||||
@@ -12,13 +12,13 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type sqlClusterDiscoveryStore struct {
|
type sqlClusterDiscoveryStore struct {
|
||||||
*SqlSupplier
|
*SqlStore
|
||||||
}
|
}
|
||||||
|
|
||||||
func newSqlClusterDiscoveryStore(sqlSupplier *SqlSupplier) store.ClusterDiscoveryStore {
|
func newSqlClusterDiscoveryStore(sqlStore *SqlStore) store.ClusterDiscoveryStore {
|
||||||
s := &sqlClusterDiscoveryStore{sqlSupplier}
|
s := &sqlClusterDiscoveryStore{sqlStore}
|
||||||
|
|
||||||
for _, db := range sqlSupplier.GetAllConns() {
|
for _, db := range sqlStore.GetAllConns() {
|
||||||
table := db.AddTableWithName(model.ClusterDiscovery{}, "ClusterDiscovery").SetKeys(false, "Id")
|
table := db.AddTableWithName(model.ClusterDiscovery{}, "ClusterDiscovery").SetKeys(false, "Id")
|
||||||
table.ColMap("Id").SetMaxSize(26)
|
table.ColMap("Id").SetMaxSize(26)
|
||||||
table.ColMap("Type").SetMaxSize(64)
|
table.ColMap("Type").SetMaxSize(64)
|
||||||
|
|||||||
@@ -14,18 +14,18 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type SqlCommandStore struct {
|
type SqlCommandStore struct {
|
||||||
*SqlSupplier
|
*SqlStore
|
||||||
|
|
||||||
commandsQuery sq.SelectBuilder
|
commandsQuery sq.SelectBuilder
|
||||||
}
|
}
|
||||||
|
|
||||||
func newSqlCommandStore(sqlSupplier *SqlSupplier) store.CommandStore {
|
func newSqlCommandStore(sqlStore *SqlStore) store.CommandStore {
|
||||||
s := &SqlCommandStore{SqlSupplier: sqlSupplier}
|
s := &SqlCommandStore{SqlStore: sqlStore}
|
||||||
|
|
||||||
s.commandsQuery = s.getQueryBuilder().
|
s.commandsQuery = s.getQueryBuilder().
|
||||||
Select("*").
|
Select("*").
|
||||||
From("Commands")
|
From("Commands")
|
||||||
for _, db := range sqlSupplier.GetAllConns() {
|
for _, db := range sqlStore.GetAllConns() {
|
||||||
tableo := db.AddTableWithName(model.Command{}, "Commands").SetKeys(false, "Id")
|
tableo := db.AddTableWithName(model.Command{}, "Commands").SetKeys(false, "Id")
|
||||||
tableo.ColMap("Id").SetMaxSize(26)
|
tableo.ColMap("Id").SetMaxSize(26)
|
||||||
tableo.ColMap("Token").SetMaxSize(26)
|
tableo.ColMap("Token").SetMaxSize(26)
|
||||||
|
|||||||
@@ -16,13 +16,13 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type SqlCommandWebhookStore struct {
|
type SqlCommandWebhookStore struct {
|
||||||
*SqlSupplier
|
*SqlStore
|
||||||
}
|
}
|
||||||
|
|
||||||
func newSqlCommandWebhookStore(sqlSupplier *SqlSupplier) store.CommandWebhookStore {
|
func newSqlCommandWebhookStore(sqlStore *SqlStore) store.CommandWebhookStore {
|
||||||
s := &SqlCommandWebhookStore{sqlSupplier}
|
s := &SqlCommandWebhookStore{sqlStore}
|
||||||
|
|
||||||
for _, db := range sqlSupplier.GetAllConns() {
|
for _, db := range sqlStore.GetAllConns() {
|
||||||
tablec := db.AddTableWithName(model.CommandWebhook{}, "CommandWebhooks").SetKeys(false, "Id")
|
tablec := db.AddTableWithName(model.CommandWebhook{}, "CommandWebhooks").SetKeys(false, "Id")
|
||||||
tablec.ColMap("Id").SetMaxSize(26)
|
tablec.ColMap("Id").SetMaxSize(26)
|
||||||
tablec.ColMap("CommandId").SetMaxSize(26)
|
tablec.ColMap("CommandId").SetMaxSize(26)
|
||||||
|
|||||||
@@ -14,13 +14,13 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type SqlComplianceStore struct {
|
type SqlComplianceStore struct {
|
||||||
*SqlSupplier
|
*SqlStore
|
||||||
}
|
}
|
||||||
|
|
||||||
func newSqlComplianceStore(sqlSupplier *SqlSupplier) store.ComplianceStore {
|
func newSqlComplianceStore(sqlStore *SqlStore) store.ComplianceStore {
|
||||||
s := &SqlComplianceStore{sqlSupplier}
|
s := &SqlComplianceStore{sqlStore}
|
||||||
|
|
||||||
for _, db := range sqlSupplier.GetAllConns() {
|
for _, db := range sqlStore.GetAllConns() {
|
||||||
table := db.AddTableWithName(model.Compliance{}, "Compliances").SetKeys(false, "Id")
|
table := db.AddTableWithName(model.Compliance{}, "Compliances").SetKeys(false, "Id")
|
||||||
table.ColMap("Id").SetMaxSize(26)
|
table.ColMap("Id").SetMaxSize(26)
|
||||||
table.ColMap("UserId").SetMaxSize(26)
|
table.ColMap("UserId").SetMaxSize(26)
|
||||||
|
|||||||
@@ -15,17 +15,17 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type SqlEmojiStore struct {
|
type SqlEmojiStore struct {
|
||||||
*SqlSupplier
|
*SqlStore
|
||||||
metrics einterfaces.MetricsInterface
|
metrics einterfaces.MetricsInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
func newSqlEmojiStore(sqlSupplier *SqlSupplier, metrics einterfaces.MetricsInterface) store.EmojiStore {
|
func newSqlEmojiStore(sqlStore *SqlStore, metrics einterfaces.MetricsInterface) store.EmojiStore {
|
||||||
s := &SqlEmojiStore{
|
s := &SqlEmojiStore{
|
||||||
SqlSupplier: sqlSupplier,
|
SqlStore: sqlStore,
|
||||||
metrics: metrics,
|
metrics: metrics,
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, db := range sqlSupplier.GetAllConns() {
|
for _, db := range sqlStore.GetAllConns() {
|
||||||
table := db.AddTableWithName(model.Emoji{}, "Emoji").SetKeys(false, "Id")
|
table := db.AddTableWithName(model.Emoji{}, "Emoji").SetKeys(false, "Id")
|
||||||
table.ColMap("Id").SetMaxSize(26)
|
table.ColMap("Id").SetMaxSize(26)
|
||||||
table.ColMap("CreatorId").SetMaxSize(26)
|
table.ColMap("CreatorId").SetMaxSize(26)
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type SqlFileInfoStore struct {
|
type SqlFileInfoStore struct {
|
||||||
*SqlSupplier
|
*SqlStore
|
||||||
metrics einterfaces.MetricsInterface
|
metrics einterfaces.MetricsInterface
|
||||||
queryFields []string
|
queryFields []string
|
||||||
}
|
}
|
||||||
@@ -24,10 +24,10 @@ type SqlFileInfoStore struct {
|
|||||||
func (fs SqlFileInfoStore) ClearCaches() {
|
func (fs SqlFileInfoStore) ClearCaches() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func newSqlFileInfoStore(sqlSupplier *SqlSupplier, metrics einterfaces.MetricsInterface) store.FileInfoStore {
|
func newSqlFileInfoStore(sqlStore *SqlStore, metrics einterfaces.MetricsInterface) store.FileInfoStore {
|
||||||
s := &SqlFileInfoStore{
|
s := &SqlFileInfoStore{
|
||||||
SqlSupplier: sqlSupplier,
|
SqlStore: sqlStore,
|
||||||
metrics: metrics,
|
metrics: metrics,
|
||||||
}
|
}
|
||||||
|
|
||||||
s.queryFields = []string{
|
s.queryFields = []string{
|
||||||
@@ -51,7 +51,7 @@ func newSqlFileInfoStore(sqlSupplier *SqlSupplier, metrics einterfaces.MetricsIn
|
|||||||
"Coalesce(FileInfo.Content, '') AS Content",
|
"Coalesce(FileInfo.Content, '') AS Content",
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, db := range sqlSupplier.GetAllConns() {
|
for _, db := range sqlStore.GetAllConns() {
|
||||||
table := db.AddTableWithName(model.FileInfo{}, "FileInfo").SetKeys(false, "Id")
|
table := db.AddTableWithName(model.FileInfo{}, "FileInfo").SetKeys(false, "Id")
|
||||||
table.ColMap("Id").SetMaxSize(26)
|
table.ColMap("Id").SetMaxSize(26)
|
||||||
table.ColMap("CreatorId").SetMaxSize(26)
|
table.ColMap("CreatorId").SetMaxSize(26)
|
||||||
|
|||||||
@@ -48,12 +48,12 @@ type groupChannelJoin struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type SqlGroupStore struct {
|
type SqlGroupStore struct {
|
||||||
*SqlSupplier
|
*SqlStore
|
||||||
}
|
}
|
||||||
|
|
||||||
func newSqlGroupStore(sqlSupplier *SqlSupplier) store.GroupStore {
|
func newSqlGroupStore(sqlStore *SqlStore) store.GroupStore {
|
||||||
s := &SqlGroupStore{SqlSupplier: sqlSupplier}
|
s := &SqlGroupStore{SqlStore: sqlStore}
|
||||||
for _, db := range sqlSupplier.GetAllConns() {
|
for _, db := range sqlStore.GetAllConns() {
|
||||||
groups := db.AddTableWithName(model.Group{}, "UserGroups").SetKeys(false, "Id")
|
groups := db.AddTableWithName(model.Group{}, "UserGroups").SetKeys(false, "Id")
|
||||||
groups.ColMap("Id").SetMaxSize(26)
|
groups.ColMap("Id").SetMaxSize(26)
|
||||||
groups.ColMap("Name").SetMaxSize(model.GroupNameMaxLength).SetUnique(true)
|
groups.ColMap("Name").SetMaxSize(model.GroupNameMaxLength).SetUnique(true)
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ type relationalCheckConfig struct {
|
|||||||
filter interface{}
|
filter interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getOrphanedRecords(ss *SqlSupplier, cfg relationalCheckConfig) ([]model.OrphanedRecord, error) {
|
func getOrphanedRecords(ss *SqlStore, cfg relationalCheckConfig) ([]model.OrphanedRecord, error) {
|
||||||
var records []model.OrphanedRecord
|
var records []model.OrphanedRecord
|
||||||
|
|
||||||
sub := ss.getQueryBuilder().
|
sub := ss.getQueryBuilder().
|
||||||
@@ -59,7 +59,7 @@ func getOrphanedRecords(ss *SqlSupplier, cfg relationalCheckConfig) ([]model.Orp
|
|||||||
return records, err
|
return records, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkParentChildIntegrity(ss *SqlSupplier, config relationalCheckConfig) model.IntegrityCheckResult {
|
func checkParentChildIntegrity(ss *SqlStore, config relationalCheckConfig) model.IntegrityCheckResult {
|
||||||
var result model.IntegrityCheckResult
|
var result model.IntegrityCheckResult
|
||||||
var data model.RelationalIntegrityCheckData
|
var data model.RelationalIntegrityCheckData
|
||||||
|
|
||||||
@@ -78,7 +78,7 @@ func checkParentChildIntegrity(ss *SqlSupplier, config relationalCheckConfig) mo
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkChannelsCommandWebhooksIntegrity(ss *SqlSupplier) model.IntegrityCheckResult {
|
func checkChannelsCommandWebhooksIntegrity(ss *SqlStore) model.IntegrityCheckResult {
|
||||||
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
||||||
parentName: "Channels",
|
parentName: "Channels",
|
||||||
parentIdAttr: "ChannelId",
|
parentIdAttr: "ChannelId",
|
||||||
@@ -87,7 +87,7 @@ func checkChannelsCommandWebhooksIntegrity(ss *SqlSupplier) model.IntegrityCheck
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkChannelsChannelMemberHistoryIntegrity(ss *SqlSupplier) model.IntegrityCheckResult {
|
func checkChannelsChannelMemberHistoryIntegrity(ss *SqlStore) model.IntegrityCheckResult {
|
||||||
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
||||||
parentName: "Channels",
|
parentName: "Channels",
|
||||||
parentIdAttr: "ChannelId",
|
parentIdAttr: "ChannelId",
|
||||||
@@ -96,7 +96,7 @@ func checkChannelsChannelMemberHistoryIntegrity(ss *SqlSupplier) model.Integrity
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkChannelsChannelMembersIntegrity(ss *SqlSupplier) model.IntegrityCheckResult {
|
func checkChannelsChannelMembersIntegrity(ss *SqlStore) model.IntegrityCheckResult {
|
||||||
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
||||||
parentName: "Channels",
|
parentName: "Channels",
|
||||||
parentIdAttr: "ChannelId",
|
parentIdAttr: "ChannelId",
|
||||||
@@ -105,7 +105,7 @@ func checkChannelsChannelMembersIntegrity(ss *SqlSupplier) model.IntegrityCheckR
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkChannelsIncomingWebhooksIntegrity(ss *SqlSupplier) model.IntegrityCheckResult {
|
func checkChannelsIncomingWebhooksIntegrity(ss *SqlStore) model.IntegrityCheckResult {
|
||||||
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
||||||
parentName: "Channels",
|
parentName: "Channels",
|
||||||
parentIdAttr: "ChannelId",
|
parentIdAttr: "ChannelId",
|
||||||
@@ -114,7 +114,7 @@ func checkChannelsIncomingWebhooksIntegrity(ss *SqlSupplier) model.IntegrityChec
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkChannelsOutgoingWebhooksIntegrity(ss *SqlSupplier) model.IntegrityCheckResult {
|
func checkChannelsOutgoingWebhooksIntegrity(ss *SqlStore) model.IntegrityCheckResult {
|
||||||
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
||||||
parentName: "Channels",
|
parentName: "Channels",
|
||||||
parentIdAttr: "ChannelId",
|
parentIdAttr: "ChannelId",
|
||||||
@@ -123,7 +123,7 @@ func checkChannelsOutgoingWebhooksIntegrity(ss *SqlSupplier) model.IntegrityChec
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkChannelsPostsIntegrity(ss *SqlSupplier) model.IntegrityCheckResult {
|
func checkChannelsPostsIntegrity(ss *SqlStore) model.IntegrityCheckResult {
|
||||||
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
||||||
parentName: "Channels",
|
parentName: "Channels",
|
||||||
parentIdAttr: "ChannelId",
|
parentIdAttr: "ChannelId",
|
||||||
@@ -132,7 +132,7 @@ func checkChannelsPostsIntegrity(ss *SqlSupplier) model.IntegrityCheckResult {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkCommandsCommandWebhooksIntegrity(ss *SqlSupplier) model.IntegrityCheckResult {
|
func checkCommandsCommandWebhooksIntegrity(ss *SqlStore) model.IntegrityCheckResult {
|
||||||
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
||||||
parentName: "Commands",
|
parentName: "Commands",
|
||||||
parentIdAttr: "CommandId",
|
parentIdAttr: "CommandId",
|
||||||
@@ -141,7 +141,7 @@ func checkCommandsCommandWebhooksIntegrity(ss *SqlSupplier) model.IntegrityCheck
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkPostsFileInfoIntegrity(ss *SqlSupplier) model.IntegrityCheckResult {
|
func checkPostsFileInfoIntegrity(ss *SqlStore) model.IntegrityCheckResult {
|
||||||
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
||||||
parentName: "Posts",
|
parentName: "Posts",
|
||||||
parentIdAttr: "PostId",
|
parentIdAttr: "PostId",
|
||||||
@@ -150,7 +150,7 @@ func checkPostsFileInfoIntegrity(ss *SqlSupplier) model.IntegrityCheckResult {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkPostsPostsParentIdIntegrity(ss *SqlSupplier) model.IntegrityCheckResult {
|
func checkPostsPostsParentIdIntegrity(ss *SqlStore) model.IntegrityCheckResult {
|
||||||
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
||||||
parentName: "Posts",
|
parentName: "Posts",
|
||||||
parentIdAttr: "ParentId",
|
parentIdAttr: "ParentId",
|
||||||
@@ -160,7 +160,7 @@ func checkPostsPostsParentIdIntegrity(ss *SqlSupplier) model.IntegrityCheckResul
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkPostsPostsRootIdIntegrity(ss *SqlSupplier) model.IntegrityCheckResult {
|
func checkPostsPostsRootIdIntegrity(ss *SqlStore) model.IntegrityCheckResult {
|
||||||
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
||||||
parentName: "Posts",
|
parentName: "Posts",
|
||||||
parentIdAttr: "RootId",
|
parentIdAttr: "RootId",
|
||||||
@@ -170,7 +170,7 @@ func checkPostsPostsRootIdIntegrity(ss *SqlSupplier) model.IntegrityCheckResult
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkPostsReactionsIntegrity(ss *SqlSupplier) model.IntegrityCheckResult {
|
func checkPostsReactionsIntegrity(ss *SqlStore) model.IntegrityCheckResult {
|
||||||
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
||||||
parentName: "Posts",
|
parentName: "Posts",
|
||||||
parentIdAttr: "PostId",
|
parentIdAttr: "PostId",
|
||||||
@@ -179,7 +179,7 @@ func checkPostsReactionsIntegrity(ss *SqlSupplier) model.IntegrityCheckResult {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkSchemesChannelsIntegrity(ss *SqlSupplier) model.IntegrityCheckResult {
|
func checkSchemesChannelsIntegrity(ss *SqlStore) model.IntegrityCheckResult {
|
||||||
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
||||||
parentName: "Schemes",
|
parentName: "Schemes",
|
||||||
parentIdAttr: "SchemeId",
|
parentIdAttr: "SchemeId",
|
||||||
@@ -189,7 +189,7 @@ func checkSchemesChannelsIntegrity(ss *SqlSupplier) model.IntegrityCheckResult {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkSchemesTeamsIntegrity(ss *SqlSupplier) model.IntegrityCheckResult {
|
func checkSchemesTeamsIntegrity(ss *SqlStore) model.IntegrityCheckResult {
|
||||||
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
||||||
parentName: "Schemes",
|
parentName: "Schemes",
|
||||||
parentIdAttr: "SchemeId",
|
parentIdAttr: "SchemeId",
|
||||||
@@ -199,7 +199,7 @@ func checkSchemesTeamsIntegrity(ss *SqlSupplier) model.IntegrityCheckResult {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkSessionsAuditsIntegrity(ss *SqlSupplier) model.IntegrityCheckResult {
|
func checkSessionsAuditsIntegrity(ss *SqlStore) model.IntegrityCheckResult {
|
||||||
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
||||||
parentName: "Sessions",
|
parentName: "Sessions",
|
||||||
parentIdAttr: "SessionId",
|
parentIdAttr: "SessionId",
|
||||||
@@ -209,7 +209,7 @@ func checkSessionsAuditsIntegrity(ss *SqlSupplier) model.IntegrityCheckResult {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkTeamsChannelsIntegrity(ss *SqlSupplier) model.IntegrityCheckResult {
|
func checkTeamsChannelsIntegrity(ss *SqlStore) model.IntegrityCheckResult {
|
||||||
res1 := checkParentChildIntegrity(ss, relationalCheckConfig{
|
res1 := checkParentChildIntegrity(ss, relationalCheckConfig{
|
||||||
parentName: "Teams",
|
parentName: "Teams",
|
||||||
parentIdAttr: "TeamId",
|
parentIdAttr: "TeamId",
|
||||||
@@ -232,7 +232,7 @@ func checkTeamsChannelsIntegrity(ss *SqlSupplier) model.IntegrityCheckResult {
|
|||||||
return res1
|
return res1
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkTeamsCommandsIntegrity(ss *SqlSupplier) model.IntegrityCheckResult {
|
func checkTeamsCommandsIntegrity(ss *SqlStore) model.IntegrityCheckResult {
|
||||||
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
||||||
parentName: "Teams",
|
parentName: "Teams",
|
||||||
parentIdAttr: "TeamId",
|
parentIdAttr: "TeamId",
|
||||||
@@ -241,7 +241,7 @@ func checkTeamsCommandsIntegrity(ss *SqlSupplier) model.IntegrityCheckResult {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkTeamsIncomingWebhooksIntegrity(ss *SqlSupplier) model.IntegrityCheckResult {
|
func checkTeamsIncomingWebhooksIntegrity(ss *SqlStore) model.IntegrityCheckResult {
|
||||||
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
||||||
parentName: "Teams",
|
parentName: "Teams",
|
||||||
parentIdAttr: "TeamId",
|
parentIdAttr: "TeamId",
|
||||||
@@ -250,7 +250,7 @@ func checkTeamsIncomingWebhooksIntegrity(ss *SqlSupplier) model.IntegrityCheckRe
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkTeamsOutgoingWebhooksIntegrity(ss *SqlSupplier) model.IntegrityCheckResult {
|
func checkTeamsOutgoingWebhooksIntegrity(ss *SqlStore) model.IntegrityCheckResult {
|
||||||
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
||||||
parentName: "Teams",
|
parentName: "Teams",
|
||||||
parentIdAttr: "TeamId",
|
parentIdAttr: "TeamId",
|
||||||
@@ -259,7 +259,7 @@ func checkTeamsOutgoingWebhooksIntegrity(ss *SqlSupplier) model.IntegrityCheckRe
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkTeamsTeamMembersIntegrity(ss *SqlSupplier) model.IntegrityCheckResult {
|
func checkTeamsTeamMembersIntegrity(ss *SqlStore) model.IntegrityCheckResult {
|
||||||
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
||||||
parentName: "Teams",
|
parentName: "Teams",
|
||||||
parentIdAttr: "TeamId",
|
parentIdAttr: "TeamId",
|
||||||
@@ -268,7 +268,7 @@ func checkTeamsTeamMembersIntegrity(ss *SqlSupplier) model.IntegrityCheckResult
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkUsersAuditsIntegrity(ss *SqlSupplier) model.IntegrityCheckResult {
|
func checkUsersAuditsIntegrity(ss *SqlStore) model.IntegrityCheckResult {
|
||||||
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
||||||
parentName: "Users",
|
parentName: "Users",
|
||||||
parentIdAttr: "UserId",
|
parentIdAttr: "UserId",
|
||||||
@@ -278,7 +278,7 @@ func checkUsersAuditsIntegrity(ss *SqlSupplier) model.IntegrityCheckResult {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkUsersCommandWebhooksIntegrity(ss *SqlSupplier) model.IntegrityCheckResult {
|
func checkUsersCommandWebhooksIntegrity(ss *SqlStore) model.IntegrityCheckResult {
|
||||||
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
||||||
parentName: "Users",
|
parentName: "Users",
|
||||||
parentIdAttr: "UserId",
|
parentIdAttr: "UserId",
|
||||||
@@ -287,7 +287,7 @@ func checkUsersCommandWebhooksIntegrity(ss *SqlSupplier) model.IntegrityCheckRes
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkUsersChannelMemberHistoryIntegrity(ss *SqlSupplier) model.IntegrityCheckResult {
|
func checkUsersChannelMemberHistoryIntegrity(ss *SqlStore) model.IntegrityCheckResult {
|
||||||
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
||||||
parentName: "Users",
|
parentName: "Users",
|
||||||
parentIdAttr: "UserId",
|
parentIdAttr: "UserId",
|
||||||
@@ -296,7 +296,7 @@ func checkUsersChannelMemberHistoryIntegrity(ss *SqlSupplier) model.IntegrityChe
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkUsersChannelMembersIntegrity(ss *SqlSupplier) model.IntegrityCheckResult {
|
func checkUsersChannelMembersIntegrity(ss *SqlStore) model.IntegrityCheckResult {
|
||||||
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
||||||
parentName: "Users",
|
parentName: "Users",
|
||||||
parentIdAttr: "UserId",
|
parentIdAttr: "UserId",
|
||||||
@@ -305,7 +305,7 @@ func checkUsersChannelMembersIntegrity(ss *SqlSupplier) model.IntegrityCheckResu
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkUsersChannelsIntegrity(ss *SqlSupplier) model.IntegrityCheckResult {
|
func checkUsersChannelsIntegrity(ss *SqlStore) model.IntegrityCheckResult {
|
||||||
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
||||||
parentName: "Users",
|
parentName: "Users",
|
||||||
parentIdAttr: "CreatorId",
|
parentIdAttr: "CreatorId",
|
||||||
@@ -315,7 +315,7 @@ func checkUsersChannelsIntegrity(ss *SqlSupplier) model.IntegrityCheckResult {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkUsersCommandsIntegrity(ss *SqlSupplier) model.IntegrityCheckResult {
|
func checkUsersCommandsIntegrity(ss *SqlStore) model.IntegrityCheckResult {
|
||||||
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
||||||
parentName: "Users",
|
parentName: "Users",
|
||||||
parentIdAttr: "CreatorId",
|
parentIdAttr: "CreatorId",
|
||||||
@@ -324,7 +324,7 @@ func checkUsersCommandsIntegrity(ss *SqlSupplier) model.IntegrityCheckResult {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkUsersCompliancesIntegrity(ss *SqlSupplier) model.IntegrityCheckResult {
|
func checkUsersCompliancesIntegrity(ss *SqlStore) model.IntegrityCheckResult {
|
||||||
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
||||||
parentName: "Users",
|
parentName: "Users",
|
||||||
parentIdAttr: "UserId",
|
parentIdAttr: "UserId",
|
||||||
@@ -333,7 +333,7 @@ func checkUsersCompliancesIntegrity(ss *SqlSupplier) model.IntegrityCheckResult
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkUsersEmojiIntegrity(ss *SqlSupplier) model.IntegrityCheckResult {
|
func checkUsersEmojiIntegrity(ss *SqlStore) model.IntegrityCheckResult {
|
||||||
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
||||||
parentName: "Users",
|
parentName: "Users",
|
||||||
parentIdAttr: "CreatorId",
|
parentIdAttr: "CreatorId",
|
||||||
@@ -342,7 +342,7 @@ func checkUsersEmojiIntegrity(ss *SqlSupplier) model.IntegrityCheckResult {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkUsersFileInfoIntegrity(ss *SqlSupplier) model.IntegrityCheckResult {
|
func checkUsersFileInfoIntegrity(ss *SqlStore) model.IntegrityCheckResult {
|
||||||
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
||||||
parentName: "Users",
|
parentName: "Users",
|
||||||
parentIdAttr: "CreatorId",
|
parentIdAttr: "CreatorId",
|
||||||
@@ -351,7 +351,7 @@ func checkUsersFileInfoIntegrity(ss *SqlSupplier) model.IntegrityCheckResult {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkUsersIncomingWebhooksIntegrity(ss *SqlSupplier) model.IntegrityCheckResult {
|
func checkUsersIncomingWebhooksIntegrity(ss *SqlStore) model.IntegrityCheckResult {
|
||||||
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
||||||
parentName: "Users",
|
parentName: "Users",
|
||||||
parentIdAttr: "UserId",
|
parentIdAttr: "UserId",
|
||||||
@@ -360,7 +360,7 @@ func checkUsersIncomingWebhooksIntegrity(ss *SqlSupplier) model.IntegrityCheckRe
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkUsersOAuthAccessDataIntegrity(ss *SqlSupplier) model.IntegrityCheckResult {
|
func checkUsersOAuthAccessDataIntegrity(ss *SqlStore) model.IntegrityCheckResult {
|
||||||
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
||||||
parentName: "Users",
|
parentName: "Users",
|
||||||
parentIdAttr: "UserId",
|
parentIdAttr: "UserId",
|
||||||
@@ -369,7 +369,7 @@ func checkUsersOAuthAccessDataIntegrity(ss *SqlSupplier) model.IntegrityCheckRes
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkUsersOAuthAppsIntegrity(ss *SqlSupplier) model.IntegrityCheckResult {
|
func checkUsersOAuthAppsIntegrity(ss *SqlStore) model.IntegrityCheckResult {
|
||||||
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
||||||
parentName: "Users",
|
parentName: "Users",
|
||||||
parentIdAttr: "CreatorId",
|
parentIdAttr: "CreatorId",
|
||||||
@@ -378,7 +378,7 @@ func checkUsersOAuthAppsIntegrity(ss *SqlSupplier) model.IntegrityCheckResult {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkUsersOAuthAuthDataIntegrity(ss *SqlSupplier) model.IntegrityCheckResult {
|
func checkUsersOAuthAuthDataIntegrity(ss *SqlStore) model.IntegrityCheckResult {
|
||||||
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
||||||
parentName: "Users",
|
parentName: "Users",
|
||||||
parentIdAttr: "UserId",
|
parentIdAttr: "UserId",
|
||||||
@@ -387,7 +387,7 @@ func checkUsersOAuthAuthDataIntegrity(ss *SqlSupplier) model.IntegrityCheckResul
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkUsersOutgoingWebhooksIntegrity(ss *SqlSupplier) model.IntegrityCheckResult {
|
func checkUsersOutgoingWebhooksIntegrity(ss *SqlStore) model.IntegrityCheckResult {
|
||||||
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
||||||
parentName: "Users",
|
parentName: "Users",
|
||||||
parentIdAttr: "CreatorId",
|
parentIdAttr: "CreatorId",
|
||||||
@@ -396,7 +396,7 @@ func checkUsersOutgoingWebhooksIntegrity(ss *SqlSupplier) model.IntegrityCheckRe
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkUsersPostsIntegrity(ss *SqlSupplier) model.IntegrityCheckResult {
|
func checkUsersPostsIntegrity(ss *SqlStore) model.IntegrityCheckResult {
|
||||||
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
||||||
parentName: "Users",
|
parentName: "Users",
|
||||||
parentIdAttr: "UserId",
|
parentIdAttr: "UserId",
|
||||||
@@ -405,7 +405,7 @@ func checkUsersPostsIntegrity(ss *SqlSupplier) model.IntegrityCheckResult {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkUsersPreferencesIntegrity(ss *SqlSupplier) model.IntegrityCheckResult {
|
func checkUsersPreferencesIntegrity(ss *SqlStore) model.IntegrityCheckResult {
|
||||||
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
||||||
parentName: "Users",
|
parentName: "Users",
|
||||||
parentIdAttr: "UserId",
|
parentIdAttr: "UserId",
|
||||||
@@ -414,7 +414,7 @@ func checkUsersPreferencesIntegrity(ss *SqlSupplier) model.IntegrityCheckResult
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkUsersReactionsIntegrity(ss *SqlSupplier) model.IntegrityCheckResult {
|
func checkUsersReactionsIntegrity(ss *SqlStore) model.IntegrityCheckResult {
|
||||||
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
||||||
parentName: "Users",
|
parentName: "Users",
|
||||||
parentIdAttr: "UserId",
|
parentIdAttr: "UserId",
|
||||||
@@ -423,7 +423,7 @@ func checkUsersReactionsIntegrity(ss *SqlSupplier) model.IntegrityCheckResult {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkUsersSessionsIntegrity(ss *SqlSupplier) model.IntegrityCheckResult {
|
func checkUsersSessionsIntegrity(ss *SqlStore) model.IntegrityCheckResult {
|
||||||
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
||||||
parentName: "Users",
|
parentName: "Users",
|
||||||
parentIdAttr: "UserId",
|
parentIdAttr: "UserId",
|
||||||
@@ -432,7 +432,7 @@ func checkUsersSessionsIntegrity(ss *SqlSupplier) model.IntegrityCheckResult {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkUsersStatusIntegrity(ss *SqlSupplier) model.IntegrityCheckResult {
|
func checkUsersStatusIntegrity(ss *SqlStore) model.IntegrityCheckResult {
|
||||||
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
||||||
parentName: "Users",
|
parentName: "Users",
|
||||||
parentIdAttr: "UserId",
|
parentIdAttr: "UserId",
|
||||||
@@ -441,7 +441,7 @@ func checkUsersStatusIntegrity(ss *SqlSupplier) model.IntegrityCheckResult {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkUsersTeamMembersIntegrity(ss *SqlSupplier) model.IntegrityCheckResult {
|
func checkUsersTeamMembersIntegrity(ss *SqlStore) model.IntegrityCheckResult {
|
||||||
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
||||||
parentName: "Users",
|
parentName: "Users",
|
||||||
parentIdAttr: "UserId",
|
parentIdAttr: "UserId",
|
||||||
@@ -450,7 +450,7 @@ func checkUsersTeamMembersIntegrity(ss *SqlSupplier) model.IntegrityCheckResult
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkUsersUserAccessTokensIntegrity(ss *SqlSupplier) model.IntegrityCheckResult {
|
func checkUsersUserAccessTokensIntegrity(ss *SqlStore) model.IntegrityCheckResult {
|
||||||
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
||||||
parentName: "Users",
|
parentName: "Users",
|
||||||
parentIdAttr: "UserId",
|
parentIdAttr: "UserId",
|
||||||
@@ -459,7 +459,7 @@ func checkUsersUserAccessTokensIntegrity(ss *SqlSupplier) model.IntegrityCheckRe
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkChannelsIntegrity(ss *SqlSupplier, results chan<- model.IntegrityCheckResult) {
|
func checkChannelsIntegrity(ss *SqlStore, results chan<- model.IntegrityCheckResult) {
|
||||||
results <- checkChannelsCommandWebhooksIntegrity(ss)
|
results <- checkChannelsCommandWebhooksIntegrity(ss)
|
||||||
results <- checkChannelsChannelMemberHistoryIntegrity(ss)
|
results <- checkChannelsChannelMemberHistoryIntegrity(ss)
|
||||||
results <- checkChannelsChannelMembersIntegrity(ss)
|
results <- checkChannelsChannelMembersIntegrity(ss)
|
||||||
@@ -468,27 +468,27 @@ func checkChannelsIntegrity(ss *SqlSupplier, results chan<- model.IntegrityCheck
|
|||||||
results <- checkChannelsPostsIntegrity(ss)
|
results <- checkChannelsPostsIntegrity(ss)
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkCommandsIntegrity(ss *SqlSupplier, results chan<- model.IntegrityCheckResult) {
|
func checkCommandsIntegrity(ss *SqlStore, results chan<- model.IntegrityCheckResult) {
|
||||||
results <- checkCommandsCommandWebhooksIntegrity(ss)
|
results <- checkCommandsCommandWebhooksIntegrity(ss)
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkPostsIntegrity(ss *SqlSupplier, results chan<- model.IntegrityCheckResult) {
|
func checkPostsIntegrity(ss *SqlStore, results chan<- model.IntegrityCheckResult) {
|
||||||
results <- checkPostsFileInfoIntegrity(ss)
|
results <- checkPostsFileInfoIntegrity(ss)
|
||||||
results <- checkPostsPostsParentIdIntegrity(ss)
|
results <- checkPostsPostsParentIdIntegrity(ss)
|
||||||
results <- checkPostsPostsRootIdIntegrity(ss)
|
results <- checkPostsPostsRootIdIntegrity(ss)
|
||||||
results <- checkPostsReactionsIntegrity(ss)
|
results <- checkPostsReactionsIntegrity(ss)
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkSchemesIntegrity(ss *SqlSupplier, results chan<- model.IntegrityCheckResult) {
|
func checkSchemesIntegrity(ss *SqlStore, results chan<- model.IntegrityCheckResult) {
|
||||||
results <- checkSchemesChannelsIntegrity(ss)
|
results <- checkSchemesChannelsIntegrity(ss)
|
||||||
results <- checkSchemesTeamsIntegrity(ss)
|
results <- checkSchemesTeamsIntegrity(ss)
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkSessionsIntegrity(ss *SqlSupplier, results chan<- model.IntegrityCheckResult) {
|
func checkSessionsIntegrity(ss *SqlStore, results chan<- model.IntegrityCheckResult) {
|
||||||
results <- checkSessionsAuditsIntegrity(ss)
|
results <- checkSessionsAuditsIntegrity(ss)
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkTeamsIntegrity(ss *SqlSupplier, results chan<- model.IntegrityCheckResult) {
|
func checkTeamsIntegrity(ss *SqlStore, results chan<- model.IntegrityCheckResult) {
|
||||||
results <- checkTeamsChannelsIntegrity(ss)
|
results <- checkTeamsChannelsIntegrity(ss)
|
||||||
results <- checkTeamsCommandsIntegrity(ss)
|
results <- checkTeamsCommandsIntegrity(ss)
|
||||||
results <- checkTeamsIncomingWebhooksIntegrity(ss)
|
results <- checkTeamsIncomingWebhooksIntegrity(ss)
|
||||||
@@ -496,7 +496,7 @@ func checkTeamsIntegrity(ss *SqlSupplier, results chan<- model.IntegrityCheckRes
|
|||||||
results <- checkTeamsTeamMembersIntegrity(ss)
|
results <- checkTeamsTeamMembersIntegrity(ss)
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkUsersIntegrity(ss *SqlSupplier, results chan<- model.IntegrityCheckResult) {
|
func checkUsersIntegrity(ss *SqlStore, results chan<- model.IntegrityCheckResult) {
|
||||||
results <- checkUsersAuditsIntegrity(ss)
|
results <- checkUsersAuditsIntegrity(ss)
|
||||||
results <- checkUsersCommandWebhooksIntegrity(ss)
|
results <- checkUsersCommandWebhooksIntegrity(ss)
|
||||||
results <- checkUsersChannelMemberHistoryIntegrity(ss)
|
results <- checkUsersChannelMemberHistoryIntegrity(ss)
|
||||||
@@ -520,7 +520,7 @@ func checkUsersIntegrity(ss *SqlSupplier, results chan<- model.IntegrityCheckRes
|
|||||||
results <- checkUsersUserAccessTokensIntegrity(ss)
|
results <- checkUsersUserAccessTokensIntegrity(ss)
|
||||||
}
|
}
|
||||||
|
|
||||||
func CheckRelationalIntegrity(ss *SqlSupplier, results chan<- model.IntegrityCheckResult) {
|
func CheckRelationalIntegrity(ss *SqlStore, results chan<- model.IntegrityCheckResult) {
|
||||||
mlog.Info("Starting relational integrity checks...")
|
mlog.Info("Starting relational integrity checks...")
|
||||||
checkChannelsIntegrity(ss, results)
|
checkChannelsIntegrity(ss, results)
|
||||||
checkCommandsIntegrity(ss, results)
|
checkCommandsIntegrity(ss, results)
|
||||||
|
|||||||
@@ -362,7 +362,7 @@ func TestCheckIntegrity(t *testing.T) {
|
|||||||
|
|
||||||
func TestCheckParentChildIntegrity(t *testing.T) {
|
func TestCheckParentChildIntegrity(t *testing.T) {
|
||||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||||
supplier := ss.(*SqlSupplier)
|
store := ss.(*SqlStore)
|
||||||
t.Run("should receive an error", func(t *testing.T) {
|
t.Run("should receive an error", func(t *testing.T) {
|
||||||
config := relationalCheckConfig{
|
config := relationalCheckConfig{
|
||||||
parentName: "NotValid",
|
parentName: "NotValid",
|
||||||
@@ -370,7 +370,7 @@ func TestCheckParentChildIntegrity(t *testing.T) {
|
|||||||
childName: "NotValid",
|
childName: "NotValid",
|
||||||
childIdAttr: "NotValid",
|
childIdAttr: "NotValid",
|
||||||
}
|
}
|
||||||
result := checkParentChildIntegrity(supplier, config)
|
result := checkParentChildIntegrity(store, config)
|
||||||
require.NotNil(t, result.Err)
|
require.NotNil(t, result.Err)
|
||||||
require.Empty(t, result.Data)
|
require.Empty(t, result.Data)
|
||||||
})
|
})
|
||||||
@@ -379,11 +379,11 @@ func TestCheckParentChildIntegrity(t *testing.T) {
|
|||||||
|
|
||||||
func TestCheckChannelsCommandWebhooksIntegrity(t *testing.T) {
|
func TestCheckChannelsCommandWebhooksIntegrity(t *testing.T) {
|
||||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||||
supplier := ss.(*SqlSupplier)
|
store := ss.(*SqlStore)
|
||||||
dbmap := supplier.GetMaster()
|
dbmap := store.GetMaster()
|
||||||
|
|
||||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||||
result := checkChannelsCommandWebhooksIntegrity(supplier)
|
result := checkChannelsCommandWebhooksIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Empty(t, data.Records)
|
require.Empty(t, data.Records)
|
||||||
@@ -392,7 +392,7 @@ func TestCheckChannelsCommandWebhooksIntegrity(t *testing.T) {
|
|||||||
t.Run("should generate a report with one record", func(t *testing.T) {
|
t.Run("should generate a report with one record", func(t *testing.T) {
|
||||||
channelId := model.NewId()
|
channelId := model.NewId()
|
||||||
cwh := createCommandWebhook(ss, model.NewId(), model.NewId(), channelId)
|
cwh := createCommandWebhook(ss, model.NewId(), model.NewId(), channelId)
|
||||||
result := checkChannelsCommandWebhooksIntegrity(supplier)
|
result := checkChannelsCommandWebhooksIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Len(t, data.Records, 1)
|
require.Len(t, data.Records, 1)
|
||||||
@@ -407,11 +407,11 @@ func TestCheckChannelsCommandWebhooksIntegrity(t *testing.T) {
|
|||||||
|
|
||||||
func TestCheckChannelsChannelMemberHistoryIntegrity(t *testing.T) {
|
func TestCheckChannelsChannelMemberHistoryIntegrity(t *testing.T) {
|
||||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||||
supplier := ss.(*SqlSupplier)
|
store := ss.(*SqlStore)
|
||||||
dbmap := supplier.GetMaster()
|
dbmap := store.GetMaster()
|
||||||
|
|
||||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||||
result := checkChannelsChannelMemberHistoryIntegrity(supplier)
|
result := checkChannelsChannelMemberHistoryIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Empty(t, data.Records)
|
require.Empty(t, data.Records)
|
||||||
@@ -422,7 +422,7 @@ func TestCheckChannelsChannelMemberHistoryIntegrity(t *testing.T) {
|
|||||||
user := createUser(ss)
|
user := createUser(ss)
|
||||||
cmh := createChannelMemberHistory(ss, channel.Id, user.Id)
|
cmh := createChannelMemberHistory(ss, channel.Id, user.Id)
|
||||||
dbmap.Delete(channel)
|
dbmap.Delete(channel)
|
||||||
result := checkChannelsChannelMemberHistoryIntegrity(supplier)
|
result := checkChannelsChannelMemberHistoryIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Len(t, data.Records, 1)
|
require.Len(t, data.Records, 1)
|
||||||
@@ -437,11 +437,11 @@ func TestCheckChannelsChannelMemberHistoryIntegrity(t *testing.T) {
|
|||||||
|
|
||||||
func TestCheckChannelsChannelMembersIntegrity(t *testing.T) {
|
func TestCheckChannelsChannelMembersIntegrity(t *testing.T) {
|
||||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||||
supplier := ss.(*SqlSupplier)
|
store := ss.(*SqlStore)
|
||||||
dbmap := supplier.GetMaster()
|
dbmap := store.GetMaster()
|
||||||
|
|
||||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||||
result := checkChannelsChannelMembersIntegrity(supplier)
|
result := checkChannelsChannelMembersIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Empty(t, data.Records)
|
require.Empty(t, data.Records)
|
||||||
@@ -451,7 +451,7 @@ func TestCheckChannelsChannelMembersIntegrity(t *testing.T) {
|
|||||||
channel := createChannel(ss, model.NewId(), model.NewId())
|
channel := createChannel(ss, model.NewId(), model.NewId())
|
||||||
member := createChannelMemberWithChannelId(ss, channel.Id)
|
member := createChannelMemberWithChannelId(ss, channel.Id)
|
||||||
dbmap.Delete(channel)
|
dbmap.Delete(channel)
|
||||||
result := checkChannelsChannelMembersIntegrity(supplier)
|
result := checkChannelsChannelMembersIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Len(t, data.Records, 1)
|
require.Len(t, data.Records, 1)
|
||||||
@@ -465,11 +465,11 @@ func TestCheckChannelsChannelMembersIntegrity(t *testing.T) {
|
|||||||
|
|
||||||
func TestCheckChannelsIncomingWebhooksIntegrity(t *testing.T) {
|
func TestCheckChannelsIncomingWebhooksIntegrity(t *testing.T) {
|
||||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||||
supplier := ss.(*SqlSupplier)
|
store := ss.(*SqlStore)
|
||||||
dbmap := supplier.GetMaster()
|
dbmap := store.GetMaster()
|
||||||
|
|
||||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||||
result := checkChannelsIncomingWebhooksIntegrity(supplier)
|
result := checkChannelsIncomingWebhooksIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Empty(t, data.Records)
|
require.Empty(t, data.Records)
|
||||||
@@ -478,7 +478,7 @@ func TestCheckChannelsIncomingWebhooksIntegrity(t *testing.T) {
|
|||||||
t.Run("should generate a report with one record", func(t *testing.T) {
|
t.Run("should generate a report with one record", func(t *testing.T) {
|
||||||
channelId := model.NewId()
|
channelId := model.NewId()
|
||||||
wh := createIncomingWebhook(ss, model.NewId(), channelId, model.NewId())
|
wh := createIncomingWebhook(ss, model.NewId(), channelId, model.NewId())
|
||||||
result := checkChannelsIncomingWebhooksIntegrity(supplier)
|
result := checkChannelsIncomingWebhooksIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Len(t, data.Records, 1)
|
require.Len(t, data.Records, 1)
|
||||||
@@ -493,11 +493,11 @@ func TestCheckChannelsIncomingWebhooksIntegrity(t *testing.T) {
|
|||||||
|
|
||||||
func TestCheckChannelsOutgoingWebhooksIntegrity(t *testing.T) {
|
func TestCheckChannelsOutgoingWebhooksIntegrity(t *testing.T) {
|
||||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||||
supplier := ss.(*SqlSupplier)
|
store := ss.(*SqlStore)
|
||||||
dbmap := supplier.GetMaster()
|
dbmap := store.GetMaster()
|
||||||
|
|
||||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||||
result := checkChannelsOutgoingWebhooksIntegrity(supplier)
|
result := checkChannelsOutgoingWebhooksIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Empty(t, data.Records)
|
require.Empty(t, data.Records)
|
||||||
@@ -508,7 +508,7 @@ func TestCheckChannelsOutgoingWebhooksIntegrity(t *testing.T) {
|
|||||||
channelId := channel.Id
|
channelId := channel.Id
|
||||||
wh := createOutgoingWebhook(ss, model.NewId(), channelId, model.NewId())
|
wh := createOutgoingWebhook(ss, model.NewId(), channelId, model.NewId())
|
||||||
dbmap.Delete(channel)
|
dbmap.Delete(channel)
|
||||||
result := checkChannelsOutgoingWebhooksIntegrity(supplier)
|
result := checkChannelsOutgoingWebhooksIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Len(t, data.Records, 1)
|
require.Len(t, data.Records, 1)
|
||||||
@@ -523,11 +523,11 @@ func TestCheckChannelsOutgoingWebhooksIntegrity(t *testing.T) {
|
|||||||
|
|
||||||
func TestCheckChannelsPostsIntegrity(t *testing.T) {
|
func TestCheckChannelsPostsIntegrity(t *testing.T) {
|
||||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||||
supplier := ss.(*SqlSupplier)
|
store := ss.(*SqlStore)
|
||||||
dbmap := supplier.GetMaster()
|
dbmap := store.GetMaster()
|
||||||
|
|
||||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||||
result := checkChannelsPostsIntegrity(supplier)
|
result := checkChannelsPostsIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Empty(t, data.Records)
|
require.Empty(t, data.Records)
|
||||||
@@ -535,7 +535,7 @@ func TestCheckChannelsPostsIntegrity(t *testing.T) {
|
|||||||
|
|
||||||
t.Run("should generate a report with one record", func(t *testing.T) {
|
t.Run("should generate a report with one record", func(t *testing.T) {
|
||||||
post := createPostWithChannelId(ss, model.NewId())
|
post := createPostWithChannelId(ss, model.NewId())
|
||||||
result := checkChannelsPostsIntegrity(supplier)
|
result := checkChannelsPostsIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Len(t, data.Records, 1)
|
require.Len(t, data.Records, 1)
|
||||||
@@ -550,11 +550,11 @@ func TestCheckChannelsPostsIntegrity(t *testing.T) {
|
|||||||
|
|
||||||
func TestCheckCommandsCommandWebhooksIntegrity(t *testing.T) {
|
func TestCheckCommandsCommandWebhooksIntegrity(t *testing.T) {
|
||||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||||
supplier := ss.(*SqlSupplier)
|
store := ss.(*SqlStore)
|
||||||
dbmap := supplier.GetMaster()
|
dbmap := store.GetMaster()
|
||||||
|
|
||||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||||
result := checkCommandsCommandWebhooksIntegrity(supplier)
|
result := checkCommandsCommandWebhooksIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Empty(t, data.Records)
|
require.Empty(t, data.Records)
|
||||||
@@ -563,7 +563,7 @@ func TestCheckCommandsCommandWebhooksIntegrity(t *testing.T) {
|
|||||||
t.Run("should generate a report with one record", func(t *testing.T) {
|
t.Run("should generate a report with one record", func(t *testing.T) {
|
||||||
commandId := model.NewId()
|
commandId := model.NewId()
|
||||||
cwh := createCommandWebhook(ss, commandId, model.NewId(), model.NewId())
|
cwh := createCommandWebhook(ss, commandId, model.NewId(), model.NewId())
|
||||||
result := checkCommandsCommandWebhooksIntegrity(supplier)
|
result := checkCommandsCommandWebhooksIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Len(t, data.Records, 1)
|
require.Len(t, data.Records, 1)
|
||||||
@@ -578,11 +578,11 @@ func TestCheckCommandsCommandWebhooksIntegrity(t *testing.T) {
|
|||||||
|
|
||||||
func TestCheckPostsFileInfoIntegrity(t *testing.T) {
|
func TestCheckPostsFileInfoIntegrity(t *testing.T) {
|
||||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||||
supplier := ss.(*SqlSupplier)
|
store := ss.(*SqlStore)
|
||||||
dbmap := supplier.GetMaster()
|
dbmap := store.GetMaster()
|
||||||
|
|
||||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||||
result := checkPostsFileInfoIntegrity(supplier)
|
result := checkPostsFileInfoIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Empty(t, data.Records)
|
require.Empty(t, data.Records)
|
||||||
@@ -591,7 +591,7 @@ func TestCheckPostsFileInfoIntegrity(t *testing.T) {
|
|||||||
t.Run("should generate a report with one record", func(t *testing.T) {
|
t.Run("should generate a report with one record", func(t *testing.T) {
|
||||||
postId := model.NewId()
|
postId := model.NewId()
|
||||||
info := createFileInfo(ss, postId, model.NewId())
|
info := createFileInfo(ss, postId, model.NewId())
|
||||||
result := checkPostsFileInfoIntegrity(supplier)
|
result := checkPostsFileInfoIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Len(t, data.Records, 1)
|
require.Len(t, data.Records, 1)
|
||||||
@@ -606,11 +606,11 @@ func TestCheckPostsFileInfoIntegrity(t *testing.T) {
|
|||||||
|
|
||||||
func TestCheckPostsPostsParentIdIntegrity(t *testing.T) {
|
func TestCheckPostsPostsParentIdIntegrity(t *testing.T) {
|
||||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||||
supplier := ss.(*SqlSupplier)
|
store := ss.(*SqlStore)
|
||||||
dbmap := supplier.GetMaster()
|
dbmap := store.GetMaster()
|
||||||
|
|
||||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||||
result := checkPostsPostsParentIdIntegrity(supplier)
|
result := checkPostsPostsParentIdIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Empty(t, data.Records)
|
require.Empty(t, data.Records)
|
||||||
@@ -620,7 +620,7 @@ func TestCheckPostsPostsParentIdIntegrity(t *testing.T) {
|
|||||||
root := createPost(ss, model.NewId(), model.NewId(), "", "")
|
root := createPost(ss, model.NewId(), model.NewId(), "", "")
|
||||||
parent := createPost(ss, model.NewId(), model.NewId(), root.Id, root.Id)
|
parent := createPost(ss, model.NewId(), model.NewId(), root.Id, root.Id)
|
||||||
post := createPost(ss, model.NewId(), model.NewId(), root.Id, parent.Id)
|
post := createPost(ss, model.NewId(), model.NewId(), root.Id, parent.Id)
|
||||||
result := checkPostsPostsParentIdIntegrity(supplier)
|
result := checkPostsPostsParentIdIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Empty(t, data.Records)
|
require.Empty(t, data.Records)
|
||||||
@@ -635,7 +635,7 @@ func TestCheckPostsPostsParentIdIntegrity(t *testing.T) {
|
|||||||
parentId := parent.Id
|
parentId := parent.Id
|
||||||
post := createPost(ss, model.NewId(), model.NewId(), root.Id, parent.Id)
|
post := createPost(ss, model.NewId(), model.NewId(), root.Id, parent.Id)
|
||||||
dbmap.Delete(parent)
|
dbmap.Delete(parent)
|
||||||
result := checkPostsPostsParentIdIntegrity(supplier)
|
result := checkPostsPostsParentIdIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Len(t, data.Records, 1)
|
require.Len(t, data.Records, 1)
|
||||||
@@ -651,11 +651,11 @@ func TestCheckPostsPostsParentIdIntegrity(t *testing.T) {
|
|||||||
|
|
||||||
func TestCheckPostsPostsRootIdIntegrity(t *testing.T) {
|
func TestCheckPostsPostsRootIdIntegrity(t *testing.T) {
|
||||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||||
supplier := ss.(*SqlSupplier)
|
store := ss.(*SqlStore)
|
||||||
dbmap := supplier.GetMaster()
|
dbmap := store.GetMaster()
|
||||||
|
|
||||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||||
result := checkPostsPostsRootIdIntegrity(supplier)
|
result := checkPostsPostsRootIdIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Empty(t, data.Records)
|
require.Empty(t, data.Records)
|
||||||
@@ -666,7 +666,7 @@ func TestCheckPostsPostsRootIdIntegrity(t *testing.T) {
|
|||||||
rootId := root.Id
|
rootId := root.Id
|
||||||
post := createPost(ss, model.NewId(), model.NewId(), root.Id, root.Id)
|
post := createPost(ss, model.NewId(), model.NewId(), root.Id, root.Id)
|
||||||
dbmap.Delete(root)
|
dbmap.Delete(root)
|
||||||
result := checkPostsPostsRootIdIntegrity(supplier)
|
result := checkPostsPostsRootIdIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Len(t, data.Records, 1)
|
require.Len(t, data.Records, 1)
|
||||||
@@ -681,11 +681,11 @@ func TestCheckPostsPostsRootIdIntegrity(t *testing.T) {
|
|||||||
|
|
||||||
func TestCheckPostsReactionsIntegrity(t *testing.T) {
|
func TestCheckPostsReactionsIntegrity(t *testing.T) {
|
||||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||||
supplier := ss.(*SqlSupplier)
|
store := ss.(*SqlStore)
|
||||||
dbmap := supplier.GetMaster()
|
dbmap := store.GetMaster()
|
||||||
|
|
||||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||||
result := checkPostsReactionsIntegrity(supplier)
|
result := checkPostsReactionsIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Empty(t, data.Records)
|
require.Empty(t, data.Records)
|
||||||
@@ -694,7 +694,7 @@ func TestCheckPostsReactionsIntegrity(t *testing.T) {
|
|||||||
t.Run("should generate a report with one record", func(t *testing.T) {
|
t.Run("should generate a report with one record", func(t *testing.T) {
|
||||||
postId := model.NewId()
|
postId := model.NewId()
|
||||||
reaction := createReaction(ss, model.NewId(), postId)
|
reaction := createReaction(ss, model.NewId(), postId)
|
||||||
result := checkPostsReactionsIntegrity(supplier)
|
result := checkPostsReactionsIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Len(t, data.Records, 1)
|
require.Len(t, data.Records, 1)
|
||||||
@@ -708,11 +708,11 @@ func TestCheckPostsReactionsIntegrity(t *testing.T) {
|
|||||||
|
|
||||||
func TestCheckSchemesChannelsIntegrity(t *testing.T) {
|
func TestCheckSchemesChannelsIntegrity(t *testing.T) {
|
||||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||||
supplier := ss.(*SqlSupplier)
|
store := ss.(*SqlStore)
|
||||||
dbmap := supplier.GetMaster()
|
dbmap := store.GetMaster()
|
||||||
|
|
||||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||||
result := checkSchemesChannelsIntegrity(supplier)
|
result := checkSchemesChannelsIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Empty(t, data.Records)
|
require.Empty(t, data.Records)
|
||||||
@@ -724,7 +724,7 @@ func TestCheckSchemesChannelsIntegrity(t *testing.T) {
|
|||||||
schemeId := scheme.Id
|
schemeId := scheme.Id
|
||||||
channel := createChannelWithSchemeId(ss, &schemeId)
|
channel := createChannelWithSchemeId(ss, &schemeId)
|
||||||
dbmap.Delete(scheme)
|
dbmap.Delete(scheme)
|
||||||
result := checkSchemesChannelsIntegrity(supplier)
|
result := checkSchemesChannelsIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Len(t, data.Records, 1)
|
require.Len(t, data.Records, 1)
|
||||||
@@ -739,11 +739,11 @@ func TestCheckSchemesChannelsIntegrity(t *testing.T) {
|
|||||||
|
|
||||||
func TestCheckSchemesTeamsIntegrity(t *testing.T) {
|
func TestCheckSchemesTeamsIntegrity(t *testing.T) {
|
||||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||||
supplier := ss.(*SqlSupplier)
|
store := ss.(*SqlStore)
|
||||||
dbmap := supplier.GetMaster()
|
dbmap := store.GetMaster()
|
||||||
|
|
||||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||||
result := checkSchemesTeamsIntegrity(supplier)
|
result := checkSchemesTeamsIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Empty(t, data.Records)
|
require.Empty(t, data.Records)
|
||||||
@@ -755,7 +755,7 @@ func TestCheckSchemesTeamsIntegrity(t *testing.T) {
|
|||||||
schemeId := scheme.Id
|
schemeId := scheme.Id
|
||||||
team := createTeamWithSchemeId(ss, &schemeId)
|
team := createTeamWithSchemeId(ss, &schemeId)
|
||||||
dbmap.Delete(scheme)
|
dbmap.Delete(scheme)
|
||||||
result := checkSchemesTeamsIntegrity(supplier)
|
result := checkSchemesTeamsIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Len(t, data.Records, 1)
|
require.Len(t, data.Records, 1)
|
||||||
@@ -770,11 +770,11 @@ func TestCheckSchemesTeamsIntegrity(t *testing.T) {
|
|||||||
|
|
||||||
func TestCheckSessionsAuditsIntegrity(t *testing.T) {
|
func TestCheckSessionsAuditsIntegrity(t *testing.T) {
|
||||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||||
supplier := ss.(*SqlSupplier)
|
store := ss.(*SqlStore)
|
||||||
dbmap := supplier.GetMaster()
|
dbmap := store.GetMaster()
|
||||||
|
|
||||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||||
result := checkSessionsAuditsIntegrity(supplier)
|
result := checkSessionsAuditsIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Empty(t, data.Records)
|
require.Empty(t, data.Records)
|
||||||
@@ -786,7 +786,7 @@ func TestCheckSessionsAuditsIntegrity(t *testing.T) {
|
|||||||
sessionId := session.Id
|
sessionId := session.Id
|
||||||
audit := createAudit(ss, userId, sessionId)
|
audit := createAudit(ss, userId, sessionId)
|
||||||
dbmap.Delete(session)
|
dbmap.Delete(session)
|
||||||
result := checkSessionsAuditsIntegrity(supplier)
|
result := checkSessionsAuditsIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Len(t, data.Records, 1)
|
require.Len(t, data.Records, 1)
|
||||||
@@ -801,11 +801,11 @@ func TestCheckSessionsAuditsIntegrity(t *testing.T) {
|
|||||||
|
|
||||||
func TestCheckTeamsChannelsIntegrity(t *testing.T) {
|
func TestCheckTeamsChannelsIntegrity(t *testing.T) {
|
||||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||||
supplier := ss.(*SqlSupplier)
|
store := ss.(*SqlStore)
|
||||||
dbmap := supplier.GetMaster()
|
dbmap := store.GetMaster()
|
||||||
|
|
||||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||||
result := checkTeamsChannelsIntegrity(supplier)
|
result := checkTeamsChannelsIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Empty(t, data.Records)
|
require.Empty(t, data.Records)
|
||||||
@@ -813,7 +813,7 @@ func TestCheckTeamsChannelsIntegrity(t *testing.T) {
|
|||||||
|
|
||||||
t.Run("should generate a report with one record", func(t *testing.T) {
|
t.Run("should generate a report with one record", func(t *testing.T) {
|
||||||
channel := createChannelWithTeamId(ss, model.NewId())
|
channel := createChannelWithTeamId(ss, model.NewId())
|
||||||
result := checkTeamsChannelsIntegrity(supplier)
|
result := checkTeamsChannelsIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Len(t, data.Records, 1)
|
require.Len(t, data.Records, 1)
|
||||||
@@ -831,7 +831,7 @@ func TestCheckTeamsChannelsIntegrity(t *testing.T) {
|
|||||||
direct, err := ss.Channel().CreateDirectChannel(userA, userB)
|
direct, err := ss.Channel().CreateDirectChannel(userA, userB)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.NotNil(t, direct)
|
require.NotNil(t, direct)
|
||||||
result := checkTeamsChannelsIntegrity(supplier)
|
result := checkTeamsChannelsIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Len(t, data.Records, 1)
|
require.Len(t, data.Records, 1)
|
||||||
@@ -854,7 +854,7 @@ func TestCheckTeamsChannelsIntegrity(t *testing.T) {
|
|||||||
require.NotNil(t, direct)
|
require.NotNil(t, direct)
|
||||||
_, err = dbmap.Exec(`UPDATE Channels SET TeamId = 'test' WHERE Id = '` + direct.Id + `'`)
|
_, err = dbmap.Exec(`UPDATE Channels SET TeamId = 'test' WHERE Id = '` + direct.Id + `'`)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
result := checkTeamsChannelsIntegrity(supplier)
|
result := checkTeamsChannelsIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Len(t, data.Records, 2)
|
require.Len(t, data.Records, 2)
|
||||||
@@ -877,11 +877,11 @@ func TestCheckTeamsChannelsIntegrity(t *testing.T) {
|
|||||||
|
|
||||||
func TestCheckTeamsCommandsIntegrity(t *testing.T) {
|
func TestCheckTeamsCommandsIntegrity(t *testing.T) {
|
||||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||||
supplier := ss.(*SqlSupplier)
|
store := ss.(*SqlStore)
|
||||||
dbmap := supplier.GetMaster()
|
dbmap := store.GetMaster()
|
||||||
|
|
||||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||||
result := checkTeamsCommandsIntegrity(supplier)
|
result := checkTeamsCommandsIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Empty(t, data.Records)
|
require.Empty(t, data.Records)
|
||||||
@@ -890,7 +890,7 @@ func TestCheckTeamsCommandsIntegrity(t *testing.T) {
|
|||||||
t.Run("should generate a report with one record", func(t *testing.T) {
|
t.Run("should generate a report with one record", func(t *testing.T) {
|
||||||
teamId := model.NewId()
|
teamId := model.NewId()
|
||||||
cmd := createCommand(ss, model.NewId(), teamId)
|
cmd := createCommand(ss, model.NewId(), teamId)
|
||||||
result := checkTeamsCommandsIntegrity(supplier)
|
result := checkTeamsCommandsIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Len(t, data.Records, 1)
|
require.Len(t, data.Records, 1)
|
||||||
@@ -905,11 +905,11 @@ func TestCheckTeamsCommandsIntegrity(t *testing.T) {
|
|||||||
|
|
||||||
func TestCheckTeamsIncomingWebhooksIntegrity(t *testing.T) {
|
func TestCheckTeamsIncomingWebhooksIntegrity(t *testing.T) {
|
||||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||||
supplier := ss.(*SqlSupplier)
|
store := ss.(*SqlStore)
|
||||||
dbmap := supplier.GetMaster()
|
dbmap := store.GetMaster()
|
||||||
|
|
||||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||||
result := checkTeamsIncomingWebhooksIntegrity(supplier)
|
result := checkTeamsIncomingWebhooksIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Empty(t, data.Records)
|
require.Empty(t, data.Records)
|
||||||
@@ -918,7 +918,7 @@ func TestCheckTeamsIncomingWebhooksIntegrity(t *testing.T) {
|
|||||||
t.Run("should generate a report with one record", func(t *testing.T) {
|
t.Run("should generate a report with one record", func(t *testing.T) {
|
||||||
teamId := model.NewId()
|
teamId := model.NewId()
|
||||||
wh := createIncomingWebhook(ss, model.NewId(), model.NewId(), teamId)
|
wh := createIncomingWebhook(ss, model.NewId(), model.NewId(), teamId)
|
||||||
result := checkTeamsIncomingWebhooksIntegrity(supplier)
|
result := checkTeamsIncomingWebhooksIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Len(t, data.Records, 1)
|
require.Len(t, data.Records, 1)
|
||||||
@@ -933,11 +933,11 @@ func TestCheckTeamsIncomingWebhooksIntegrity(t *testing.T) {
|
|||||||
|
|
||||||
func TestCheckTeamsOutgoingWebhooksIntegrity(t *testing.T) {
|
func TestCheckTeamsOutgoingWebhooksIntegrity(t *testing.T) {
|
||||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||||
supplier := ss.(*SqlSupplier)
|
store := ss.(*SqlStore)
|
||||||
dbmap := supplier.GetMaster()
|
dbmap := store.GetMaster()
|
||||||
|
|
||||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||||
result := checkTeamsOutgoingWebhooksIntegrity(supplier)
|
result := checkTeamsOutgoingWebhooksIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Empty(t, data.Records)
|
require.Empty(t, data.Records)
|
||||||
@@ -946,7 +946,7 @@ func TestCheckTeamsOutgoingWebhooksIntegrity(t *testing.T) {
|
|||||||
t.Run("should generate a report with one record", func(t *testing.T) {
|
t.Run("should generate a report with one record", func(t *testing.T) {
|
||||||
teamId := model.NewId()
|
teamId := model.NewId()
|
||||||
wh := createOutgoingWebhook(ss, model.NewId(), model.NewId(), teamId)
|
wh := createOutgoingWebhook(ss, model.NewId(), model.NewId(), teamId)
|
||||||
result := checkTeamsOutgoingWebhooksIntegrity(supplier)
|
result := checkTeamsOutgoingWebhooksIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Len(t, data.Records, 1)
|
require.Len(t, data.Records, 1)
|
||||||
@@ -961,11 +961,11 @@ func TestCheckTeamsOutgoingWebhooksIntegrity(t *testing.T) {
|
|||||||
|
|
||||||
func TestCheckTeamsTeamMembersIntegrity(t *testing.T) {
|
func TestCheckTeamsTeamMembersIntegrity(t *testing.T) {
|
||||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||||
supplier := ss.(*SqlSupplier)
|
store := ss.(*SqlStore)
|
||||||
dbmap := supplier.GetMaster()
|
dbmap := store.GetMaster()
|
||||||
|
|
||||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||||
result := checkTeamsTeamMembersIntegrity(supplier)
|
result := checkTeamsTeamMembersIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Empty(t, data.Records)
|
require.Empty(t, data.Records)
|
||||||
@@ -975,7 +975,7 @@ func TestCheckTeamsTeamMembersIntegrity(t *testing.T) {
|
|||||||
team := createTeam(ss, model.NewId())
|
team := createTeam(ss, model.NewId())
|
||||||
member := createTeamMember(ss, team.Id, model.NewId())
|
member := createTeamMember(ss, team.Id, model.NewId())
|
||||||
dbmap.Delete(team)
|
dbmap.Delete(team)
|
||||||
result := checkTeamsTeamMembersIntegrity(supplier)
|
result := checkTeamsTeamMembersIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Len(t, data.Records, 1)
|
require.Len(t, data.Records, 1)
|
||||||
@@ -989,11 +989,11 @@ func TestCheckTeamsTeamMembersIntegrity(t *testing.T) {
|
|||||||
|
|
||||||
func TestCheckUsersAuditsIntegrity(t *testing.T) {
|
func TestCheckUsersAuditsIntegrity(t *testing.T) {
|
||||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||||
supplier := ss.(*SqlSupplier)
|
store := ss.(*SqlStore)
|
||||||
dbmap := supplier.GetMaster()
|
dbmap := store.GetMaster()
|
||||||
|
|
||||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||||
result := checkUsersAuditsIntegrity(supplier)
|
result := checkUsersAuditsIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Empty(t, data.Records)
|
require.Empty(t, data.Records)
|
||||||
@@ -1004,7 +1004,7 @@ func TestCheckUsersAuditsIntegrity(t *testing.T) {
|
|||||||
userId := user.Id
|
userId := user.Id
|
||||||
audit := createAudit(ss, userId, model.NewId())
|
audit := createAudit(ss, userId, model.NewId())
|
||||||
dbmap.Delete(user)
|
dbmap.Delete(user)
|
||||||
result := checkUsersAuditsIntegrity(supplier)
|
result := checkUsersAuditsIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Len(t, data.Records, 1)
|
require.Len(t, data.Records, 1)
|
||||||
@@ -1019,11 +1019,11 @@ func TestCheckUsersAuditsIntegrity(t *testing.T) {
|
|||||||
|
|
||||||
func TestCheckUsersCommandWebhooksIntegrity(t *testing.T) {
|
func TestCheckUsersCommandWebhooksIntegrity(t *testing.T) {
|
||||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||||
supplier := ss.(*SqlSupplier)
|
store := ss.(*SqlStore)
|
||||||
dbmap := supplier.GetMaster()
|
dbmap := store.GetMaster()
|
||||||
|
|
||||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||||
result := checkUsersCommandWebhooksIntegrity(supplier)
|
result := checkUsersCommandWebhooksIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Empty(t, data.Records)
|
require.Empty(t, data.Records)
|
||||||
@@ -1032,7 +1032,7 @@ func TestCheckUsersCommandWebhooksIntegrity(t *testing.T) {
|
|||||||
t.Run("should generate a report with one record", func(t *testing.T) {
|
t.Run("should generate a report with one record", func(t *testing.T) {
|
||||||
userId := model.NewId()
|
userId := model.NewId()
|
||||||
cwh := createCommandWebhook(ss, model.NewId(), userId, model.NewId())
|
cwh := createCommandWebhook(ss, model.NewId(), userId, model.NewId())
|
||||||
result := checkUsersCommandWebhooksIntegrity(supplier)
|
result := checkUsersCommandWebhooksIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Len(t, data.Records, 1)
|
require.Len(t, data.Records, 1)
|
||||||
@@ -1047,11 +1047,11 @@ func TestCheckUsersCommandWebhooksIntegrity(t *testing.T) {
|
|||||||
|
|
||||||
func TestCheckUsersChannelsIntegrity(t *testing.T) {
|
func TestCheckUsersChannelsIntegrity(t *testing.T) {
|
||||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||||
supplier := ss.(*SqlSupplier)
|
store := ss.(*SqlStore)
|
||||||
dbmap := supplier.GetMaster()
|
dbmap := store.GetMaster()
|
||||||
|
|
||||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||||
result := checkUsersChannelsIntegrity(supplier)
|
result := checkUsersChannelsIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Empty(t, data.Records)
|
require.Empty(t, data.Records)
|
||||||
@@ -1059,7 +1059,7 @@ func TestCheckUsersChannelsIntegrity(t *testing.T) {
|
|||||||
|
|
||||||
t.Run("should generate a report with one record", func(t *testing.T) {
|
t.Run("should generate a report with one record", func(t *testing.T) {
|
||||||
channel := createChannelWithCreatorId(ss, model.NewId())
|
channel := createChannelWithCreatorId(ss, model.NewId())
|
||||||
result := checkUsersChannelsIntegrity(supplier)
|
result := checkUsersChannelsIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Len(t, data.Records, 1)
|
require.Len(t, data.Records, 1)
|
||||||
@@ -1074,11 +1074,11 @@ func TestCheckUsersChannelsIntegrity(t *testing.T) {
|
|||||||
|
|
||||||
func TestCheckUsersChannelMemberHistoryIntegrity(t *testing.T) {
|
func TestCheckUsersChannelMemberHistoryIntegrity(t *testing.T) {
|
||||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||||
supplier := ss.(*SqlSupplier)
|
store := ss.(*SqlStore)
|
||||||
dbmap := supplier.GetMaster()
|
dbmap := store.GetMaster()
|
||||||
|
|
||||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||||
result := checkUsersChannelMemberHistoryIntegrity(supplier)
|
result := checkUsersChannelMemberHistoryIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Empty(t, data.Records)
|
require.Empty(t, data.Records)
|
||||||
@@ -1089,7 +1089,7 @@ func TestCheckUsersChannelMemberHistoryIntegrity(t *testing.T) {
|
|||||||
channel := createChannel(ss, model.NewId(), model.NewId())
|
channel := createChannel(ss, model.NewId(), model.NewId())
|
||||||
cmh := createChannelMemberHistory(ss, channel.Id, user.Id)
|
cmh := createChannelMemberHistory(ss, channel.Id, user.Id)
|
||||||
dbmap.Delete(user)
|
dbmap.Delete(user)
|
||||||
result := checkUsersChannelMemberHistoryIntegrity(supplier)
|
result := checkUsersChannelMemberHistoryIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Len(t, data.Records, 1)
|
require.Len(t, data.Records, 1)
|
||||||
@@ -1104,11 +1104,11 @@ func TestCheckUsersChannelMemberHistoryIntegrity(t *testing.T) {
|
|||||||
|
|
||||||
func TestCheckUsersChannelMembersIntegrity(t *testing.T) {
|
func TestCheckUsersChannelMembersIntegrity(t *testing.T) {
|
||||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||||
supplier := ss.(*SqlSupplier)
|
store := ss.(*SqlStore)
|
||||||
dbmap := supplier.GetMaster()
|
dbmap := store.GetMaster()
|
||||||
|
|
||||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||||
result := checkUsersChannelMembersIntegrity(supplier)
|
result := checkUsersChannelMembersIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Empty(t, data.Records)
|
require.Empty(t, data.Records)
|
||||||
@@ -1119,7 +1119,7 @@ func TestCheckUsersChannelMembersIntegrity(t *testing.T) {
|
|||||||
channel := createChannelWithCreatorId(ss, user.Id)
|
channel := createChannelWithCreatorId(ss, user.Id)
|
||||||
member := createChannelMember(ss, channel.Id, user.Id)
|
member := createChannelMember(ss, channel.Id, user.Id)
|
||||||
dbmap.Delete(user)
|
dbmap.Delete(user)
|
||||||
result := checkUsersChannelMembersIntegrity(supplier)
|
result := checkUsersChannelMembersIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Len(t, data.Records, 1)
|
require.Len(t, data.Records, 1)
|
||||||
@@ -1134,11 +1134,11 @@ func TestCheckUsersChannelMembersIntegrity(t *testing.T) {
|
|||||||
|
|
||||||
func TestCheckUsersCommandsIntegrity(t *testing.T) {
|
func TestCheckUsersCommandsIntegrity(t *testing.T) {
|
||||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||||
supplier := ss.(*SqlSupplier)
|
store := ss.(*SqlStore)
|
||||||
dbmap := supplier.GetMaster()
|
dbmap := store.GetMaster()
|
||||||
|
|
||||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||||
result := checkUsersCommandsIntegrity(supplier)
|
result := checkUsersCommandsIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Empty(t, data.Records)
|
require.Empty(t, data.Records)
|
||||||
@@ -1147,7 +1147,7 @@ func TestCheckUsersCommandsIntegrity(t *testing.T) {
|
|||||||
t.Run("should generate a report with one record", func(t *testing.T) {
|
t.Run("should generate a report with one record", func(t *testing.T) {
|
||||||
userId := model.NewId()
|
userId := model.NewId()
|
||||||
cmd := createCommand(ss, userId, model.NewId())
|
cmd := createCommand(ss, userId, model.NewId())
|
||||||
result := checkUsersCommandsIntegrity(supplier)
|
result := checkUsersCommandsIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Len(t, data.Records, 1)
|
require.Len(t, data.Records, 1)
|
||||||
@@ -1162,11 +1162,11 @@ func TestCheckUsersCommandsIntegrity(t *testing.T) {
|
|||||||
|
|
||||||
func TestCheckUsersCompliancesIntegrity(t *testing.T) {
|
func TestCheckUsersCompliancesIntegrity(t *testing.T) {
|
||||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||||
supplier := ss.(*SqlSupplier)
|
store := ss.(*SqlStore)
|
||||||
dbmap := supplier.GetMaster()
|
dbmap := store.GetMaster()
|
||||||
|
|
||||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||||
result := checkUsersCompliancesIntegrity(supplier)
|
result := checkUsersCompliancesIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Empty(t, data.Records)
|
require.Empty(t, data.Records)
|
||||||
@@ -1177,7 +1177,7 @@ func TestCheckUsersCompliancesIntegrity(t *testing.T) {
|
|||||||
userId := user.Id
|
userId := user.Id
|
||||||
compliance := createCompliance(ss, userId)
|
compliance := createCompliance(ss, userId)
|
||||||
dbmap.Delete(user)
|
dbmap.Delete(user)
|
||||||
result := checkUsersCompliancesIntegrity(supplier)
|
result := checkUsersCompliancesIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Len(t, data.Records, 1)
|
require.Len(t, data.Records, 1)
|
||||||
@@ -1192,11 +1192,11 @@ func TestCheckUsersCompliancesIntegrity(t *testing.T) {
|
|||||||
|
|
||||||
func TestCheckUsersEmojiIntegrity(t *testing.T) {
|
func TestCheckUsersEmojiIntegrity(t *testing.T) {
|
||||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||||
supplier := ss.(*SqlSupplier)
|
store := ss.(*SqlStore)
|
||||||
dbmap := supplier.GetMaster()
|
dbmap := store.GetMaster()
|
||||||
|
|
||||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||||
result := checkUsersEmojiIntegrity(supplier)
|
result := checkUsersEmojiIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Empty(t, data.Records)
|
require.Empty(t, data.Records)
|
||||||
@@ -1207,7 +1207,7 @@ func TestCheckUsersEmojiIntegrity(t *testing.T) {
|
|||||||
userId := user.Id
|
userId := user.Id
|
||||||
emoji := createEmoji(ss, userId)
|
emoji := createEmoji(ss, userId)
|
||||||
dbmap.Delete(user)
|
dbmap.Delete(user)
|
||||||
result := checkUsersEmojiIntegrity(supplier)
|
result := checkUsersEmojiIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Len(t, data.Records, 1)
|
require.Len(t, data.Records, 1)
|
||||||
@@ -1222,11 +1222,11 @@ func TestCheckUsersEmojiIntegrity(t *testing.T) {
|
|||||||
|
|
||||||
func TestCheckUsersFileInfoIntegrity(t *testing.T) {
|
func TestCheckUsersFileInfoIntegrity(t *testing.T) {
|
||||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||||
supplier := ss.(*SqlSupplier)
|
store := ss.(*SqlStore)
|
||||||
dbmap := supplier.GetMaster()
|
dbmap := store.GetMaster()
|
||||||
|
|
||||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||||
result := checkUsersFileInfoIntegrity(supplier)
|
result := checkUsersFileInfoIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Empty(t, data.Records)
|
require.Empty(t, data.Records)
|
||||||
@@ -1237,7 +1237,7 @@ func TestCheckUsersFileInfoIntegrity(t *testing.T) {
|
|||||||
userId := user.Id
|
userId := user.Id
|
||||||
info := createFileInfo(ss, model.NewId(), userId)
|
info := createFileInfo(ss, model.NewId(), userId)
|
||||||
dbmap.Delete(user)
|
dbmap.Delete(user)
|
||||||
result := checkUsersFileInfoIntegrity(supplier)
|
result := checkUsersFileInfoIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Len(t, data.Records, 1)
|
require.Len(t, data.Records, 1)
|
||||||
@@ -1252,11 +1252,11 @@ func TestCheckUsersFileInfoIntegrity(t *testing.T) {
|
|||||||
|
|
||||||
func TestCheckUsersIncomingWebhooksIntegrity(t *testing.T) {
|
func TestCheckUsersIncomingWebhooksIntegrity(t *testing.T) {
|
||||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||||
supplier := ss.(*SqlSupplier)
|
store := ss.(*SqlStore)
|
||||||
dbmap := supplier.GetMaster()
|
dbmap := store.GetMaster()
|
||||||
|
|
||||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||||
result := checkUsersIncomingWebhooksIntegrity(supplier)
|
result := checkUsersIncomingWebhooksIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Empty(t, data.Records)
|
require.Empty(t, data.Records)
|
||||||
@@ -1265,7 +1265,7 @@ func TestCheckUsersIncomingWebhooksIntegrity(t *testing.T) {
|
|||||||
t.Run("should generate a report with one record", func(t *testing.T) {
|
t.Run("should generate a report with one record", func(t *testing.T) {
|
||||||
userId := model.NewId()
|
userId := model.NewId()
|
||||||
wh := createIncomingWebhook(ss, userId, model.NewId(), model.NewId())
|
wh := createIncomingWebhook(ss, userId, model.NewId(), model.NewId())
|
||||||
result := checkUsersIncomingWebhooksIntegrity(supplier)
|
result := checkUsersIncomingWebhooksIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Len(t, data.Records, 1)
|
require.Len(t, data.Records, 1)
|
||||||
@@ -1280,11 +1280,11 @@ func TestCheckUsersIncomingWebhooksIntegrity(t *testing.T) {
|
|||||||
|
|
||||||
func TestCheckUsersOAuthAccessDataIntegrity(t *testing.T) {
|
func TestCheckUsersOAuthAccessDataIntegrity(t *testing.T) {
|
||||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||||
supplier := ss.(*SqlSupplier)
|
store := ss.(*SqlStore)
|
||||||
dbmap := supplier.GetMaster()
|
dbmap := store.GetMaster()
|
||||||
|
|
||||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||||
result := checkUsersOAuthAccessDataIntegrity(supplier)
|
result := checkUsersOAuthAccessDataIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Empty(t, data.Records)
|
require.Empty(t, data.Records)
|
||||||
@@ -1295,7 +1295,7 @@ func TestCheckUsersOAuthAccessDataIntegrity(t *testing.T) {
|
|||||||
userId := user.Id
|
userId := user.Id
|
||||||
ad := createOAuthAccessData(ss, userId)
|
ad := createOAuthAccessData(ss, userId)
|
||||||
dbmap.Delete(user)
|
dbmap.Delete(user)
|
||||||
result := checkUsersOAuthAccessDataIntegrity(supplier)
|
result := checkUsersOAuthAccessDataIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Len(t, data.Records, 1)
|
require.Len(t, data.Records, 1)
|
||||||
@@ -1310,11 +1310,11 @@ func TestCheckUsersOAuthAccessDataIntegrity(t *testing.T) {
|
|||||||
|
|
||||||
func TestCheckUsersOAuthAppsIntegrity(t *testing.T) {
|
func TestCheckUsersOAuthAppsIntegrity(t *testing.T) {
|
||||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||||
supplier := ss.(*SqlSupplier)
|
store := ss.(*SqlStore)
|
||||||
dbmap := supplier.GetMaster()
|
dbmap := store.GetMaster()
|
||||||
|
|
||||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||||
result := checkUsersOAuthAppsIntegrity(supplier)
|
result := checkUsersOAuthAppsIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Empty(t, data.Records)
|
require.Empty(t, data.Records)
|
||||||
@@ -1325,7 +1325,7 @@ func TestCheckUsersOAuthAppsIntegrity(t *testing.T) {
|
|||||||
userId := user.Id
|
userId := user.Id
|
||||||
app := createOAuthApp(ss, userId)
|
app := createOAuthApp(ss, userId)
|
||||||
dbmap.Delete(user)
|
dbmap.Delete(user)
|
||||||
result := checkUsersOAuthAppsIntegrity(supplier)
|
result := checkUsersOAuthAppsIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Len(t, data.Records, 1)
|
require.Len(t, data.Records, 1)
|
||||||
@@ -1340,11 +1340,11 @@ func TestCheckUsersOAuthAppsIntegrity(t *testing.T) {
|
|||||||
|
|
||||||
func TestCheckUsersOAuthAuthDataIntegrity(t *testing.T) {
|
func TestCheckUsersOAuthAuthDataIntegrity(t *testing.T) {
|
||||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||||
supplier := ss.(*SqlSupplier)
|
store := ss.(*SqlStore)
|
||||||
dbmap := supplier.GetMaster()
|
dbmap := store.GetMaster()
|
||||||
|
|
||||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||||
result := checkUsersOAuthAuthDataIntegrity(supplier)
|
result := checkUsersOAuthAuthDataIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Empty(t, data.Records)
|
require.Empty(t, data.Records)
|
||||||
@@ -1355,7 +1355,7 @@ func TestCheckUsersOAuthAuthDataIntegrity(t *testing.T) {
|
|||||||
userId := user.Id
|
userId := user.Id
|
||||||
ad := createOAuthAuthData(ss, userId)
|
ad := createOAuthAuthData(ss, userId)
|
||||||
dbmap.Delete(user)
|
dbmap.Delete(user)
|
||||||
result := checkUsersOAuthAuthDataIntegrity(supplier)
|
result := checkUsersOAuthAuthDataIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Len(t, data.Records, 1)
|
require.Len(t, data.Records, 1)
|
||||||
@@ -1370,11 +1370,11 @@ func TestCheckUsersOAuthAuthDataIntegrity(t *testing.T) {
|
|||||||
|
|
||||||
func TestCheckUsersOutgoingWebhooksIntegrity(t *testing.T) {
|
func TestCheckUsersOutgoingWebhooksIntegrity(t *testing.T) {
|
||||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||||
supplier := ss.(*SqlSupplier)
|
store := ss.(*SqlStore)
|
||||||
dbmap := supplier.GetMaster()
|
dbmap := store.GetMaster()
|
||||||
|
|
||||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||||
result := checkUsersOutgoingWebhooksIntegrity(supplier)
|
result := checkUsersOutgoingWebhooksIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Empty(t, data.Records)
|
require.Empty(t, data.Records)
|
||||||
@@ -1383,7 +1383,7 @@ func TestCheckUsersOutgoingWebhooksIntegrity(t *testing.T) {
|
|||||||
t.Run("should generate a report with one record", func(t *testing.T) {
|
t.Run("should generate a report with one record", func(t *testing.T) {
|
||||||
userId := model.NewId()
|
userId := model.NewId()
|
||||||
wh := createOutgoingWebhook(ss, userId, model.NewId(), model.NewId())
|
wh := createOutgoingWebhook(ss, userId, model.NewId(), model.NewId())
|
||||||
result := checkUsersOutgoingWebhooksIntegrity(supplier)
|
result := checkUsersOutgoingWebhooksIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Len(t, data.Records, 1)
|
require.Len(t, data.Records, 1)
|
||||||
@@ -1398,11 +1398,11 @@ func TestCheckUsersOutgoingWebhooksIntegrity(t *testing.T) {
|
|||||||
|
|
||||||
func TestCheckUsersPostsIntegrity(t *testing.T) {
|
func TestCheckUsersPostsIntegrity(t *testing.T) {
|
||||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||||
supplier := ss.(*SqlSupplier)
|
store := ss.(*SqlStore)
|
||||||
dbmap := supplier.GetMaster()
|
dbmap := store.GetMaster()
|
||||||
|
|
||||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||||
result := checkUsersPostsIntegrity(supplier)
|
result := checkUsersPostsIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Empty(t, data.Records)
|
require.Empty(t, data.Records)
|
||||||
@@ -1410,7 +1410,7 @@ func TestCheckUsersPostsIntegrity(t *testing.T) {
|
|||||||
|
|
||||||
t.Run("should generate a report with one record", func(t *testing.T) {
|
t.Run("should generate a report with one record", func(t *testing.T) {
|
||||||
post := createPostWithUserId(ss, model.NewId())
|
post := createPostWithUserId(ss, model.NewId())
|
||||||
result := checkUsersPostsIntegrity(supplier)
|
result := checkUsersPostsIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Len(t, data.Records, 1)
|
require.Len(t, data.Records, 1)
|
||||||
@@ -1425,11 +1425,11 @@ func TestCheckUsersPostsIntegrity(t *testing.T) {
|
|||||||
|
|
||||||
func TestCheckUsersPreferencesIntegrity(t *testing.T) {
|
func TestCheckUsersPreferencesIntegrity(t *testing.T) {
|
||||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||||
supplier := ss.(*SqlSupplier)
|
store := ss.(*SqlStore)
|
||||||
dbmap := supplier.GetMaster()
|
dbmap := store.GetMaster()
|
||||||
|
|
||||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||||
result := checkUsersPreferencesIntegrity(supplier)
|
result := checkUsersPreferencesIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Empty(t, data.Records)
|
require.Empty(t, data.Records)
|
||||||
@@ -1441,7 +1441,7 @@ func TestCheckUsersPreferencesIntegrity(t *testing.T) {
|
|||||||
userId := user.Id
|
userId := user.Id
|
||||||
preferences := createPreferences(ss, userId)
|
preferences := createPreferences(ss, userId)
|
||||||
require.NotNil(t, preferences)
|
require.NotNil(t, preferences)
|
||||||
result := checkUsersPreferencesIntegrity(supplier)
|
result := checkUsersPreferencesIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Empty(t, data.Records)
|
require.Empty(t, data.Records)
|
||||||
@@ -1456,7 +1456,7 @@ func TestCheckUsersPreferencesIntegrity(t *testing.T) {
|
|||||||
preferences := createPreferences(ss, userId)
|
preferences := createPreferences(ss, userId)
|
||||||
require.NotNil(t, preferences)
|
require.NotNil(t, preferences)
|
||||||
dbmap.Delete(user)
|
dbmap.Delete(user)
|
||||||
result := checkUsersPreferencesIntegrity(supplier)
|
result := checkUsersPreferencesIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Len(t, data.Records, 1)
|
require.Len(t, data.Records, 1)
|
||||||
@@ -1471,11 +1471,11 @@ func TestCheckUsersPreferencesIntegrity(t *testing.T) {
|
|||||||
|
|
||||||
func TestCheckUsersReactionsIntegrity(t *testing.T) {
|
func TestCheckUsersReactionsIntegrity(t *testing.T) {
|
||||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||||
supplier := ss.(*SqlSupplier)
|
store := ss.(*SqlStore)
|
||||||
dbmap := supplier.GetMaster()
|
dbmap := store.GetMaster()
|
||||||
|
|
||||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||||
result := checkUsersReactionsIntegrity(supplier)
|
result := checkUsersReactionsIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Empty(t, data.Records)
|
require.Empty(t, data.Records)
|
||||||
@@ -1486,7 +1486,7 @@ func TestCheckUsersReactionsIntegrity(t *testing.T) {
|
|||||||
userId := user.Id
|
userId := user.Id
|
||||||
reaction := createReaction(ss, user.Id, model.NewId())
|
reaction := createReaction(ss, user.Id, model.NewId())
|
||||||
dbmap.Delete(user)
|
dbmap.Delete(user)
|
||||||
result := checkUsersReactionsIntegrity(supplier)
|
result := checkUsersReactionsIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Len(t, data.Records, 1)
|
require.Len(t, data.Records, 1)
|
||||||
@@ -1500,11 +1500,11 @@ func TestCheckUsersReactionsIntegrity(t *testing.T) {
|
|||||||
|
|
||||||
func TestCheckUsersSessionsIntegrity(t *testing.T) {
|
func TestCheckUsersSessionsIntegrity(t *testing.T) {
|
||||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||||
supplier := ss.(*SqlSupplier)
|
store := ss.(*SqlStore)
|
||||||
dbmap := supplier.GetMaster()
|
dbmap := store.GetMaster()
|
||||||
|
|
||||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||||
result := checkUsersSessionsIntegrity(supplier)
|
result := checkUsersSessionsIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Empty(t, data.Records)
|
require.Empty(t, data.Records)
|
||||||
@@ -1513,7 +1513,7 @@ func TestCheckUsersSessionsIntegrity(t *testing.T) {
|
|||||||
t.Run("should generate a report with one record", func(t *testing.T) {
|
t.Run("should generate a report with one record", func(t *testing.T) {
|
||||||
userId := model.NewId()
|
userId := model.NewId()
|
||||||
session := createSession(ss, userId)
|
session := createSession(ss, userId)
|
||||||
result := checkUsersSessionsIntegrity(supplier)
|
result := checkUsersSessionsIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Len(t, data.Records, 1)
|
require.Len(t, data.Records, 1)
|
||||||
@@ -1528,11 +1528,11 @@ func TestCheckUsersSessionsIntegrity(t *testing.T) {
|
|||||||
|
|
||||||
func TestCheckUsersStatusIntegrity(t *testing.T) {
|
func TestCheckUsersStatusIntegrity(t *testing.T) {
|
||||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||||
supplier := ss.(*SqlSupplier)
|
store := ss.(*SqlStore)
|
||||||
dbmap := supplier.GetMaster()
|
dbmap := store.GetMaster()
|
||||||
|
|
||||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||||
result := checkUsersStatusIntegrity(supplier)
|
result := checkUsersStatusIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Empty(t, data.Records)
|
require.Empty(t, data.Records)
|
||||||
@@ -1543,7 +1543,7 @@ func TestCheckUsersStatusIntegrity(t *testing.T) {
|
|||||||
userId := user.Id
|
userId := user.Id
|
||||||
status := createStatus(ss, user.Id)
|
status := createStatus(ss, user.Id)
|
||||||
dbmap.Delete(user)
|
dbmap.Delete(user)
|
||||||
result := checkUsersStatusIntegrity(supplier)
|
result := checkUsersStatusIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Len(t, data.Records, 1)
|
require.Len(t, data.Records, 1)
|
||||||
@@ -1557,11 +1557,11 @@ func TestCheckUsersStatusIntegrity(t *testing.T) {
|
|||||||
|
|
||||||
func TestCheckUsersTeamMembersIntegrity(t *testing.T) {
|
func TestCheckUsersTeamMembersIntegrity(t *testing.T) {
|
||||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||||
supplier := ss.(*SqlSupplier)
|
store := ss.(*SqlStore)
|
||||||
dbmap := supplier.GetMaster()
|
dbmap := store.GetMaster()
|
||||||
|
|
||||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||||
result := checkUsersTeamMembersIntegrity(supplier)
|
result := checkUsersTeamMembersIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Empty(t, data.Records)
|
require.Empty(t, data.Records)
|
||||||
@@ -1572,7 +1572,7 @@ func TestCheckUsersTeamMembersIntegrity(t *testing.T) {
|
|||||||
team := createTeam(ss, user.Id)
|
team := createTeam(ss, user.Id)
|
||||||
member := createTeamMember(ss, team.Id, user.Id)
|
member := createTeamMember(ss, team.Id, user.Id)
|
||||||
dbmap.Delete(user)
|
dbmap.Delete(user)
|
||||||
result := checkUsersTeamMembersIntegrity(supplier)
|
result := checkUsersTeamMembersIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Len(t, data.Records, 1)
|
require.Len(t, data.Records, 1)
|
||||||
@@ -1587,11 +1587,11 @@ func TestCheckUsersTeamMembersIntegrity(t *testing.T) {
|
|||||||
|
|
||||||
func TestCheckUsersUserAccessTokensIntegrity(t *testing.T) {
|
func TestCheckUsersUserAccessTokensIntegrity(t *testing.T) {
|
||||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||||
supplier := ss.(*SqlSupplier)
|
store := ss.(*SqlStore)
|
||||||
dbmap := supplier.GetMaster()
|
dbmap := store.GetMaster()
|
||||||
|
|
||||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||||
result := checkUsersUserAccessTokensIntegrity(supplier)
|
result := checkUsersUserAccessTokensIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Empty(t, data.Records)
|
require.Empty(t, data.Records)
|
||||||
@@ -1602,7 +1602,7 @@ func TestCheckUsersUserAccessTokensIntegrity(t *testing.T) {
|
|||||||
userId := user.Id
|
userId := user.Id
|
||||||
uat := createUserAccessToken(ss, user.Id)
|
uat := createUserAccessToken(ss, user.Id)
|
||||||
dbmap.Delete(user)
|
dbmap.Delete(user)
|
||||||
result := checkUsersUserAccessTokensIntegrity(supplier)
|
result := checkUsersUserAccessTokensIntegrity(store)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, result.Err)
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||||
require.Len(t, data.Records, 1)
|
require.Len(t, data.Records, 1)
|
||||||
|
|||||||
@@ -17,13 +17,13 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type SqlJobStore struct {
|
type SqlJobStore struct {
|
||||||
*SqlSupplier
|
*SqlStore
|
||||||
}
|
}
|
||||||
|
|
||||||
func newSqlJobStore(sqlSupplier *SqlSupplier) store.JobStore {
|
func newSqlJobStore(sqlStore *SqlStore) store.JobStore {
|
||||||
s := &SqlJobStore{sqlSupplier}
|
s := &SqlJobStore{sqlStore}
|
||||||
|
|
||||||
for _, db := range sqlSupplier.GetAllConns() {
|
for _, db := range sqlStore.GetAllConns() {
|
||||||
table := db.AddTableWithName(model.Job{}, "Jobs").SetKeys(false, "Id")
|
table := db.AddTableWithName(model.Job{}, "Jobs").SetKeys(false, "Id")
|
||||||
table.ColMap("Id").SetMaxSize(26)
|
table.ColMap("Id").SetMaxSize(26)
|
||||||
table.ColMap("Type").SetMaxSize(32)
|
table.ColMap("Type").SetMaxSize(32)
|
||||||
|
|||||||
@@ -15,13 +15,13 @@ import (
|
|||||||
// SqlLicenseStore encapsulates the database writes and reads for
|
// SqlLicenseStore encapsulates the database writes and reads for
|
||||||
// model.LicenseRecord objects.
|
// model.LicenseRecord objects.
|
||||||
type SqlLicenseStore struct {
|
type SqlLicenseStore struct {
|
||||||
*SqlSupplier
|
*SqlStore
|
||||||
}
|
}
|
||||||
|
|
||||||
func newSqlLicenseStore(sqlSupplier *SqlSupplier) store.LicenseStore {
|
func newSqlLicenseStore(sqlStore *SqlStore) store.LicenseStore {
|
||||||
ls := &SqlLicenseStore{sqlSupplier}
|
ls := &SqlLicenseStore{sqlStore}
|
||||||
|
|
||||||
for _, db := range sqlSupplier.GetAllConns() {
|
for _, db := range sqlStore.GetAllConns() {
|
||||||
table := db.AddTableWithName(model.LicenseRecord{}, "Licenses").SetKeys(false, "Id")
|
table := db.AddTableWithName(model.LicenseRecord{}, "Licenses").SetKeys(false, "Id")
|
||||||
table.ColMap("Id").SetMaxSize(26)
|
table.ColMap("Id").SetMaxSize(26)
|
||||||
table.ColMap("Bytes").SetMaxSize(10000)
|
table.ColMap("Bytes").SetMaxSize(10000)
|
||||||
|
|||||||
@@ -14,13 +14,13 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type SqlLinkMetadataStore struct {
|
type SqlLinkMetadataStore struct {
|
||||||
*SqlSupplier
|
*SqlStore
|
||||||
}
|
}
|
||||||
|
|
||||||
func newSqlLinkMetadataStore(sqlSupplier *SqlSupplier) store.LinkMetadataStore {
|
func newSqlLinkMetadataStore(sqlStore *SqlStore) store.LinkMetadataStore {
|
||||||
s := &SqlLinkMetadataStore{sqlSupplier}
|
s := &SqlLinkMetadataStore{sqlStore}
|
||||||
|
|
||||||
for _, db := range sqlSupplier.GetAllConns() {
|
for _, db := range sqlStore.GetAllConns() {
|
||||||
table := db.AddTableWithName(model.LinkMetadata{}, "LinkMetadata").SetKeys(false, "Hash")
|
table := db.AddTableWithName(model.LinkMetadata{}, "LinkMetadata").SetKeys(false, "Hash")
|
||||||
table.ColMap("URL").SetMaxSize(2048)
|
table.ColMap("URL").SetMaxSize(2048)
|
||||||
table.ColMap("Type").SetMaxSize(16)
|
table.ColMap("Type").SetMaxSize(16)
|
||||||
|
|||||||
@@ -15,13 +15,13 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type SqlOAuthStore struct {
|
type SqlOAuthStore struct {
|
||||||
*SqlSupplier
|
*SqlStore
|
||||||
}
|
}
|
||||||
|
|
||||||
func newSqlOAuthStore(sqlSupplier *SqlSupplier) store.OAuthStore {
|
func newSqlOAuthStore(sqlStore *SqlStore) store.OAuthStore {
|
||||||
as := &SqlOAuthStore{sqlSupplier}
|
as := &SqlOAuthStore{sqlStore}
|
||||||
|
|
||||||
for _, db := range sqlSupplier.GetAllConns() {
|
for _, db := range sqlStore.GetAllConns() {
|
||||||
table := db.AddTableWithName(model.OAuthApp{}, "OAuthApps").SetKeys(false, "Id")
|
table := db.AddTableWithName(model.OAuthApp{}, "OAuthApps").SetKeys(false, "Id")
|
||||||
table.ColMap("Id").SetMaxSize(26)
|
table.ColMap("Id").SetMaxSize(26)
|
||||||
table.ColMap("CreatorId").SetMaxSize(26)
|
table.ColMap("CreatorId").SetMaxSize(26)
|
||||||
|
|||||||
@@ -20,13 +20,13 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type SqlPluginStore struct {
|
type SqlPluginStore struct {
|
||||||
*SqlSupplier
|
*SqlStore
|
||||||
}
|
}
|
||||||
|
|
||||||
func newSqlPluginStore(sqlSupplier *SqlSupplier) store.PluginStore {
|
func newSqlPluginStore(sqlStore *SqlStore) store.PluginStore {
|
||||||
s := &SqlPluginStore{sqlSupplier}
|
s := &SqlPluginStore{sqlStore}
|
||||||
|
|
||||||
for _, db := range sqlSupplier.GetAllConns() {
|
for _, db := range sqlStore.GetAllConns() {
|
||||||
table := db.AddTableWithName(model.PluginKeyValue{}, "PluginKeyValueStore").SetKeys(false, "PluginId", "Key")
|
table := db.AddTableWithName(model.PluginKeyValue{}, "PluginKeyValueStore").SetKeys(false, "PluginId", "Key")
|
||||||
table.ColMap("PluginId").SetMaxSize(190)
|
table.ColMap("PluginId").SetMaxSize(190)
|
||||||
table.ColMap("Key").SetMaxSize(50)
|
table.ColMap("Key").SetMaxSize(50)
|
||||||
|
|||||||
@@ -10,5 +10,5 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestPluginStore(t *testing.T) {
|
func TestPluginStore(t *testing.T) {
|
||||||
StoreTestWithSqlSupplier(t, storetest.TestPluginStore)
|
StoreTestWithSqlStore(t, storetest.TestPluginStore)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type SqlPostStore struct {
|
type SqlPostStore struct {
|
||||||
*SqlSupplier
|
*SqlStore
|
||||||
metrics einterfaces.MetricsInterface
|
metrics einterfaces.MetricsInterface
|
||||||
maxPostSizeOnce sync.Once
|
maxPostSizeOnce sync.Once
|
||||||
maxPostSizeCached int
|
maxPostSizeCached int
|
||||||
@@ -60,14 +60,14 @@ func postToSlice(post *model.Post) []interface{} {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func newSqlPostStore(sqlSupplier *SqlSupplier, metrics einterfaces.MetricsInterface) store.PostStore {
|
func newSqlPostStore(sqlStore *SqlStore, metrics einterfaces.MetricsInterface) store.PostStore {
|
||||||
s := &SqlPostStore{
|
s := &SqlPostStore{
|
||||||
SqlSupplier: sqlSupplier,
|
SqlStore: sqlStore,
|
||||||
metrics: metrics,
|
metrics: metrics,
|
||||||
maxPostSizeCached: model.POST_MESSAGE_MAX_RUNES_V1,
|
maxPostSizeCached: model.POST_MESSAGE_MAX_RUNES_V1,
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, db := range sqlSupplier.GetAllConns() {
|
for _, db := range sqlStore.GetAllConns() {
|
||||||
table := db.AddTableWithName(model.Post{}, "Posts").SetKeys(false, "Id")
|
table := db.AddTableWithName(model.Post{}, "Posts").SetKeys(false, "Id")
|
||||||
table.ColMap("Id").SetMaxSize(26)
|
table.ColMap("Id").SetMaxSize(26)
|
||||||
table.ColMap("UserId").SetMaxSize(26)
|
table.ColMap("UserId").SetMaxSize(26)
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestPostStore(t *testing.T) {
|
func TestPostStore(t *testing.T) {
|
||||||
StoreTestWithSqlSupplier(t, storetest.TestPostStore)
|
StoreTestWithSqlStore(t, storetest.TestPostStore)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSearchPostStore(t *testing.T) {
|
func TestSearchPostStore(t *testing.T) {
|
||||||
|
|||||||
@@ -15,13 +15,13 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type SqlPreferenceStore struct {
|
type SqlPreferenceStore struct {
|
||||||
*SqlSupplier
|
*SqlStore
|
||||||
}
|
}
|
||||||
|
|
||||||
func newSqlPreferenceStore(sqlSupplier *SqlSupplier) store.PreferenceStore {
|
func newSqlPreferenceStore(sqlStore *SqlStore) store.PreferenceStore {
|
||||||
s := &SqlPreferenceStore{sqlSupplier}
|
s := &SqlPreferenceStore{sqlStore}
|
||||||
|
|
||||||
for _, db := range sqlSupplier.GetAllConns() {
|
for _, db := range sqlStore.GetAllConns() {
|
||||||
table := db.AddTableWithName(model.Preference{}, "Preferences").SetKeys(false, "UserId", "Category", "Name")
|
table := db.AddTableWithName(model.Preference{}, "Preferences").SetKeys(false, "UserId", "Category", "Name")
|
||||||
table.ColMap("UserId").SetMaxSize(26)
|
table.ColMap("UserId").SetMaxSize(26)
|
||||||
table.ColMap("Category").SetMaxSize(32)
|
table.ColMap("Category").SetMaxSize(32)
|
||||||
|
|||||||
@@ -14,13 +14,13 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type SqlProductNoticesStore struct {
|
type SqlProductNoticesStore struct {
|
||||||
*SqlSupplier
|
*SqlStore
|
||||||
}
|
}
|
||||||
|
|
||||||
func newSqlProductNoticesStore(sqlSupplier *SqlSupplier) store.ProductNoticesStore {
|
func newSqlProductNoticesStore(sqlStore *SqlStore) store.ProductNoticesStore {
|
||||||
s := SqlProductNoticesStore{sqlSupplier}
|
s := SqlProductNoticesStore{sqlStore}
|
||||||
|
|
||||||
for _, db := range sqlSupplier.GetAllConns() {
|
for _, db := range sqlStore.GetAllConns() {
|
||||||
table := db.AddTableWithName(model.ProductNoticeViewState{}, "ProductNoticeViewState").SetKeys(false, "UserId", "NoticeId")
|
table := db.AddTableWithName(model.ProductNoticeViewState{}, "ProductNoticeViewState").SetKeys(false, "UserId", "NoticeId")
|
||||||
table.ColMap("UserId").SetMaxSize(26)
|
table.ColMap("UserId").SetMaxSize(26)
|
||||||
table.ColMap("NoticeId").SetMaxSize(26)
|
table.ColMap("NoticeId").SetMaxSize(26)
|
||||||
|
|||||||
@@ -13,13 +13,13 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type SqlReactionStore struct {
|
type SqlReactionStore struct {
|
||||||
*SqlSupplier
|
*SqlStore
|
||||||
}
|
}
|
||||||
|
|
||||||
func newSqlReactionStore(sqlSupplier *SqlSupplier) store.ReactionStore {
|
func newSqlReactionStore(sqlStore *SqlStore) store.ReactionStore {
|
||||||
s := &SqlReactionStore{sqlSupplier}
|
s := &SqlReactionStore{sqlStore}
|
||||||
|
|
||||||
for _, db := range sqlSupplier.GetAllConns() {
|
for _, db := range sqlStore.GetAllConns() {
|
||||||
table := db.AddTableWithName(model.Reaction{}, "Reactions").SetKeys(false, "PostId", "UserId", "EmojiName")
|
table := db.AddTableWithName(model.Reaction{}, "Reactions").SetKeys(false, "PostId", "UserId", "EmojiName")
|
||||||
table.ColMap("UserId").SetMaxSize(26)
|
table.ColMap("UserId").SetMaxSize(26)
|
||||||
table.ColMap("PostId").SetMaxSize(26)
|
table.ColMap("PostId").SetMaxSize(26)
|
||||||
@@ -17,7 +17,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type SqlRoleStore struct {
|
type SqlRoleStore struct {
|
||||||
*SqlSupplier
|
*SqlStore
|
||||||
}
|
}
|
||||||
|
|
||||||
type Role struct {
|
type Role struct {
|
||||||
@@ -82,10 +82,10 @@ func (role Role) ToModel() *model.Role {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func newSqlRoleStore(sqlSupplier *SqlSupplier) store.RoleStore {
|
func newSqlRoleStore(sqlStore *SqlStore) store.RoleStore {
|
||||||
s := &SqlRoleStore{sqlSupplier}
|
s := &SqlRoleStore{sqlStore}
|
||||||
|
|
||||||
for _, db := range sqlSupplier.GetAllConns() {
|
for _, db := range sqlStore.GetAllConns() {
|
||||||
table := db.AddTableWithName(Role{}, "Roles").SetKeys(false, "Id")
|
table := db.AddTableWithName(Role{}, "Roles").SetKeys(false, "Id")
|
||||||
table.ColMap("Id").SetMaxSize(26)
|
table.ColMap("Id").SetMaxSize(26)
|
||||||
table.ColMap("Name").SetMaxSize(64).SetUnique(true)
|
table.ColMap("Name").SetMaxSize(64).SetUnique(true)
|
||||||
|
|||||||
@@ -10,5 +10,5 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestRoleStore(t *testing.T) {
|
func TestRoleStore(t *testing.T) {
|
||||||
StoreTestWithSqlSupplier(t, storetest.TestRoleStore)
|
StoreTestWithSqlStore(t, storetest.TestRoleStore)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,13 +16,13 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type SqlSchemeStore struct {
|
type SqlSchemeStore struct {
|
||||||
*SqlSupplier
|
*SqlStore
|
||||||
}
|
}
|
||||||
|
|
||||||
func newSqlSchemeStore(sqlSupplier *SqlSupplier) store.SchemeStore {
|
func newSqlSchemeStore(sqlStore *SqlStore) store.SchemeStore {
|
||||||
s := &SqlSchemeStore{sqlSupplier}
|
s := &SqlSchemeStore{sqlStore}
|
||||||
|
|
||||||
for _, db := range sqlSupplier.GetAllConns() {
|
for _, db := range sqlStore.GetAllConns() {
|
||||||
table := db.AddTableWithName(model.Scheme{}, "Schemes").SetKeys(false, "Id")
|
table := db.AddTableWithName(model.Scheme{}, "Schemes").SetKeys(false, "Id")
|
||||||
table.ColMap("Id").SetMaxSize(26)
|
table.ColMap("Id").SetMaxSize(26)
|
||||||
table.ColMap("Name").SetMaxSize(model.SCHEME_NAME_MAX_LENGTH).SetUnique(true)
|
table.ColMap("Name").SetMaxSize(model.SCHEME_NAME_MAX_LENGTH).SetUnique(true)
|
||||||
@@ -85,7 +85,7 @@ func (s *SqlSchemeStore) createScheme(scheme *model.Scheme, transaction *gorp.Tr
|
|||||||
// Fetch the default system scheme roles to populate default permissions.
|
// Fetch the default system scheme roles to populate default permissions.
|
||||||
defaultRoleNames := []string{model.TEAM_ADMIN_ROLE_ID, model.TEAM_USER_ROLE_ID, model.TEAM_GUEST_ROLE_ID, model.CHANNEL_ADMIN_ROLE_ID, model.CHANNEL_USER_ROLE_ID, model.CHANNEL_GUEST_ROLE_ID}
|
defaultRoleNames := []string{model.TEAM_ADMIN_ROLE_ID, model.TEAM_USER_ROLE_ID, model.TEAM_GUEST_ROLE_ID, model.CHANNEL_ADMIN_ROLE_ID, model.CHANNEL_USER_ROLE_ID, model.CHANNEL_GUEST_ROLE_ID}
|
||||||
defaultRoles := make(map[string]*model.Role)
|
defaultRoles := make(map[string]*model.Role)
|
||||||
roles, appErr := s.SqlSupplier.Role().GetByNames(defaultRoleNames)
|
roles, appErr := s.SqlStore.Role().GetByNames(defaultRoleNames)
|
||||||
if appErr != nil {
|
if appErr != nil {
|
||||||
return nil, appErr
|
return nil, appErr
|
||||||
}
|
}
|
||||||
@@ -121,7 +121,7 @@ func (s *SqlSchemeStore) createScheme(scheme *model.Scheme, transaction *gorp.Tr
|
|||||||
SchemeManaged: true,
|
SchemeManaged: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
savedRole, err := s.SqlSupplier.Role().(*SqlRoleStore).createRole(teamAdminRole, transaction)
|
savedRole, err := s.SqlStore.Role().(*SqlRoleStore).createRole(teamAdminRole, transaction)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -135,7 +135,7 @@ func (s *SqlSchemeStore) createScheme(scheme *model.Scheme, transaction *gorp.Tr
|
|||||||
SchemeManaged: true,
|
SchemeManaged: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
savedRole, err = s.SqlSupplier.Role().(*SqlRoleStore).createRole(teamUserRole, transaction)
|
savedRole, err = s.SqlStore.Role().(*SqlRoleStore).createRole(teamUserRole, transaction)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -149,7 +149,7 @@ func (s *SqlSchemeStore) createScheme(scheme *model.Scheme, transaction *gorp.Tr
|
|||||||
SchemeManaged: true,
|
SchemeManaged: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
savedRole, err = s.SqlSupplier.Role().(*SqlRoleStore).createRole(teamGuestRole, transaction)
|
savedRole, err = s.SqlStore.Role().(*SqlRoleStore).createRole(teamGuestRole, transaction)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -169,7 +169,7 @@ func (s *SqlSchemeStore) createScheme(scheme *model.Scheme, transaction *gorp.Tr
|
|||||||
channelAdminRole.Permissions = []string{}
|
channelAdminRole.Permissions = []string{}
|
||||||
}
|
}
|
||||||
|
|
||||||
savedRole, err := s.SqlSupplier.Role().(*SqlRoleStore).createRole(channelAdminRole, transaction)
|
savedRole, err := s.SqlStore.Role().(*SqlRoleStore).createRole(channelAdminRole, transaction)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -187,7 +187,7 @@ func (s *SqlSchemeStore) createScheme(scheme *model.Scheme, transaction *gorp.Tr
|
|||||||
channelUserRole.Permissions = filterModerated(channelUserRole.Permissions)
|
channelUserRole.Permissions = filterModerated(channelUserRole.Permissions)
|
||||||
}
|
}
|
||||||
|
|
||||||
savedRole, err = s.SqlSupplier.Role().(*SqlRoleStore).createRole(channelUserRole, transaction)
|
savedRole, err = s.SqlStore.Role().(*SqlRoleStore).createRole(channelUserRole, transaction)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -205,7 +205,7 @@ func (s *SqlSchemeStore) createScheme(scheme *model.Scheme, transaction *gorp.Tr
|
|||||||
channelGuestRole.Permissions = filterModerated(channelGuestRole.Permissions)
|
channelGuestRole.Permissions = filterModerated(channelGuestRole.Permissions)
|
||||||
}
|
}
|
||||||
|
|
||||||
savedRole, err = s.SqlSupplier.Role().(*SqlRoleStore).createRole(channelGuestRole, transaction)
|
savedRole, err = s.SqlStore.Role().(*SqlRoleStore).createRole(channelGuestRole, transaction)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,13 +21,13 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type SqlSessionStore struct {
|
type SqlSessionStore struct {
|
||||||
*SqlSupplier
|
*SqlStore
|
||||||
}
|
}
|
||||||
|
|
||||||
func newSqlSessionStore(sqlSupplier *SqlSupplier) store.SessionStore {
|
func newSqlSessionStore(sqlStore *SqlStore) store.SessionStore {
|
||||||
us := &SqlSessionStore{sqlSupplier}
|
us := &SqlSessionStore{sqlStore}
|
||||||
|
|
||||||
for _, db := range sqlSupplier.GetAllConns() {
|
for _, db := range sqlStore.GetAllConns() {
|
||||||
table := db.AddTableWithName(model.Session{}, "Sessions").SetKeys(false, "Id")
|
table := db.AddTableWithName(model.Session{}, "Sessions").SetKeys(false, "Id")
|
||||||
table.ColMap("Id").SetMaxSize(26)
|
table.ColMap("Id").SetMaxSize(26)
|
||||||
table.ColMap("Token").SetMaxSize(26)
|
table.ColMap("Token").SetMaxSize(26)
|
||||||
|
|||||||
@@ -16,13 +16,13 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type SqlStatusStore struct {
|
type SqlStatusStore struct {
|
||||||
*SqlSupplier
|
*SqlStore
|
||||||
}
|
}
|
||||||
|
|
||||||
func newSqlStatusStore(sqlSupplier *SqlSupplier) store.StatusStore {
|
func newSqlStatusStore(sqlStore *SqlStore) store.StatusStore {
|
||||||
s := &SqlStatusStore{sqlSupplier}
|
s := &SqlStatusStore{sqlStore}
|
||||||
|
|
||||||
for _, db := range sqlSupplier.GetAllConns() {
|
for _, db := range sqlStore.GetAllConns() {
|
||||||
table := db.AddTableWithName(model.Status{}, "Status").SetKeys(false, "UserId")
|
table := db.AddTableWithName(model.Status{}, "Status").SetKeys(false, "UserId")
|
||||||
table.ColMap("UserId").SetMaxSize(26)
|
table.ColMap("UserId").SetMaxSize(26)
|
||||||
table.ColMap("Status").SetMaxSize(32)
|
table.ColMap("Status").SetMaxSize(32)
|
||||||
|
|||||||
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
@@ -4,20 +4,30 @@
|
|||||||
package sqlstore
|
package sqlstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"regexp"
|
||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/go-sql-driver/mysql"
|
||||||
|
"github.com/lib/pq"
|
||||||
|
"github.com/mattermost/gorp"
|
||||||
"github.com/mattermost/mattermost-server/v5/model"
|
"github.com/mattermost/mattermost-server/v5/model"
|
||||||
"github.com/mattermost/mattermost-server/v5/store"
|
"github.com/mattermost/mattermost-server/v5/store"
|
||||||
"github.com/mattermost/mattermost-server/v5/store/searchtest"
|
"github.com/mattermost/mattermost-server/v5/store/searchtest"
|
||||||
"github.com/mattermost/mattermost-server/v5/store/storetest"
|
"github.com/mattermost/mattermost-server/v5/store/storetest"
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
|
_ "github.com/mattn/go-sqlite3"
|
||||||
)
|
)
|
||||||
|
|
||||||
type storeType struct {
|
type storeType struct {
|
||||||
Name string
|
Name string
|
||||||
SqlSettings *model.SqlSettings
|
SqlSettings *model.SqlSettings
|
||||||
SqlSupplier *SqlSupplier
|
SqlStore *SqlStore
|
||||||
Store store.Store
|
Store store.Store
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,7 +76,7 @@ func StoreTestWithSearchTestEngine(t *testing.T, f func(*testing.T, store.Store,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func StoreTestWithSqlSupplier(t *testing.T, f func(*testing.T, store.Store, storetest.SqlSupplier)) {
|
func StoreTestWithSqlStore(t *testing.T, f func(*testing.T, store.Store, storetest.SqlStore)) {
|
||||||
defer func() {
|
defer func() {
|
||||||
if err := recover(); err != nil {
|
if err := recover(); err != nil {
|
||||||
tearDownStores()
|
tearDownStores()
|
||||||
@@ -79,7 +89,7 @@ func StoreTestWithSqlSupplier(t *testing.T, f func(*testing.T, store.Store, stor
|
|||||||
if testing.Short() {
|
if testing.Short() {
|
||||||
t.SkipNow()
|
t.SkipNow()
|
||||||
}
|
}
|
||||||
f(t, st.Store, st.SqlSupplier)
|
f(t, st.Store, st.SqlStore)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -114,8 +124,8 @@ func initStores() {
|
|||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
st.SqlSupplier = NewSqlSupplier(*st.SqlSettings, nil)
|
st.SqlStore = New(*st.SqlSettings, nil)
|
||||||
st.Store = st.SqlSupplier
|
st.Store = st.SqlStore
|
||||||
st.Store.DropAllTables()
|
st.Store.DropAllTables()
|
||||||
st.Store.MarkSystemRanUnitTests()
|
st.Store.MarkSystemRanUnitTests()
|
||||||
}()
|
}()
|
||||||
@@ -147,3 +157,347 @@ func tearDownStores() {
|
|||||||
wg.Wait()
|
wg.Wait()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This test was used to consistently reproduce the race
|
||||||
|
// before the fix in MM-28397.
|
||||||
|
// Keeping it here to help avoiding future regressions.
|
||||||
|
func TestStoreLicenseRace(t *testing.T) {
|
||||||
|
settings := makeSqlSettings(model.DATABASE_DRIVER_SQLITE)
|
||||||
|
settings.DataSourceReplicas = []string{":memory:"}
|
||||||
|
settings.DataSourceSearchReplicas = []string{":memory:"}
|
||||||
|
store := New(*settings, nil)
|
||||||
|
|
||||||
|
wg := sync.WaitGroup{}
|
||||||
|
wg.Add(3)
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
store.UpdateLicense(&model.License{})
|
||||||
|
wg.Done()
|
||||||
|
}()
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
store.GetReplica()
|
||||||
|
wg.Done()
|
||||||
|
}()
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
store.GetSearchReplica()
|
||||||
|
wg.Done()
|
||||||
|
}()
|
||||||
|
|
||||||
|
wg.Wait()
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestGetReplica(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
testCases := []struct {
|
||||||
|
Description string
|
||||||
|
DataSourceReplicas []string
|
||||||
|
DataSourceSearchReplicas []string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
"no replicas",
|
||||||
|
[]string{},
|
||||||
|
[]string{},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"one source replica",
|
||||||
|
[]string{":memory:"},
|
||||||
|
[]string{},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"multiple source replicas",
|
||||||
|
[]string{":memory:", ":memory:", ":memory:"},
|
||||||
|
[]string{},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"one source search replica",
|
||||||
|
[]string{},
|
||||||
|
[]string{":memory:"},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"multiple source search replicas",
|
||||||
|
[]string{},
|
||||||
|
[]string{":memory:", ":memory:", ":memory:"},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"one source replica, one source search replica",
|
||||||
|
[]string{":memory:"},
|
||||||
|
[]string{":memory:"},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"one source replica, multiple source search replicas",
|
||||||
|
[]string{":memory:"},
|
||||||
|
[]string{":memory:", ":memory:", ":memory:"},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"multiple source replica, one source search replica",
|
||||||
|
[]string{":memory:", ":memory:", ":memory:"},
|
||||||
|
[]string{":memory:"},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"multiple source replica, multiple source search replicas",
|
||||||
|
[]string{":memory:", ":memory:", ":memory:"},
|
||||||
|
[]string{":memory:", ":memory:", ":memory:"},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, testCase := range testCases {
|
||||||
|
testCase := testCase
|
||||||
|
t.Run(testCase.Description+" with license", func(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
settings := makeSqlSettings(model.DATABASE_DRIVER_SQLITE)
|
||||||
|
settings.DataSourceReplicas = testCase.DataSourceReplicas
|
||||||
|
settings.DataSourceSearchReplicas = testCase.DataSourceSearchReplicas
|
||||||
|
store := New(*settings, nil)
|
||||||
|
store.UpdateLicense(&model.License{})
|
||||||
|
|
||||||
|
replicas := make(map[*gorp.DbMap]bool)
|
||||||
|
for i := 0; i < 5; i++ {
|
||||||
|
replicas[store.GetReplica()] = true
|
||||||
|
}
|
||||||
|
|
||||||
|
searchReplicas := make(map[*gorp.DbMap]bool)
|
||||||
|
for i := 0; i < 5; i++ {
|
||||||
|
searchReplicas[store.GetSearchReplica()] = true
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(testCase.DataSourceReplicas) > 0 {
|
||||||
|
// If replicas were defined, ensure none are the master.
|
||||||
|
assert.Len(t, replicas, len(testCase.DataSourceReplicas))
|
||||||
|
|
||||||
|
for replica := range replicas {
|
||||||
|
assert.NotEqual(t, store.GetMaster(), replica)
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if assert.Len(t, replicas, 1) {
|
||||||
|
// Otherwise ensure the replicas contains only the master.
|
||||||
|
for replica := range replicas {
|
||||||
|
assert.Equal(t, store.GetMaster(), replica)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(testCase.DataSourceSearchReplicas) > 0 {
|
||||||
|
// If search replicas were defined, ensure none are the master nor the replicas.
|
||||||
|
assert.Len(t, searchReplicas, len(testCase.DataSourceSearchReplicas))
|
||||||
|
|
||||||
|
for searchReplica := range searchReplicas {
|
||||||
|
assert.NotEqual(t, store.GetMaster(), searchReplica)
|
||||||
|
for replica := range replicas {
|
||||||
|
assert.NotEqual(t, searchReplica, replica)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if len(testCase.DataSourceReplicas) > 0 {
|
||||||
|
// If no search replicas were defined, but replicas were, ensure they are equal.
|
||||||
|
assert.Equal(t, replicas, searchReplicas)
|
||||||
|
|
||||||
|
} else if assert.Len(t, searchReplicas, 1) {
|
||||||
|
// Otherwise ensure the search replicas contains the master.
|
||||||
|
for searchReplica := range searchReplicas {
|
||||||
|
assert.Equal(t, store.GetMaster(), searchReplica)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run(testCase.Description+" without license", func(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
settings := makeSqlSettings(model.DATABASE_DRIVER_SQLITE)
|
||||||
|
settings.DataSourceReplicas = testCase.DataSourceReplicas
|
||||||
|
settings.DataSourceSearchReplicas = testCase.DataSourceSearchReplicas
|
||||||
|
store := New(*settings, nil)
|
||||||
|
|
||||||
|
replicas := make(map[*gorp.DbMap]bool)
|
||||||
|
for i := 0; i < 5; i++ {
|
||||||
|
replicas[store.GetReplica()] = true
|
||||||
|
}
|
||||||
|
|
||||||
|
searchReplicas := make(map[*gorp.DbMap]bool)
|
||||||
|
for i := 0; i < 5; i++ {
|
||||||
|
searchReplicas[store.GetSearchReplica()] = true
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(testCase.DataSourceReplicas) > 0 {
|
||||||
|
// If replicas were defined, ensure none are the master.
|
||||||
|
assert.Len(t, replicas, 1)
|
||||||
|
|
||||||
|
for replica := range replicas {
|
||||||
|
assert.Same(t, store.GetMaster(), replica)
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if assert.Len(t, replicas, 1) {
|
||||||
|
// Otherwise ensure the replicas contains only the master.
|
||||||
|
for replica := range replicas {
|
||||||
|
assert.Equal(t, store.GetMaster(), replica)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(testCase.DataSourceSearchReplicas) > 0 {
|
||||||
|
// If search replicas were defined, ensure none are the master nor the replicas.
|
||||||
|
assert.Len(t, searchReplicas, 1)
|
||||||
|
|
||||||
|
for searchReplica := range searchReplicas {
|
||||||
|
assert.Same(t, store.GetMaster(), searchReplica)
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if len(testCase.DataSourceReplicas) > 0 {
|
||||||
|
// If no search replicas were defined, but replicas were, ensure they are equal.
|
||||||
|
assert.Equal(t, replicas, searchReplicas)
|
||||||
|
|
||||||
|
} else if assert.Len(t, searchReplicas, 1) {
|
||||||
|
// Otherwise ensure the search replicas contains the master.
|
||||||
|
for searchReplica := range searchReplicas {
|
||||||
|
assert.Equal(t, store.GetMaster(), searchReplica)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestGetDbVersion(t *testing.T) {
|
||||||
|
testDrivers := []string{
|
||||||
|
model.DATABASE_DRIVER_POSTGRES,
|
||||||
|
model.DATABASE_DRIVER_MYSQL,
|
||||||
|
model.DATABASE_DRIVER_SQLITE,
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, driver := range testDrivers {
|
||||||
|
t.Run("Should return db version for "+driver, func(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
settings := makeSqlSettings(driver)
|
||||||
|
store := New(*settings, nil)
|
||||||
|
|
||||||
|
version, err := store.GetDbVersion()
|
||||||
|
require.Nil(t, err)
|
||||||
|
require.Regexp(t, regexp.MustCompile(`\d+\.\d+(\.\d+)?`), version)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestGetAllConns(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
testCases := []struct {
|
||||||
|
Description string
|
||||||
|
DataSourceReplicas []string
|
||||||
|
DataSourceSearchReplicas []string
|
||||||
|
ExpectedNumConnections int
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
"no replicas",
|
||||||
|
[]string{},
|
||||||
|
[]string{},
|
||||||
|
1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"one source replica",
|
||||||
|
[]string{":memory:"},
|
||||||
|
[]string{},
|
||||||
|
2,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"multiple source replicas",
|
||||||
|
[]string{":memory:", ":memory:", ":memory:"},
|
||||||
|
[]string{},
|
||||||
|
4,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"one source search replica",
|
||||||
|
[]string{},
|
||||||
|
[]string{":memory:"},
|
||||||
|
1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"multiple source search replicas",
|
||||||
|
[]string{},
|
||||||
|
[]string{":memory:", ":memory:", ":memory:"},
|
||||||
|
1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"one source replica, one source search replica",
|
||||||
|
[]string{":memory:"},
|
||||||
|
[]string{":memory:"},
|
||||||
|
2,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"one source replica, multiple source search replicas",
|
||||||
|
[]string{":memory:"},
|
||||||
|
[]string{":memory:", ":memory:", ":memory:"},
|
||||||
|
2,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"multiple source replica, one source search replica",
|
||||||
|
[]string{":memory:", ":memory:", ":memory:"},
|
||||||
|
[]string{":memory:"},
|
||||||
|
4,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"multiple source replica, multiple source search replicas",
|
||||||
|
[]string{":memory:", ":memory:", ":memory:"},
|
||||||
|
[]string{":memory:", ":memory:", ":memory:"},
|
||||||
|
4,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, testCase := range testCases {
|
||||||
|
testCase := testCase
|
||||||
|
t.Run(testCase.Description, func(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
settings := makeSqlSettings(model.DATABASE_DRIVER_SQLITE)
|
||||||
|
settings.DataSourceReplicas = testCase.DataSourceReplicas
|
||||||
|
settings.DataSourceSearchReplicas = testCase.DataSourceSearchReplicas
|
||||||
|
store := New(*settings, nil)
|
||||||
|
|
||||||
|
assert.Len(t, store.GetAllConns(), testCase.ExpectedNumConnections)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestIsDuplicate(t *testing.T) {
|
||||||
|
testErrors := map[error]bool{
|
||||||
|
&pq.Error{Code: "42P06"}: false,
|
||||||
|
&pq.Error{Code: PG_DUP_TABLE_ERROR_CODE}: true,
|
||||||
|
&mysql.MySQLError{Number: uint16(1000)}: false,
|
||||||
|
&mysql.MySQLError{Number: MYSQL_DUP_TABLE_ERROR_CODE}: true,
|
||||||
|
errors.New("Random error"): false,
|
||||||
|
}
|
||||||
|
|
||||||
|
for err, expected := range testErrors {
|
||||||
|
t.Run(fmt.Sprintf("Should return %t for %s", expected, err.Error()), func(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
assert.Equal(t, expected, IsDuplicate(err))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func makeSqlSettings(driver string) *model.SqlSettings {
|
||||||
|
switch driver {
|
||||||
|
case model.DATABASE_DRIVER_POSTGRES:
|
||||||
|
return storetest.MakeSqlSettings(driver)
|
||||||
|
case model.DATABASE_DRIVER_MYSQL:
|
||||||
|
return storetest.MakeSqlSettings(driver)
|
||||||
|
case model.DATABASE_DRIVER_SQLITE:
|
||||||
|
return makeSqliteSettings()
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func makeSqliteSettings() *model.SqlSettings {
|
||||||
|
driverName := model.DATABASE_DRIVER_SQLITE
|
||||||
|
dataSource := ":memory:"
|
||||||
|
maxIdleConns := 1
|
||||||
|
connMaxLifetimeMilliseconds := 3600000
|
||||||
|
maxOpenConns := 1
|
||||||
|
queryTimeout := 5
|
||||||
|
|
||||||
|
return &model.SqlSettings{
|
||||||
|
DriverName: &driverName,
|
||||||
|
DataSource: &dataSource,
|
||||||
|
MaxIdleConns: &maxIdleConns,
|
||||||
|
ConnMaxLifetimeMilliseconds: &connMaxLifetimeMilliseconds,
|
||||||
|
MaxOpenConns: &maxOpenConns,
|
||||||
|
QueryTimeout: &queryTimeout,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
@@ -1,367 +0,0 @@
|
|||||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
||||||
// See LICENSE.txt for license information.
|
|
||||||
|
|
||||||
package sqlstore_test
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"regexp"
|
|
||||||
"sync"
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/go-sql-driver/mysql"
|
|
||||||
"github.com/lib/pq"
|
|
||||||
"github.com/mattermost/gorp"
|
|
||||||
_ "github.com/mattn/go-sqlite3"
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
"github.com/stretchr/testify/require"
|
|
||||||
|
|
||||||
"github.com/mattermost/mattermost-server/v5/model"
|
|
||||||
"github.com/mattermost/mattermost-server/v5/store/sqlstore"
|
|
||||||
"github.com/mattermost/mattermost-server/v5/store/storetest"
|
|
||||||
)
|
|
||||||
|
|
||||||
// This test was used to consistently reproduce the race
|
|
||||||
// before the fix in MM-28397.
|
|
||||||
// Keeping it here to help avoiding future regressions.
|
|
||||||
func TestSupplierLicenseRace(t *testing.T) {
|
|
||||||
settings := makeSqlSettings(model.DATABASE_DRIVER_SQLITE)
|
|
||||||
settings.DataSourceReplicas = []string{":memory:"}
|
|
||||||
settings.DataSourceSearchReplicas = []string{":memory:"}
|
|
||||||
supplier := sqlstore.NewSqlSupplier(*settings, nil)
|
|
||||||
|
|
||||||
wg := sync.WaitGroup{}
|
|
||||||
wg.Add(3)
|
|
||||||
|
|
||||||
go func() {
|
|
||||||
supplier.UpdateLicense(&model.License{})
|
|
||||||
wg.Done()
|
|
||||||
}()
|
|
||||||
|
|
||||||
go func() {
|
|
||||||
supplier.GetReplica()
|
|
||||||
wg.Done()
|
|
||||||
}()
|
|
||||||
|
|
||||||
go func() {
|
|
||||||
supplier.GetSearchReplica()
|
|
||||||
wg.Done()
|
|
||||||
}()
|
|
||||||
|
|
||||||
wg.Wait()
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestGetReplica(t *testing.T) {
|
|
||||||
t.Parallel()
|
|
||||||
testCases := []struct {
|
|
||||||
Description string
|
|
||||||
DataSourceReplicas []string
|
|
||||||
DataSourceSearchReplicas []string
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
"no replicas",
|
|
||||||
[]string{},
|
|
||||||
[]string{},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"one source replica",
|
|
||||||
[]string{":memory:"},
|
|
||||||
[]string{},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"multiple source replicas",
|
|
||||||
[]string{":memory:", ":memory:", ":memory:"},
|
|
||||||
[]string{},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"one source search replica",
|
|
||||||
[]string{},
|
|
||||||
[]string{":memory:"},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"multiple source search replicas",
|
|
||||||
[]string{},
|
|
||||||
[]string{":memory:", ":memory:", ":memory:"},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"one source replica, one source search replica",
|
|
||||||
[]string{":memory:"},
|
|
||||||
[]string{":memory:"},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"one source replica, multiple source search replicas",
|
|
||||||
[]string{":memory:"},
|
|
||||||
[]string{":memory:", ":memory:", ":memory:"},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"multiple source replica, one source search replica",
|
|
||||||
[]string{":memory:", ":memory:", ":memory:"},
|
|
||||||
[]string{":memory:"},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"multiple source replica, multiple source search replicas",
|
|
||||||
[]string{":memory:", ":memory:", ":memory:"},
|
|
||||||
[]string{":memory:", ":memory:", ":memory:"},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, testCase := range testCases {
|
|
||||||
testCase := testCase
|
|
||||||
t.Run(testCase.Description+" with license", func(t *testing.T) {
|
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
settings := makeSqlSettings(model.DATABASE_DRIVER_SQLITE)
|
|
||||||
settings.DataSourceReplicas = testCase.DataSourceReplicas
|
|
||||||
settings.DataSourceSearchReplicas = testCase.DataSourceSearchReplicas
|
|
||||||
supplier := sqlstore.NewSqlSupplier(*settings, nil)
|
|
||||||
supplier.UpdateLicense(&model.License{})
|
|
||||||
|
|
||||||
replicas := make(map[*gorp.DbMap]bool)
|
|
||||||
for i := 0; i < 5; i++ {
|
|
||||||
replicas[supplier.GetReplica()] = true
|
|
||||||
}
|
|
||||||
|
|
||||||
searchReplicas := make(map[*gorp.DbMap]bool)
|
|
||||||
for i := 0; i < 5; i++ {
|
|
||||||
searchReplicas[supplier.GetSearchReplica()] = true
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(testCase.DataSourceReplicas) > 0 {
|
|
||||||
// If replicas were defined, ensure none are the master.
|
|
||||||
assert.Len(t, replicas, len(testCase.DataSourceReplicas))
|
|
||||||
|
|
||||||
for replica := range replicas {
|
|
||||||
assert.NotEqual(t, supplier.GetMaster(), replica)
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if assert.Len(t, replicas, 1) {
|
|
||||||
// Otherwise ensure the replicas contains only the master.
|
|
||||||
for replica := range replicas {
|
|
||||||
assert.Equal(t, supplier.GetMaster(), replica)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(testCase.DataSourceSearchReplicas) > 0 {
|
|
||||||
// If search replicas were defined, ensure none are the master nor the replicas.
|
|
||||||
assert.Len(t, searchReplicas, len(testCase.DataSourceSearchReplicas))
|
|
||||||
|
|
||||||
for searchReplica := range searchReplicas {
|
|
||||||
assert.NotEqual(t, supplier.GetMaster(), searchReplica)
|
|
||||||
for replica := range replicas {
|
|
||||||
assert.NotEqual(t, searchReplica, replica)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if len(testCase.DataSourceReplicas) > 0 {
|
|
||||||
// If no search replicas were defined, but replicas were, ensure they are equal.
|
|
||||||
assert.Equal(t, replicas, searchReplicas)
|
|
||||||
|
|
||||||
} else if assert.Len(t, searchReplicas, 1) {
|
|
||||||
// Otherwise ensure the search replicas contains the master.
|
|
||||||
for searchReplica := range searchReplicas {
|
|
||||||
assert.Equal(t, supplier.GetMaster(), searchReplica)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run(testCase.Description+" without license", func(t *testing.T) {
|
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
settings := makeSqlSettings(model.DATABASE_DRIVER_SQLITE)
|
|
||||||
settings.DataSourceReplicas = testCase.DataSourceReplicas
|
|
||||||
settings.DataSourceSearchReplicas = testCase.DataSourceSearchReplicas
|
|
||||||
supplier := sqlstore.NewSqlSupplier(*settings, nil)
|
|
||||||
|
|
||||||
replicas := make(map[*gorp.DbMap]bool)
|
|
||||||
for i := 0; i < 5; i++ {
|
|
||||||
replicas[supplier.GetReplica()] = true
|
|
||||||
}
|
|
||||||
|
|
||||||
searchReplicas := make(map[*gorp.DbMap]bool)
|
|
||||||
for i := 0; i < 5; i++ {
|
|
||||||
searchReplicas[supplier.GetSearchReplica()] = true
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(testCase.DataSourceReplicas) > 0 {
|
|
||||||
// If replicas were defined, ensure none are the master.
|
|
||||||
assert.Len(t, replicas, 1)
|
|
||||||
|
|
||||||
for replica := range replicas {
|
|
||||||
assert.Same(t, supplier.GetMaster(), replica)
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if assert.Len(t, replicas, 1) {
|
|
||||||
// Otherwise ensure the replicas contains only the master.
|
|
||||||
for replica := range replicas {
|
|
||||||
assert.Equal(t, supplier.GetMaster(), replica)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(testCase.DataSourceSearchReplicas) > 0 {
|
|
||||||
// If search replicas were defined, ensure none are the master nor the replicas.
|
|
||||||
assert.Len(t, searchReplicas, 1)
|
|
||||||
|
|
||||||
for searchReplica := range searchReplicas {
|
|
||||||
assert.Same(t, supplier.GetMaster(), searchReplica)
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if len(testCase.DataSourceReplicas) > 0 {
|
|
||||||
// If no search replicas were defined, but replicas were, ensure they are equal.
|
|
||||||
assert.Equal(t, replicas, searchReplicas)
|
|
||||||
|
|
||||||
} else if assert.Len(t, searchReplicas, 1) {
|
|
||||||
// Otherwise ensure the search replicas contains the master.
|
|
||||||
for searchReplica := range searchReplicas {
|
|
||||||
assert.Equal(t, supplier.GetMaster(), searchReplica)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestGetDbVersion(t *testing.T) {
|
|
||||||
testDrivers := []string{
|
|
||||||
model.DATABASE_DRIVER_POSTGRES,
|
|
||||||
model.DATABASE_DRIVER_MYSQL,
|
|
||||||
model.DATABASE_DRIVER_SQLITE,
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, driver := range testDrivers {
|
|
||||||
t.Run("Should return db version for "+driver, func(t *testing.T) {
|
|
||||||
t.Parallel()
|
|
||||||
settings := makeSqlSettings(driver)
|
|
||||||
supplier := sqlstore.NewSqlSupplier(*settings, nil)
|
|
||||||
|
|
||||||
version, err := supplier.GetDbVersion()
|
|
||||||
require.Nil(t, err)
|
|
||||||
require.Regexp(t, regexp.MustCompile(`\d+\.\d+(\.\d+)?`), version)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestGetAllConns(t *testing.T) {
|
|
||||||
t.Parallel()
|
|
||||||
testCases := []struct {
|
|
||||||
Description string
|
|
||||||
DataSourceReplicas []string
|
|
||||||
DataSourceSearchReplicas []string
|
|
||||||
ExpectedNumConnections int
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
"no replicas",
|
|
||||||
[]string{},
|
|
||||||
[]string{},
|
|
||||||
1,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"one source replica",
|
|
||||||
[]string{":memory:"},
|
|
||||||
[]string{},
|
|
||||||
2,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"multiple source replicas",
|
|
||||||
[]string{":memory:", ":memory:", ":memory:"},
|
|
||||||
[]string{},
|
|
||||||
4,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"one source search replica",
|
|
||||||
[]string{},
|
|
||||||
[]string{":memory:"},
|
|
||||||
1,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"multiple source search replicas",
|
|
||||||
[]string{},
|
|
||||||
[]string{":memory:", ":memory:", ":memory:"},
|
|
||||||
1,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"one source replica, one source search replica",
|
|
||||||
[]string{":memory:"},
|
|
||||||
[]string{":memory:"},
|
|
||||||
2,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"one source replica, multiple source search replicas",
|
|
||||||
[]string{":memory:"},
|
|
||||||
[]string{":memory:", ":memory:", ":memory:"},
|
|
||||||
2,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"multiple source replica, one source search replica",
|
|
||||||
[]string{":memory:", ":memory:", ":memory:"},
|
|
||||||
[]string{":memory:"},
|
|
||||||
4,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"multiple source replica, multiple source search replicas",
|
|
||||||
[]string{":memory:", ":memory:", ":memory:"},
|
|
||||||
[]string{":memory:", ":memory:", ":memory:"},
|
|
||||||
4,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, testCase := range testCases {
|
|
||||||
testCase := testCase
|
|
||||||
t.Run(testCase.Description, func(t *testing.T) {
|
|
||||||
t.Parallel()
|
|
||||||
settings := makeSqlSettings(model.DATABASE_DRIVER_SQLITE)
|
|
||||||
settings.DataSourceReplicas = testCase.DataSourceReplicas
|
|
||||||
settings.DataSourceSearchReplicas = testCase.DataSourceSearchReplicas
|
|
||||||
supplier := sqlstore.NewSqlSupplier(*settings, nil)
|
|
||||||
|
|
||||||
assert.Len(t, supplier.GetAllConns(), testCase.ExpectedNumConnections)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestIsDuplicate(t *testing.T) {
|
|
||||||
testErrors := map[error]bool{
|
|
||||||
&pq.Error{Code: "42P06"}: false,
|
|
||||||
&pq.Error{Code: sqlstore.PG_DUP_TABLE_ERROR_CODE}: true,
|
|
||||||
&mysql.MySQLError{Number: uint16(1000)}: false,
|
|
||||||
&mysql.MySQLError{Number: sqlstore.MYSQL_DUP_TABLE_ERROR_CODE}: true,
|
|
||||||
errors.New("Random error"): false,
|
|
||||||
}
|
|
||||||
|
|
||||||
for err, expected := range testErrors {
|
|
||||||
t.Run(fmt.Sprintf("Should return %t for %s", expected, err.Error()), func(t *testing.T) {
|
|
||||||
t.Parallel()
|
|
||||||
assert.Equal(t, expected, sqlstore.IsDuplicate(err))
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func makeSqlSettings(driver string) *model.SqlSettings {
|
|
||||||
switch driver {
|
|
||||||
case model.DATABASE_DRIVER_POSTGRES:
|
|
||||||
return storetest.MakeSqlSettings(driver)
|
|
||||||
case model.DATABASE_DRIVER_MYSQL:
|
|
||||||
return storetest.MakeSqlSettings(driver)
|
|
||||||
case model.DATABASE_DRIVER_SQLITE:
|
|
||||||
return makeSqliteSettings()
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func makeSqliteSettings() *model.SqlSettings {
|
|
||||||
driverName := model.DATABASE_DRIVER_SQLITE
|
|
||||||
dataSource := ":memory:"
|
|
||||||
maxIdleConns := 1
|
|
||||||
connMaxLifetimeMilliseconds := 3600000
|
|
||||||
maxOpenConns := 1
|
|
||||||
queryTimeout := 5
|
|
||||||
|
|
||||||
return &model.SqlSettings{
|
|
||||||
DriverName: &driverName,
|
|
||||||
DataSource: &dataSource,
|
|
||||||
MaxIdleConns: &maxIdleConns,
|
|
||||||
ConnMaxLifetimeMilliseconds: &connMaxLifetimeMilliseconds,
|
|
||||||
MaxOpenConns: &maxOpenConns,
|
|
||||||
QueryTimeout: &queryTimeout,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -18,13 +18,13 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type SqlSystemStore struct {
|
type SqlSystemStore struct {
|
||||||
*SqlSupplier
|
*SqlStore
|
||||||
}
|
}
|
||||||
|
|
||||||
func newSqlSystemStore(sqlSupplier *SqlSupplier) store.SystemStore {
|
func newSqlSystemStore(sqlStore *SqlStore) store.SystemStore {
|
||||||
s := &SqlSystemStore{sqlSupplier}
|
s := &SqlSystemStore{sqlStore}
|
||||||
|
|
||||||
for _, db := range sqlSupplier.GetAllConns() {
|
for _, db := range sqlStore.GetAllConns() {
|
||||||
table := db.AddTableWithName(model.System{}, "Systems").SetKeys(false, "Name")
|
table := db.AddTableWithName(model.System{}, "Systems").SetKeys(false, "Name")
|
||||||
table.ColMap("Name").SetMaxSize(64)
|
table.ColMap("Name").SetMaxSize(64)
|
||||||
table.ColMap("Value").SetMaxSize(1024)
|
table.ColMap("Value").SetMaxSize(1024)
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type SqlTeamStore struct {
|
type SqlTeamStore struct {
|
||||||
*SqlSupplier
|
*SqlStore
|
||||||
|
|
||||||
teamsQuery sq.SelectBuilder
|
teamsQuery sq.SelectBuilder
|
||||||
}
|
}
|
||||||
@@ -202,16 +202,16 @@ func (db teamMemberWithSchemeRolesList) ToModel() []*model.TeamMember {
|
|||||||
return tms
|
return tms
|
||||||
}
|
}
|
||||||
|
|
||||||
func newSqlTeamStore(sqlSupplier *SqlSupplier) store.TeamStore {
|
func newSqlTeamStore(sqlStore *SqlStore) store.TeamStore {
|
||||||
s := &SqlTeamStore{
|
s := &SqlTeamStore{
|
||||||
SqlSupplier: sqlSupplier,
|
SqlStore: sqlStore,
|
||||||
}
|
}
|
||||||
|
|
||||||
s.teamsQuery = s.getQueryBuilder().
|
s.teamsQuery = s.getQueryBuilder().
|
||||||
Select("Teams.*").
|
Select("Teams.*").
|
||||||
From("Teams")
|
From("Teams")
|
||||||
|
|
||||||
for _, db := range sqlSupplier.GetAllConns() {
|
for _, db := range sqlStore.GetAllConns() {
|
||||||
table := db.AddTableWithName(model.Team{}, "Teams").SetKeys(false, "Id")
|
table := db.AddTableWithName(model.Team{}, "Teams").SetKeys(false, "Id")
|
||||||
table.ColMap("Id").SetMaxSize(26)
|
table.ColMap("Id").SetMaxSize(26)
|
||||||
table.ColMap("DisplayName").SetMaxSize(64)
|
table.ColMap("DisplayName").SetMaxSize(64)
|
||||||
|
|||||||
@@ -14,14 +14,14 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type SqlTermsOfServiceStore struct {
|
type SqlTermsOfServiceStore struct {
|
||||||
*SqlSupplier
|
*SqlStore
|
||||||
metrics einterfaces.MetricsInterface
|
metrics einterfaces.MetricsInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
func newSqlTermsOfServiceStore(sqlSupplier *SqlSupplier, metrics einterfaces.MetricsInterface) store.TermsOfServiceStore {
|
func newSqlTermsOfServiceStore(sqlStore *SqlStore, metrics einterfaces.MetricsInterface) store.TermsOfServiceStore {
|
||||||
s := SqlTermsOfServiceStore{sqlSupplier, metrics}
|
s := SqlTermsOfServiceStore{sqlStore, metrics}
|
||||||
|
|
||||||
for _, db := range sqlSupplier.GetAllConns() {
|
for _, db := range sqlStore.GetAllConns() {
|
||||||
table := db.AddTableWithName(model.TermsOfService{}, "TermsOfService").SetKeys(false, "Id")
|
table := db.AddTableWithName(model.TermsOfService{}, "TermsOfService").SetKeys(false, "Id")
|
||||||
table.ColMap("Id").SetMaxSize(26)
|
table.ColMap("Id").SetMaxSize(26)
|
||||||
table.ColMap("UserId").SetMaxSize(26)
|
table.ColMap("UserId").SetMaxSize(26)
|
||||||
|
|||||||
@@ -16,18 +16,18 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type SqlThreadStore struct {
|
type SqlThreadStore struct {
|
||||||
*SqlSupplier
|
*SqlStore
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SqlThreadStore) ClearCaches() {
|
func (s *SqlThreadStore) ClearCaches() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func newSqlThreadStore(sqlSupplier *SqlSupplier) store.ThreadStore {
|
func newSqlThreadStore(sqlStore *SqlStore) store.ThreadStore {
|
||||||
s := &SqlThreadStore{
|
s := &SqlThreadStore{
|
||||||
SqlSupplier: sqlSupplier,
|
SqlStore: sqlStore,
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, db := range sqlSupplier.GetAllConns() {
|
for _, db := range sqlStore.GetAllConns() {
|
||||||
tableThreads := db.AddTableWithName(model.Thread{}, "Threads").SetKeys(false, "PostId")
|
tableThreads := db.AddTableWithName(model.Thread{}, "Threads").SetKeys(false, "PostId")
|
||||||
tableThreads.ColMap("PostId").SetMaxSize(26)
|
tableThreads.ColMap("PostId").SetMaxSize(26)
|
||||||
tableThreads.ColMap("ChannelId").SetMaxSize(26)
|
tableThreads.ColMap("ChannelId").SetMaxSize(26)
|
||||||
|
|||||||
@@ -10,5 +10,5 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestThreadStore(t *testing.T) {
|
func TestThreadStore(t *testing.T) {
|
||||||
StoreTestWithSqlSupplier(t, storetest.TestThreadStore)
|
StoreTestWithSqlStore(t, storetest.TestThreadStore)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,13 +15,13 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type SqlTokenStore struct {
|
type SqlTokenStore struct {
|
||||||
*SqlSupplier
|
*SqlStore
|
||||||
}
|
}
|
||||||
|
|
||||||
func newSqlTokenStore(sqlSupplier *SqlSupplier) store.TokenStore {
|
func newSqlTokenStore(sqlStore *SqlStore) store.TokenStore {
|
||||||
s := &SqlTokenStore{sqlSupplier}
|
s := &SqlTokenStore{sqlStore}
|
||||||
|
|
||||||
for _, db := range sqlSupplier.GetAllConns() {
|
for _, db := range sqlStore.GetAllConns() {
|
||||||
table := db.AddTableWithName(model.Token{}, "Tokens").SetKeys(false, "Token")
|
table := db.AddTableWithName(model.Token{}, "Tokens").SetKeys(false, "Token")
|
||||||
table.ColMap("Token").SetMaxSize(64)
|
table.ColMap("Token").SetMaxSize(64)
|
||||||
table.ColMap("Type").SetMaxSize(64)
|
table.ColMap("Type").SetMaxSize(64)
|
||||||
|
|||||||
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
@@ -12,7 +12,7 @@ import (
|
|||||||
|
|
||||||
func TestStoreUpgrade(t *testing.T) {
|
func TestStoreUpgrade(t *testing.T) {
|
||||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||||
sqlStore := ss.(*SqlSupplier)
|
sqlStore := ss.(*SqlStore)
|
||||||
|
|
||||||
t.Run("invalid currentModelVersion", func(t *testing.T) {
|
t.Run("invalid currentModelVersion", func(t *testing.T) {
|
||||||
err := upgradeDatabase(sqlStore, "notaversion")
|
err := upgradeDatabase(sqlStore, "notaversion")
|
||||||
@@ -81,7 +81,7 @@ func TestStoreUpgrade(t *testing.T) {
|
|||||||
|
|
||||||
func TestSaveSchemaVersion(t *testing.T) {
|
func TestSaveSchemaVersion(t *testing.T) {
|
||||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||||
sqlStore := ss.(*SqlSupplier)
|
sqlStore := ss.(*SqlStore)
|
||||||
|
|
||||||
t.Run("set earliest version", func(t *testing.T) {
|
t.Run("set earliest version", func(t *testing.T) {
|
||||||
saveSchemaVersion(sqlStore, VERSION_3_0_0)
|
saveSchemaVersion(sqlStore, VERSION_3_0_0)
|
||||||
|
|||||||
@@ -15,14 +15,14 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type SqlUploadSessionStore struct {
|
type SqlUploadSessionStore struct {
|
||||||
*SqlSupplier
|
*SqlStore
|
||||||
}
|
}
|
||||||
|
|
||||||
func newSqlUploadSessionStore(sqlSupplier *SqlSupplier) store.UploadSessionStore {
|
func newSqlUploadSessionStore(sqlStore *SqlStore) store.UploadSessionStore {
|
||||||
s := &SqlUploadSessionStore{
|
s := &SqlUploadSessionStore{
|
||||||
SqlSupplier: sqlSupplier,
|
SqlStore: sqlStore,
|
||||||
}
|
}
|
||||||
for _, db := range sqlSupplier.GetAllConns() {
|
for _, db := range sqlStore.GetAllConns() {
|
||||||
table := db.AddTableWithName(model.UploadSession{}, "UploadSessions").SetKeys(false, "Id")
|
table := db.AddTableWithName(model.UploadSession{}, "UploadSessions").SetKeys(false, "Id")
|
||||||
table.ColMap("Id").SetMaxSize(26)
|
table.ColMap("Id").SetMaxSize(26)
|
||||||
table.ColMap("Type").SetMaxSize(32)
|
table.ColMap("Type").SetMaxSize(32)
|
||||||
|
|||||||
@@ -15,13 +15,13 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type SqlUserAccessTokenStore struct {
|
type SqlUserAccessTokenStore struct {
|
||||||
*SqlSupplier
|
*SqlStore
|
||||||
}
|
}
|
||||||
|
|
||||||
func newSqlUserAccessTokenStore(sqlSupplier *SqlSupplier) store.UserAccessTokenStore {
|
func newSqlUserAccessTokenStore(sqlStore *SqlStore) store.UserAccessTokenStore {
|
||||||
s := &SqlUserAccessTokenStore{sqlSupplier}
|
s := &SqlUserAccessTokenStore{sqlStore}
|
||||||
|
|
||||||
for _, db := range sqlSupplier.GetAllConns() {
|
for _, db := range sqlStore.GetAllConns() {
|
||||||
table := db.AddTableWithName(model.UserAccessToken{}, "UserAccessTokens").SetKeys(false, "Id")
|
table := db.AddTableWithName(model.UserAccessToken{}, "UserAccessTokens").SetKeys(false, "Id")
|
||||||
table.ColMap("Id").SetMaxSize(26)
|
table.ColMap("Id").SetMaxSize(26)
|
||||||
table.ColMap("Token").SetMaxSize(26).SetUnique(true)
|
table.ColMap("Token").SetMaxSize(26).SetUnique(true)
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type SqlUserStore struct {
|
type SqlUserStore struct {
|
||||||
*SqlSupplier
|
*SqlStore
|
||||||
metrics einterfaces.MetricsInterface
|
metrics einterfaces.MetricsInterface
|
||||||
|
|
||||||
// usersQuery is a starting point for all queries that return one or more Users.
|
// usersQuery is a starting point for all queries that return one or more Users.
|
||||||
@@ -42,10 +42,10 @@ func (us SqlUserStore) ClearCaches() {}
|
|||||||
|
|
||||||
func (us SqlUserStore) InvalidateProfileCacheForUser(userId string) {}
|
func (us SqlUserStore) InvalidateProfileCacheForUser(userId string) {}
|
||||||
|
|
||||||
func newSqlUserStore(sqlSupplier *SqlSupplier, metrics einterfaces.MetricsInterface) store.UserStore {
|
func newSqlUserStore(sqlStore *SqlStore, metrics einterfaces.MetricsInterface) store.UserStore {
|
||||||
us := &SqlUserStore{
|
us := &SqlUserStore{
|
||||||
SqlSupplier: sqlSupplier,
|
SqlStore: sqlStore,
|
||||||
metrics: metrics,
|
metrics: metrics,
|
||||||
}
|
}
|
||||||
|
|
||||||
// note: we are providing field names explicitly here to maintain order of columns (needed when using raw queries)
|
// note: we are providing field names explicitly here to maintain order of columns (needed when using raw queries)
|
||||||
@@ -55,7 +55,7 @@ func newSqlUserStore(sqlSupplier *SqlSupplier, metrics einterfaces.MetricsInterf
|
|||||||
From("Users u").
|
From("Users u").
|
||||||
LeftJoin("Bots b ON ( b.UserId = u.Id )")
|
LeftJoin("Bots b ON ( b.UserId = u.Id )")
|
||||||
|
|
||||||
for _, db := range sqlSupplier.GetAllConns() {
|
for _, db := range sqlStore.GetAllConns() {
|
||||||
table := db.AddTableWithName(model.User{}, "Users").SetKeys(false, "Id")
|
table := db.AddTableWithName(model.User{}, "Users").SetKeys(false, "Id")
|
||||||
table.ColMap("Id").SetMaxSize(26)
|
table.ColMap("Id").SetMaxSize(26)
|
||||||
table.ColMap("Username").SetMaxSize(64).SetUnique(true)
|
table.ColMap("Username").SetMaxSize(64).SetUnique(true)
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestUserStore(t *testing.T) {
|
func TestUserStore(t *testing.T) {
|
||||||
StoreTestWithSqlSupplier(t, storetest.TestUserStore)
|
StoreTestWithSqlStore(t, storetest.TestUserStore)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSearchUserStore(t *testing.T) {
|
func TestSearchUserStore(t *testing.T) {
|
||||||
|
|||||||
@@ -13,13 +13,13 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type SqlUserTermsOfServiceStore struct {
|
type SqlUserTermsOfServiceStore struct {
|
||||||
*SqlSupplier
|
*SqlStore
|
||||||
}
|
}
|
||||||
|
|
||||||
func newSqlUserTermsOfServiceStore(sqlSupplier *SqlSupplier) store.UserTermsOfServiceStore {
|
func newSqlUserTermsOfServiceStore(sqlStore *SqlStore) store.UserTermsOfServiceStore {
|
||||||
s := SqlUserTermsOfServiceStore{sqlSupplier}
|
s := SqlUserTermsOfServiceStore{sqlStore}
|
||||||
|
|
||||||
for _, db := range sqlSupplier.GetAllConns() {
|
for _, db := range sqlStore.GetAllConns() {
|
||||||
table := db.AddTableWithName(model.UserTermsOfService{}, "UserTermsOfService").SetKeys(false, "UserId")
|
table := db.AddTableWithName(model.UserTermsOfService{}, "UserTermsOfService").SetKeys(false, "UserId")
|
||||||
table.ColMap("UserId").SetMaxSize(26)
|
table.ColMap("UserId").SetMaxSize(26)
|
||||||
table.ColMap("TermsOfServiceId").SetMaxSize(26)
|
table.ColMap("TermsOfServiceId").SetMaxSize(26)
|
||||||
|
|||||||
@@ -15,20 +15,20 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type SqlWebhookStore struct {
|
type SqlWebhookStore struct {
|
||||||
*SqlSupplier
|
*SqlStore
|
||||||
metrics einterfaces.MetricsInterface
|
metrics einterfaces.MetricsInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s SqlWebhookStore) ClearCaches() {
|
func (s SqlWebhookStore) ClearCaches() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func newSqlWebhookStore(sqlSupplier *SqlSupplier, metrics einterfaces.MetricsInterface) store.WebhookStore {
|
func newSqlWebhookStore(sqlStore *SqlStore, metrics einterfaces.MetricsInterface) store.WebhookStore {
|
||||||
s := &SqlWebhookStore{
|
s := &SqlWebhookStore{
|
||||||
SqlSupplier: sqlSupplier,
|
SqlStore: sqlStore,
|
||||||
metrics: metrics,
|
metrics: metrics,
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, db := range sqlSupplier.GetAllConns() {
|
for _, db := range sqlStore.GetAllConns() {
|
||||||
table := db.AddTableWithName(model.IncomingWebhook{}, "IncomingWebhooks").SetKeys(false, "Id")
|
table := db.AddTableWithName(model.IncomingWebhook{}, "IncomingWebhooks").SetKeys(false, "Id")
|
||||||
table.ColMap("Id").SetMaxSize(26)
|
table.ColMap("Id").SetMaxSize(26)
|
||||||
table.ColMap("UserId").SetMaxSize(26)
|
table.ColMap("UserId").SetMaxSize(26)
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ func makeBotWithUser(t *testing.T, ss store.Store, bot *model.Bot) (*model.Bot,
|
|||||||
return bot, user
|
return bot, user
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBotStore(t *testing.T, ss store.Store, s SqlSupplier) {
|
func TestBotStore(t *testing.T, ss store.Store, s SqlStore) {
|
||||||
t.Run("Get", func(t *testing.T) { testBotStoreGet(t, ss, s) })
|
t.Run("Get", func(t *testing.T) { testBotStoreGet(t, ss, s) })
|
||||||
t.Run("GetAll", func(t *testing.T) { testBotStoreGetAll(t, ss, s) })
|
t.Run("GetAll", func(t *testing.T) { testBotStoreGetAll(t, ss, s) })
|
||||||
t.Run("Save", func(t *testing.T) { testBotStoreSave(t, ss) })
|
t.Run("Save", func(t *testing.T) { testBotStoreSave(t, ss) })
|
||||||
@@ -32,7 +32,7 @@ func TestBotStore(t *testing.T, ss store.Store, s SqlSupplier) {
|
|||||||
t.Run("PermanentDelete", func(t *testing.T) { testBotStorePermanentDelete(t, ss) })
|
t.Run("PermanentDelete", func(t *testing.T) { testBotStorePermanentDelete(t, ss) })
|
||||||
}
|
}
|
||||||
|
|
||||||
func testBotStoreGet(t *testing.T, ss store.Store, s SqlSupplier) {
|
func testBotStoreGet(t *testing.T, ss store.Store, s SqlStore) {
|
||||||
deletedBot, _ := makeBotWithUser(t, ss, &model.Bot{
|
deletedBot, _ := makeBotWithUser(t, ss, &model.Bot{
|
||||||
Username: "deleted_bot",
|
Username: "deleted_bot",
|
||||||
Description: "A deleted bot",
|
Description: "A deleted bot",
|
||||||
@@ -117,7 +117,7 @@ func testBotStoreGet(t *testing.T, ss store.Store, s SqlSupplier) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func testBotStoreGetAll(t *testing.T, ss store.Store, s SqlSupplier) {
|
func testBotStoreGetAll(t *testing.T, ss store.Store, s SqlStore) {
|
||||||
OwnerId1 := model.NewId()
|
OwnerId1 := model.NewId()
|
||||||
OwnerId2 := model.NewId()
|
OwnerId2 := model.NewId()
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import (
|
|||||||
"github.com/mattermost/mattermost-server/v5/utils"
|
"github.com/mattermost/mattermost-server/v5/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
type SqlSupplier interface {
|
type SqlStore interface {
|
||||||
GetMaster() *gorp.DbMap
|
GetMaster() *gorp.DbMap
|
||||||
DriverName() string
|
DriverName() string
|
||||||
}
|
}
|
||||||
@@ -35,7 +35,7 @@ func cleanupChannels(t *testing.T, ss store.Store) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestChannelStore(t *testing.T, ss store.Store, s SqlSupplier) {
|
func TestChannelStore(t *testing.T, ss store.Store, s SqlStore) {
|
||||||
createDefaultRoles(t, ss)
|
createDefaultRoles(t, ss)
|
||||||
|
|
||||||
t.Run("Save", func(t *testing.T) { testChannelStoreSave(t, ss) })
|
t.Run("Save", func(t *testing.T) { testChannelStoreSave(t, ss) })
|
||||||
@@ -163,7 +163,7 @@ func testChannelStoreSave(t *testing.T, ss store.Store) {
|
|||||||
require.True(t, errors.As(nErr, &cErr))
|
require.True(t, errors.As(nErr, &cErr))
|
||||||
}
|
}
|
||||||
|
|
||||||
func testChannelStoreSaveDirectChannel(t *testing.T, ss store.Store, s SqlSupplier) {
|
func testChannelStoreSaveDirectChannel(t *testing.T, ss store.Store, s SqlStore) {
|
||||||
teamId := model.NewId()
|
teamId := model.NewId()
|
||||||
|
|
||||||
o1 := model.Channel{}
|
o1 := model.Channel{}
|
||||||
@@ -363,7 +363,7 @@ func testGetChannelUnread(t *testing.T, ss store.Store) {
|
|||||||
require.EqualValues(t, 10, ch2.MsgCount, "wrong MsgCount for channel 2")
|
require.EqualValues(t, 10, ch2.MsgCount, "wrong MsgCount for channel 2")
|
||||||
}
|
}
|
||||||
|
|
||||||
func testChannelStoreGet(t *testing.T, ss store.Store, s SqlSupplier) {
|
func testChannelStoreGet(t *testing.T, ss store.Store, s SqlStore) {
|
||||||
o1 := model.Channel{}
|
o1 := model.Channel{}
|
||||||
o1.TeamId = model.NewId()
|
o1.TeamId = model.NewId()
|
||||||
o1.DisplayName = "Name"
|
o1.DisplayName = "Name"
|
||||||
@@ -3256,7 +3256,7 @@ func testChannelStoreGetChannels(t *testing.T, ss store.Store) {
|
|||||||
ss.Channel().InvalidateAllChannelMembersForUser(m1.UserId)
|
ss.Channel().InvalidateAllChannelMembersForUser(m1.UserId)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testChannelStoreGetAllChannels(t *testing.T, ss store.Store, s SqlSupplier) {
|
func testChannelStoreGetAllChannels(t *testing.T, ss store.Store, s SqlStore) {
|
||||||
cleanupChannels(t, ss)
|
cleanupChannels(t, ss)
|
||||||
|
|
||||||
t1 := model.Team{}
|
t1 := model.Team{}
|
||||||
@@ -4949,7 +4949,7 @@ func (s ByChannelDisplayName) Less(i, j int) bool {
|
|||||||
return s[i].Id < s[j].Id
|
return s[i].Id < s[j].Id
|
||||||
}
|
}
|
||||||
|
|
||||||
func testChannelStoreSearchArchivedInTeam(t *testing.T, ss store.Store, s SqlSupplier) {
|
func testChannelStoreSearchArchivedInTeam(t *testing.T, ss store.Store, s SqlStore) {
|
||||||
teamId := model.NewId()
|
teamId := model.NewId()
|
||||||
userId := model.NewId()
|
userId := model.NewId()
|
||||||
|
|
||||||
@@ -4971,7 +4971,7 @@ func testChannelStoreSearchArchivedInTeam(t *testing.T, ss store.Store, s SqlSup
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func testChannelStoreSearchInTeam(t *testing.T, ss store.Store, s SqlSupplier) {
|
func testChannelStoreSearchInTeam(t *testing.T, ss store.Store, s SqlStore) {
|
||||||
teamId := model.NewId()
|
teamId := model.NewId()
|
||||||
otherTeamId := model.NewId()
|
otherTeamId := model.NewId()
|
||||||
|
|
||||||
@@ -6246,7 +6246,7 @@ func testChannelStoreClearAllCustomRoleAssignments(t *testing.T, ss store.Store)
|
|||||||
|
|
||||||
// testMaterializedPublicChannels tests edge cases involving the triggers and stored procedures
|
// testMaterializedPublicChannels tests edge cases involving the triggers and stored procedures
|
||||||
// that materialize the PublicChannels table.
|
// that materialize the PublicChannels table.
|
||||||
func testMaterializedPublicChannels(t *testing.T, ss store.Store, s SqlSupplier) {
|
func testMaterializedPublicChannels(t *testing.T, ss store.Store, s SqlStore) {
|
||||||
teamId := model.NewId()
|
teamId := model.NewId()
|
||||||
|
|
||||||
// o1 is a public channel on the team
|
// o1 is a public channel on the team
|
||||||
@@ -6491,7 +6491,7 @@ func testChannelStoreGetChannelMembersForExport(t *testing.T, ss store.Store) {
|
|||||||
assert.Equal(t, u1.Id, cmfe1.UserId)
|
assert.Equal(t, u1.Id, cmfe1.UserId)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testChannelStoreRemoveAllDeactivatedMembers(t *testing.T, ss store.Store, s SqlSupplier) {
|
func testChannelStoreRemoveAllDeactivatedMembers(t *testing.T, ss store.Store, s SqlStore) {
|
||||||
// Set up all the objects needed in the store.
|
// Set up all the objects needed in the store.
|
||||||
t1 := model.Team{}
|
t1 := model.Team{}
|
||||||
t1.DisplayName = "Name"
|
t1.DisplayName = "Name"
|
||||||
@@ -6574,7 +6574,7 @@ func testChannelStoreRemoveAllDeactivatedMembers(t *testing.T, ss store.Store, s
|
|||||||
s.GetMaster().Exec("TRUNCATE Channels")
|
s.GetMaster().Exec("TRUNCATE Channels")
|
||||||
}
|
}
|
||||||
|
|
||||||
func testChannelStoreExportAllDirectChannels(t *testing.T, ss store.Store, s SqlSupplier) {
|
func testChannelStoreExportAllDirectChannels(t *testing.T, ss store.Store, s SqlStore) {
|
||||||
teamId := model.NewId()
|
teamId := model.NewId()
|
||||||
|
|
||||||
o1 := model.Channel{}
|
o1 := model.Channel{}
|
||||||
@@ -6631,7 +6631,7 @@ func testChannelStoreExportAllDirectChannels(t *testing.T, ss store.Store, s Sql
|
|||||||
s.GetMaster().Exec("TRUNCATE Channels")
|
s.GetMaster().Exec("TRUNCATE Channels")
|
||||||
}
|
}
|
||||||
|
|
||||||
func testChannelStoreExportAllDirectChannelsExcludePrivateAndPublic(t *testing.T, ss store.Store, s SqlSupplier) {
|
func testChannelStoreExportAllDirectChannelsExcludePrivateAndPublic(t *testing.T, ss store.Store, s SqlStore) {
|
||||||
teamId := model.NewId()
|
teamId := model.NewId()
|
||||||
|
|
||||||
o1 := model.Channel{}
|
o1 := model.Channel{}
|
||||||
@@ -6693,7 +6693,7 @@ func testChannelStoreExportAllDirectChannelsExcludePrivateAndPublic(t *testing.T
|
|||||||
s.GetMaster().Exec("TRUNCATE Channels")
|
s.GetMaster().Exec("TRUNCATE Channels")
|
||||||
}
|
}
|
||||||
|
|
||||||
func testChannelStoreExportAllDirectChannelsDeletedChannel(t *testing.T, ss store.Store, s SqlSupplier) {
|
func testChannelStoreExportAllDirectChannelsDeletedChannel(t *testing.T, ss store.Store, s SqlStore) {
|
||||||
teamId := model.NewId()
|
teamId := model.NewId()
|
||||||
|
|
||||||
o1 := model.Channel{}
|
o1 := model.Channel{}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import (
|
|||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestChannelStoreCategories(t *testing.T, ss store.Store, s SqlSupplier) {
|
func TestChannelStoreCategories(t *testing.T, ss store.Store, s SqlStore) {
|
||||||
t.Run("CreateInitialSidebarCategories", func(t *testing.T) { testCreateInitialSidebarCategories(t, ss) })
|
t.Run("CreateInitialSidebarCategories", func(t *testing.T) { testCreateInitialSidebarCategories(t, ss) })
|
||||||
t.Run("CreateSidebarCategory", func(t *testing.T) { testCreateSidebarCategory(t, ss) })
|
t.Run("CreateSidebarCategory", func(t *testing.T) { testCreateSidebarCategory(t, ss) })
|
||||||
t.Run("GetSidebarCategory", func(t *testing.T) { testGetSidebarCategory(t, ss, s) })
|
t.Run("GetSidebarCategory", func(t *testing.T) { testGetSidebarCategory(t, ss, s) })
|
||||||
@@ -505,7 +505,7 @@ func testCreateSidebarCategory(t *testing.T, ss store.Store) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func testGetSidebarCategory(t *testing.T, ss store.Store, s SqlSupplier) {
|
func testGetSidebarCategory(t *testing.T, ss store.Store, s SqlStore) {
|
||||||
t.Run("should return a custom category with its Channels field set", func(t *testing.T) {
|
t.Run("should return a custom category with its Channels field set", func(t *testing.T) {
|
||||||
userId := model.NewId()
|
userId := model.NewId()
|
||||||
teamId := model.NewId()
|
teamId := model.NewId()
|
||||||
@@ -867,7 +867,7 @@ func testGetSidebarCategories(t *testing.T, ss store.Store) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func testUpdateSidebarCategories(t *testing.T, ss store.Store, s SqlSupplier) {
|
func testUpdateSidebarCategories(t *testing.T, ss store.Store, s SqlStore) {
|
||||||
t.Run("ensure the query to update SidebarCategories hasn't been polluted by UpdateSidebarCategoryOrder", func(t *testing.T) {
|
t.Run("ensure the query to update SidebarCategories hasn't been polluted by UpdateSidebarCategoryOrder", func(t *testing.T) {
|
||||||
userId := model.NewId()
|
userId := model.NewId()
|
||||||
teamId := model.NewId()
|
teamId := model.NewId()
|
||||||
@@ -1648,7 +1648,7 @@ func testUpdateSidebarCategories(t *testing.T, ss store.Store, s SqlSupplier) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func testDeleteSidebarCategory(t *testing.T, ss store.Store, s SqlSupplier) {
|
func testDeleteSidebarCategory(t *testing.T, ss store.Store, s SqlStore) {
|
||||||
setupInitialSidebarCategories := func(t *testing.T, ss store.Store) (string, string) {
|
setupInitialSidebarCategories := func(t *testing.T, ss store.Store) (string, string) {
|
||||||
userId := model.NewId()
|
userId := model.NewId()
|
||||||
teamId := model.NewId()
|
teamId := model.NewId()
|
||||||
|
|||||||
@@ -9,13 +9,13 @@ import (
|
|||||||
mock "github.com/stretchr/testify/mock"
|
mock "github.com/stretchr/testify/mock"
|
||||||
)
|
)
|
||||||
|
|
||||||
// SqlSupplier is an autogenerated mock type for the SqlSupplier type
|
// SqlStore is an autogenerated mock type for the SqlStore type
|
||||||
type SqlSupplier struct {
|
type SqlStore struct {
|
||||||
mock.Mock
|
mock.Mock
|
||||||
}
|
}
|
||||||
|
|
||||||
// DriverName provides a mock function with given fields:
|
// DriverName provides a mock function with given fields:
|
||||||
func (_m *SqlSupplier) DriverName() string {
|
func (_m *SqlStore) DriverName() string {
|
||||||
ret := _m.Called()
|
ret := _m.Called()
|
||||||
|
|
||||||
var r0 string
|
var r0 string
|
||||||
@@ -29,7 +29,7 @@ func (_m *SqlSupplier) DriverName() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetMaster provides a mock function with given fields:
|
// GetMaster provides a mock function with given fields:
|
||||||
func (_m *SqlSupplier) GetMaster() *gorp.DbMap {
|
func (_m *SqlStore) GetMaster() *gorp.DbMap {
|
||||||
ret := _m.Called()
|
ret := _m.Called()
|
||||||
|
|
||||||
var r0 *gorp.DbMap
|
var r0 *gorp.DbMap
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestPluginStore(t *testing.T, ss store.Store, s SqlSupplier) {
|
func TestPluginStore(t *testing.T, ss store.Store, s SqlStore) {
|
||||||
t.Run("SaveOrUpdate", func(t *testing.T) { testPluginSaveOrUpdate(t, ss, s) })
|
t.Run("SaveOrUpdate", func(t *testing.T) { testPluginSaveOrUpdate(t, ss, s) })
|
||||||
t.Run("CompareAndSet", func(t *testing.T) { testPluginCompareAndSet(t, ss, s) })
|
t.Run("CompareAndSet", func(t *testing.T) { testPluginCompareAndSet(t, ss, s) })
|
||||||
t.Run("CompareAndDelete", func(t *testing.T) { testPluginCompareAndDelete(t, ss, s) })
|
t.Run("CompareAndDelete", func(t *testing.T) { testPluginCompareAndDelete(t, ss, s) })
|
||||||
@@ -63,7 +63,7 @@ func setupKVs(t *testing.T, ss store.Store) (string, func()) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func doTestPluginSaveOrUpdate(t *testing.T, ss store.Store, s SqlSupplier, doer func(kv *model.PluginKeyValue) (*model.PluginKeyValue, error)) {
|
func doTestPluginSaveOrUpdate(t *testing.T, ss store.Store, s SqlStore, doer func(kv *model.PluginKeyValue) (*model.PluginKeyValue, error)) {
|
||||||
t.Run("invalid kv", func(t *testing.T) {
|
t.Run("invalid kv", func(t *testing.T) {
|
||||||
_, tearDown := setupKVs(t, ss)
|
_, tearDown := setupKVs(t, ss)
|
||||||
defer tearDown()
|
defer tearDown()
|
||||||
@@ -219,7 +219,7 @@ func doTestPluginSaveOrUpdate(t *testing.T, ss store.Store, s SqlSupplier, doer
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func testPluginSaveOrUpdate(t *testing.T, ss store.Store, s SqlSupplier) {
|
func testPluginSaveOrUpdate(t *testing.T, ss store.Store, s SqlStore) {
|
||||||
doTestPluginSaveOrUpdate(t, ss, s, func(kv *model.PluginKeyValue) (*model.PluginKeyValue, error) {
|
doTestPluginSaveOrUpdate(t, ss, s, func(kv *model.PluginKeyValue) (*model.PluginKeyValue, error) {
|
||||||
return ss.Plugin().SaveOrUpdate(kv)
|
return ss.Plugin().SaveOrUpdate(kv)
|
||||||
})
|
})
|
||||||
@@ -227,7 +227,7 @@ func testPluginSaveOrUpdate(t *testing.T, ss store.Store, s SqlSupplier) {
|
|||||||
|
|
||||||
// doTestPluginCompareAndSet exercises the CompareAndSet functionality, but abstracts the actual
|
// doTestPluginCompareAndSet exercises the CompareAndSet functionality, but abstracts the actual
|
||||||
// call to same to allow reuse with SetWithOptions
|
// call to same to allow reuse with SetWithOptions
|
||||||
func doTestPluginCompareAndSet(t *testing.T, ss store.Store, s SqlSupplier, compareAndSet func(kv *model.PluginKeyValue, oldValue []byte) (bool, error)) {
|
func doTestPluginCompareAndSet(t *testing.T, ss store.Store, s SqlStore, compareAndSet func(kv *model.PluginKeyValue, oldValue []byte) (bool, error)) {
|
||||||
t.Run("invalid kv", func(t *testing.T) {
|
t.Run("invalid kv", func(t *testing.T) {
|
||||||
_, tearDown := setupKVs(t, ss)
|
_, tearDown := setupKVs(t, ss)
|
||||||
defer tearDown()
|
defer tearDown()
|
||||||
@@ -524,13 +524,13 @@ func doTestPluginCompareAndSet(t *testing.T, ss store.Store, s SqlSupplier, comp
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func testPluginCompareAndSet(t *testing.T, ss store.Store, s SqlSupplier) {
|
func testPluginCompareAndSet(t *testing.T, ss store.Store, s SqlStore) {
|
||||||
doTestPluginCompareAndSet(t, ss, s, func(kv *model.PluginKeyValue, oldValue []byte) (bool, error) {
|
doTestPluginCompareAndSet(t, ss, s, func(kv *model.PluginKeyValue, oldValue []byte) (bool, error) {
|
||||||
return ss.Plugin().CompareAndSet(kv, oldValue)
|
return ss.Plugin().CompareAndSet(kv, oldValue)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func testPluginCompareAndDelete(t *testing.T, ss store.Store, s SqlSupplier) {
|
func testPluginCompareAndDelete(t *testing.T, ss store.Store, s SqlStore) {
|
||||||
t.Run("invalid kv", func(t *testing.T) {
|
t.Run("invalid kv", func(t *testing.T) {
|
||||||
_, tearDown := setupKVs(t, ss)
|
_, tearDown := setupKVs(t, ss)
|
||||||
defer tearDown()
|
defer tearDown()
|
||||||
@@ -660,7 +660,7 @@ func testPluginCompareAndDelete(t *testing.T, ss store.Store, s SqlSupplier) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func testPluginSetWithOptions(t *testing.T, ss store.Store, s SqlSupplier) {
|
func testPluginSetWithOptions(t *testing.T, ss store.Store, s SqlStore) {
|
||||||
t.Run("invalid options", func(t *testing.T) {
|
t.Run("invalid options", func(t *testing.T) {
|
||||||
_, tearDown := setupKVs(t, ss)
|
_, tearDown := setupKVs(t, ss)
|
||||||
defer tearDown()
|
defer tearDown()
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import (
|
|||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestPostStore(t *testing.T, ss store.Store, s SqlSupplier) {
|
func TestPostStore(t *testing.T, ss store.Store, s SqlStore) {
|
||||||
t.Run("SaveMultiple", func(t *testing.T) { testPostStoreSaveMultiple(t, ss) })
|
t.Run("SaveMultiple", func(t *testing.T) { testPostStoreSaveMultiple(t, ss) })
|
||||||
t.Run("Save", func(t *testing.T) { testPostStoreSave(t, ss) })
|
t.Run("Save", func(t *testing.T) { testPostStoreSave(t, ss) })
|
||||||
t.Run("SaveAndUpdateChannelMsgCounts", func(t *testing.T) { testPostStoreSaveChannelMsgCounts(t, ss) })
|
t.Run("SaveAndUpdateChannelMsgCounts", func(t *testing.T) { testPostStoreSaveChannelMsgCounts(t, ss) })
|
||||||
@@ -1691,7 +1691,7 @@ func testPostCountsByDay(t *testing.T, ss store.Store) {
|
|||||||
assert.Equal(t, int64(6), r2)
|
assert.Equal(t, int64(6), r2)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testPostStoreGetFlaggedPostsForTeam(t *testing.T, ss store.Store, s SqlSupplier) {
|
func testPostStoreGetFlaggedPostsForTeam(t *testing.T, ss store.Store, s SqlStore) {
|
||||||
c1 := &model.Channel{}
|
c1 := &model.Channel{}
|
||||||
c1.TeamId = model.NewId()
|
c1.TeamId = model.NewId()
|
||||||
c1.DisplayName = "Channel1"
|
c1.DisplayName = "Channel1"
|
||||||
@@ -2609,7 +2609,7 @@ func testPostStoreGetRepliesForExport(t *testing.T, ss store.Store) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func testPostStoreGetDirectPostParentsForExportAfter(t *testing.T, ss store.Store, s SqlSupplier) {
|
func testPostStoreGetDirectPostParentsForExportAfter(t *testing.T, ss store.Store, s SqlStore) {
|
||||||
teamId := model.NewId()
|
teamId := model.NewId()
|
||||||
|
|
||||||
o1 := model.Channel{}
|
o1 := model.Channel{}
|
||||||
@@ -2663,7 +2663,7 @@ func testPostStoreGetDirectPostParentsForExportAfter(t *testing.T, ss store.Stor
|
|||||||
s.GetMaster().Exec("TRUNCATE Channels")
|
s.GetMaster().Exec("TRUNCATE Channels")
|
||||||
}
|
}
|
||||||
|
|
||||||
func testPostStoreGetDirectPostParentsForExportAfterDeleted(t *testing.T, ss store.Store, s SqlSupplier) {
|
func testPostStoreGetDirectPostParentsForExportAfterDeleted(t *testing.T, ss store.Store, s SqlStore) {
|
||||||
teamId := model.NewId()
|
teamId := model.NewId()
|
||||||
|
|
||||||
o1 := model.Channel{}
|
o1 := model.Channel{}
|
||||||
@@ -2729,7 +2729,7 @@ func testPostStoreGetDirectPostParentsForExportAfterDeleted(t *testing.T, ss sto
|
|||||||
s.GetMaster().Exec("TRUNCATE Channels")
|
s.GetMaster().Exec("TRUNCATE Channels")
|
||||||
}
|
}
|
||||||
|
|
||||||
func testPostStoreGetDirectPostParentsForExportAfterBatched(t *testing.T, ss store.Store, s SqlSupplier) {
|
func testPostStoreGetDirectPostParentsForExportAfterBatched(t *testing.T, ss store.Store, s SqlStore) {
|
||||||
teamId := model.NewId()
|
teamId := model.NewId()
|
||||||
|
|
||||||
o1 := model.Channel{}
|
o1 := model.Channel{}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import (
|
|||||||
"github.com/mattermost/mattermost-server/v5/store"
|
"github.com/mattermost/mattermost-server/v5/store"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestRoleStore(t *testing.T, ss store.Store, s SqlSupplier) {
|
func TestRoleStore(t *testing.T, ss store.Store, s SqlStore) {
|
||||||
t.Run("Save", func(t *testing.T) { testRoleStoreSave(t, ss) })
|
t.Run("Save", func(t *testing.T) { testRoleStoreSave(t, ss) })
|
||||||
t.Run("Get", func(t *testing.T) { testRoleStoreGet(t, ss) })
|
t.Run("Get", func(t *testing.T) { testRoleStoreGet(t, ss) })
|
||||||
t.Run("GetAll", func(t *testing.T) { testRoleStoreGetAll(t, ss) })
|
t.Run("GetAll", func(t *testing.T) { testRoleStoreGetAll(t, ss) })
|
||||||
@@ -516,7 +516,7 @@ func testRoleStoreLowerScopedChannelSchemeRoles(t *testing.T, ss store.Store) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func testRoleStoreChannelHigherScopedPermissionsBlankTeamSchemeChannelGuest(t *testing.T, ss store.Store, s SqlSupplier) {
|
func testRoleStoreChannelHigherScopedPermissionsBlankTeamSchemeChannelGuest(t *testing.T, ss store.Store, s SqlStore) {
|
||||||
teamScheme := &model.Scheme{
|
teamScheme := &model.Scheme{
|
||||||
DisplayName: model.NewId(),
|
DisplayName: model.NewId(),
|
||||||
Name: model.NewId(),
|
Name: model.NewId(),
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import (
|
|||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestThreadStore(t *testing.T, ss store.Store, s SqlSupplier) {
|
func TestThreadStore(t *testing.T, ss store.Store, s SqlStore) {
|
||||||
t.Run("ThreadStorePopulation", func(t *testing.T) { testThreadStorePopulation(t, ss) })
|
t.Run("ThreadStorePopulation", func(t *testing.T) { testThreadStorePopulation(t, ss) })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,12 +21,12 @@ const (
|
|||||||
MONTH_MILLISECONDS = 31 * DAY_MILLISECONDS
|
MONTH_MILLISECONDS = 31 * DAY_MILLISECONDS
|
||||||
)
|
)
|
||||||
|
|
||||||
func cleanupStatusStore(t *testing.T, s SqlSupplier) {
|
func cleanupStatusStore(t *testing.T, s SqlStore) {
|
||||||
_, execerr := s.GetMaster().ExecNoTimeout(` DELETE FROM Status `)
|
_, execerr := s.GetMaster().ExecNoTimeout(` DELETE FROM Status `)
|
||||||
require.Nil(t, execerr)
|
require.Nil(t, execerr)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestUserStore(t *testing.T, ss store.Store, s SqlSupplier) {
|
func TestUserStore(t *testing.T, ss store.Store, s SqlStore) {
|
||||||
users, err := ss.User().GetAll()
|
users, err := ss.User().GetAll()
|
||||||
require.Nil(t, err, "failed cleaning up test users")
|
require.Nil(t, err, "failed cleaning up test users")
|
||||||
|
|
||||||
@@ -957,7 +957,7 @@ func testUserStoreGetProfilesInChannel(t *testing.T, ss store.Store) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func testUserStoreGetProfilesInChannelByStatus(t *testing.T, ss store.Store, s SqlSupplier) {
|
func testUserStoreGetProfilesInChannelByStatus(t *testing.T, ss store.Store, s SqlStore) {
|
||||||
|
|
||||||
cleanupStatusStore(t, s)
|
cleanupStatusStore(t, s)
|
||||||
|
|
||||||
@@ -2317,7 +2317,7 @@ func testUserStoreUpdateMfaActive(t *testing.T, ss store.Store) {
|
|||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testUserStoreGetRecentlyActiveUsersForTeam(t *testing.T, ss store.Store, s SqlSupplier) {
|
func testUserStoreGetRecentlyActiveUsersForTeam(t *testing.T, ss store.Store, s SqlStore) {
|
||||||
|
|
||||||
cleanupStatusStore(t, s)
|
cleanupStatusStore(t, s)
|
||||||
|
|
||||||
@@ -3823,7 +3823,7 @@ func testCount(t *testing.T, ss store.Store) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func testUserStoreAnalyticsActiveCount(t *testing.T, ss store.Store, s SqlSupplier) {
|
func testUserStoreAnalyticsActiveCount(t *testing.T, ss store.Store, s SqlStore) {
|
||||||
|
|
||||||
cleanupStatusStore(t, s)
|
cleanupStatusStore(t, s)
|
||||||
|
|
||||||
@@ -3908,7 +3908,7 @@ func testUserStoreAnalyticsActiveCount(t *testing.T, ss store.Store, s SqlSuppli
|
|||||||
assert.Equal(t, int64(4), count)
|
assert.Equal(t, int64(4), count)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testUserStoreAnalyticsActiveCountForPeriod(t *testing.T, ss store.Store, s SqlSupplier) {
|
func testUserStoreAnalyticsActiveCountForPeriod(t *testing.T, ss store.Store, s SqlStore) {
|
||||||
|
|
||||||
cleanupStatusStore(t, s)
|
cleanupStatusStore(t, s)
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ type MainHelper struct {
|
|||||||
Settings *model.SqlSettings
|
Settings *model.SqlSettings
|
||||||
Store store.Store
|
Store store.Store
|
||||||
SearchEngine *searchengine.Broker
|
SearchEngine *searchengine.Broker
|
||||||
SQLSupplier *sqlstore.SqlSupplier
|
SQLStore *sqlstore.SqlStore
|
||||||
ClusterInterface *FakeClusterInterface
|
ClusterInterface *FakeClusterInterface
|
||||||
|
|
||||||
status int
|
status int
|
||||||
@@ -109,9 +109,9 @@ func (h *MainHelper) setupStore() {
|
|||||||
|
|
||||||
h.SearchEngine = searchengine.NewBroker(config, nil)
|
h.SearchEngine = searchengine.NewBroker(config, nil)
|
||||||
h.ClusterInterface = &FakeClusterInterface{}
|
h.ClusterInterface = &FakeClusterInterface{}
|
||||||
h.SQLSupplier = sqlstore.NewSqlSupplier(*h.Settings, nil)
|
h.SQLStore = sqlstore.New(*h.Settings, nil)
|
||||||
h.Store = searchlayer.NewSearchLayer(&TestStore{
|
h.Store = searchlayer.NewSearchLayer(&TestStore{
|
||||||
h.SQLSupplier,
|
h.SQLStore,
|
||||||
}, h.SearchEngine, config)
|
}, h.SearchEngine, config)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,7 +151,7 @@ func (h *MainHelper) PreloadMigrations() {
|
|||||||
panic(fmt.Errorf("cannot read file: %v", err))
|
panic(fmt.Errorf("cannot read file: %v", err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
handle := h.SQLSupplier.GetMaster()
|
handle := h.SQLStore.GetMaster()
|
||||||
_, err = handle.Exec(string(buf))
|
_, err = handle.Exec(string(buf))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
mlog.Error("Error preloading migrations. Check if you have &multiStatements=true in your DSN if you are using MySQL. Or perhaps the schema changed? If yes, then update the warmup files accordingly.")
|
mlog.Error("Error preloading migrations. Check if you have &multiStatements=true in your DSN if you are using MySQL. Or perhaps the schema changed? If yes, then update the warmup files accordingly.")
|
||||||
@@ -160,8 +160,8 @@ func (h *MainHelper) PreloadMigrations() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *MainHelper) Close() error {
|
func (h *MainHelper) Close() error {
|
||||||
if h.SQLSupplier != nil {
|
if h.SQLStore != nil {
|
||||||
h.SQLSupplier.Close()
|
h.SQLStore.Close()
|
||||||
}
|
}
|
||||||
if h.Settings != nil {
|
if h.Settings != nil {
|
||||||
storetest.CleanupSqlSettings(h.Settings)
|
storetest.CleanupSqlSettings(h.Settings)
|
||||||
@@ -195,12 +195,12 @@ func (h *MainHelper) GetStore() store.Store {
|
|||||||
return h.Store
|
return h.Store
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *MainHelper) GetSQLSupplier() *sqlstore.SqlSupplier {
|
func (h *MainHelper) GetSQLStore() *sqlstore.SqlStore {
|
||||||
if h.SQLSupplier == nil {
|
if h.SQLStore == nil {
|
||||||
panic("MainHelper not initialized with sql supplier.")
|
panic("MainHelper not initialized with sql store.")
|
||||||
}
|
}
|
||||||
|
|
||||||
return h.SQLSupplier
|
return h.SQLStore
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *MainHelper) GetClusterInterface() *FakeClusterInterface {
|
func (h *MainHelper) GetClusterInterface() *FakeClusterInterface {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user