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
@@ -24,7 +24,7 @@ func makeBotWithUser(t *testing.T, ss store.Store, bot *model.Bot) (*model.Bot,
|
||||
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("GetAll", func(t *testing.T) { testBotStoreGetAll(t, ss, s) })
|
||||
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) })
|
||||
}
|
||||
|
||||
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{
|
||||
Username: "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()
|
||||
OwnerId2 := model.NewId()
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ import (
|
||||
"github.com/mattermost/mattermost-server/v5/utils"
|
||||
)
|
||||
|
||||
type SqlSupplier interface {
|
||||
type SqlStore interface {
|
||||
GetMaster() *gorp.DbMap
|
||||
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)
|
||||
|
||||
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))
|
||||
}
|
||||
|
||||
func testChannelStoreSaveDirectChannel(t *testing.T, ss store.Store, s SqlSupplier) {
|
||||
func testChannelStoreSaveDirectChannel(t *testing.T, ss store.Store, s SqlStore) {
|
||||
teamId := model.NewId()
|
||||
|
||||
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")
|
||||
}
|
||||
|
||||
func testChannelStoreGet(t *testing.T, ss store.Store, s SqlSupplier) {
|
||||
func testChannelStoreGet(t *testing.T, ss store.Store, s SqlStore) {
|
||||
o1 := model.Channel{}
|
||||
o1.TeamId = model.NewId()
|
||||
o1.DisplayName = "Name"
|
||||
@@ -3256,7 +3256,7 @@ func testChannelStoreGetChannels(t *testing.T, ss store.Store) {
|
||||
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)
|
||||
|
||||
t1 := model.Team{}
|
||||
@@ -4949,7 +4949,7 @@ func (s ByChannelDisplayName) Less(i, j int) bool {
|
||||
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()
|
||||
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()
|
||||
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
|
||||
// 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()
|
||||
|
||||
// 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)
|
||||
}
|
||||
|
||||
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.
|
||||
t1 := model.Team{}
|
||||
t1.DisplayName = "Name"
|
||||
@@ -6574,7 +6574,7 @@ func testChannelStoreRemoveAllDeactivatedMembers(t *testing.T, ss store.Store, s
|
||||
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()
|
||||
|
||||
o1 := model.Channel{}
|
||||
@@ -6631,7 +6631,7 @@ func testChannelStoreExportAllDirectChannels(t *testing.T, ss store.Store, s Sql
|
||||
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()
|
||||
|
||||
o1 := model.Channel{}
|
||||
@@ -6693,7 +6693,7 @@ func testChannelStoreExportAllDirectChannelsExcludePrivateAndPublic(t *testing.T
|
||||
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()
|
||||
|
||||
o1 := model.Channel{}
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
"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("CreateSidebarCategory", func(t *testing.T) { testCreateSidebarCategory(t, ss) })
|
||||
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) {
|
||||
userId := 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) {
|
||||
userId := 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) {
|
||||
userId := model.NewId()
|
||||
teamId := model.NewId()
|
||||
|
||||
@@ -9,13 +9,13 @@ import (
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
||||
// SqlSupplier is an autogenerated mock type for the SqlSupplier type
|
||||
type SqlSupplier struct {
|
||||
// SqlStore is an autogenerated mock type for the SqlStore type
|
||||
type SqlStore struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
// DriverName provides a mock function with given fields:
|
||||
func (_m *SqlSupplier) DriverName() string {
|
||||
func (_m *SqlStore) DriverName() string {
|
||||
ret := _m.Called()
|
||||
|
||||
var r0 string
|
||||
@@ -29,7 +29,7 @@ func (_m *SqlSupplier) DriverName() string {
|
||||
}
|
||||
|
||||
// GetMaster provides a mock function with given fields:
|
||||
func (_m *SqlSupplier) GetMaster() *gorp.DbMap {
|
||||
func (_m *SqlStore) GetMaster() *gorp.DbMap {
|
||||
ret := _m.Called()
|
||||
|
||||
var r0 *gorp.DbMap
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
"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("CompareAndSet", func(t *testing.T) { testPluginCompareAndSet(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) {
|
||||
_, tearDown := setupKVs(t, ss)
|
||||
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) {
|
||||
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
|
||||
// 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) {
|
||||
_, tearDown := setupKVs(t, ss)
|
||||
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) {
|
||||
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) {
|
||||
_, tearDown := setupKVs(t, ss)
|
||||
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) {
|
||||
_, tearDown := setupKVs(t, ss)
|
||||
defer tearDown()
|
||||
|
||||
@@ -17,7 +17,7 @@ import (
|
||||
"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("Save", func(t *testing.T) { testPostStoreSave(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)
|
||||
}
|
||||
|
||||
func testPostStoreGetFlaggedPostsForTeam(t *testing.T, ss store.Store, s SqlSupplier) {
|
||||
func testPostStoreGetFlaggedPostsForTeam(t *testing.T, ss store.Store, s SqlStore) {
|
||||
c1 := &model.Channel{}
|
||||
c1.TeamId = model.NewId()
|
||||
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()
|
||||
|
||||
o1 := model.Channel{}
|
||||
@@ -2663,7 +2663,7 @@ func testPostStoreGetDirectPostParentsForExportAfter(t *testing.T, ss store.Stor
|
||||
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()
|
||||
|
||||
o1 := model.Channel{}
|
||||
@@ -2729,7 +2729,7 @@ func testPostStoreGetDirectPostParentsForExportAfterDeleted(t *testing.T, ss sto
|
||||
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()
|
||||
|
||||
o1 := model.Channel{}
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
"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("Get", func(t *testing.T) { testRoleStoreGet(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{
|
||||
DisplayName: model.NewId(),
|
||||
Name: model.NewId(),
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
"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) })
|
||||
}
|
||||
|
||||
|
||||
@@ -21,12 +21,12 @@ const (
|
||||
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 `)
|
||||
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()
|
||||
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)
|
||||
|
||||
@@ -2317,7 +2317,7 @@ func testUserStoreUpdateMfaActive(t *testing.T, ss store.Store) {
|
||||
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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -3908,7 +3908,7 @@ func testUserStoreAnalyticsActiveCount(t *testing.T, ss store.Store, s SqlSuppli
|
||||
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)
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user