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
@@ -12,13 +12,13 @@ import (
|
||||
)
|
||||
|
||||
type SqlAuditStore struct {
|
||||
*SqlSupplier
|
||||
*SqlStore
|
||||
}
|
||||
|
||||
func newSqlAuditStore(sqlSupplier *SqlSupplier) store.AuditStore {
|
||||
s := &SqlAuditStore{sqlSupplier}
|
||||
func newSqlAuditStore(sqlStore *SqlStore) store.AuditStore {
|
||||
s := &SqlAuditStore{sqlStore}
|
||||
|
||||
for _, db := range sqlSupplier.GetAllConns() {
|
||||
for _, db := range sqlStore.GetAllConns() {
|
||||
table := db.AddTableWithName(model.Audit{}, "Audits").SetKeys(false, "Id")
|
||||
table.ColMap("Id").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
|
||||
// for a bot matches the primary key value for corresponding User record.
|
||||
type SqlBotStore struct {
|
||||
*SqlSupplier
|
||||
*SqlStore
|
||||
metrics einterfaces.MetricsInterface
|
||||
}
|
||||
|
||||
// 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{
|
||||
SqlSupplier: sqlSupplier,
|
||||
metrics: metrics,
|
||||
SqlStore: sqlStore,
|
||||
metrics: metrics,
|
||||
}
|
||||
|
||||
for _, db := range sqlSupplier.GetAllConns() {
|
||||
for _, db := range sqlStore.GetAllConns() {
|
||||
table := db.AddTableWithName(bot{}, "Bots").SetKeys(false, "UserId")
|
||||
table.ColMap("UserId").SetMaxSize(26)
|
||||
table.ColMap("Description").SetMaxSize(1024)
|
||||
|
||||
@@ -10,5 +10,5 @@ import (
|
||||
)
|
||||
|
||||
func TestBotStore(t *testing.T) {
|
||||
StoreTestWithSqlSupplier(t, storetest.TestBotStore)
|
||||
StoreTestWithSqlStore(t, storetest.TestBotStore)
|
||||
}
|
||||
|
||||
@@ -17,15 +17,15 @@ import (
|
||||
)
|
||||
|
||||
type SqlChannelMemberHistoryStore struct {
|
||||
*SqlSupplier
|
||||
*SqlStore
|
||||
}
|
||||
|
||||
func newSqlChannelMemberHistoryStore(sqlSupplier *SqlSupplier) store.ChannelMemberHistoryStore {
|
||||
func newSqlChannelMemberHistoryStore(sqlStore *SqlStore) store.ChannelMemberHistoryStore {
|
||||
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.ColMap("ChannelId").SetMaxSize(26)
|
||||
table.ColMap("UserId").SetMaxSize(26)
|
||||
|
||||
@@ -33,7 +33,7 @@ const (
|
||||
)
|
||||
|
||||
type SqlChannelStore struct {
|
||||
*SqlSupplier
|
||||
*SqlStore
|
||||
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{
|
||||
SqlSupplier: sqlSupplier,
|
||||
metrics: metrics,
|
||||
SqlStore: sqlStore,
|
||||
metrics: metrics,
|
||||
}
|
||||
|
||||
for _, db := range sqlSupplier.GetAllConns() {
|
||||
for _, db := range sqlStore.GetAllConns() {
|
||||
table := db.AddTableWithName(model.Channel{}, "Channels").SetKeys(false, "Id")
|
||||
table.ColMap("Id").SetMaxSize(26)
|
||||
table.ColMap("TeamId").SetMaxSize(26)
|
||||
|
||||
@@ -10,5 +10,5 @@ import (
|
||||
)
|
||||
|
||||
func TestChannelStoreCategories(t *testing.T) {
|
||||
StoreTestWithSqlSupplier(t, storetest.TestChannelStoreCategories)
|
||||
StoreTestWithSqlStore(t, storetest.TestChannelStoreCategories)
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ import (
|
||||
)
|
||||
|
||||
func TestChannelStore(t *testing.T) {
|
||||
StoreTestWithSqlSupplier(t, storetest.TestChannelStore)
|
||||
StoreTestWithSqlStore(t, storetest.TestChannelStore)
|
||||
}
|
||||
|
||||
func TestSearchChannelStore(t *testing.T) {
|
||||
@@ -28,7 +28,7 @@ func TestChannelSearchQuerySQLInjection(t *testing.T) {
|
||||
for _, st := range storeTypes {
|
||||
t.Run(st.Name, func(t *testing.T) {
|
||||
s := &SqlChannelStore{
|
||||
SqlSupplier: st.SqlSupplier,
|
||||
SqlStore: st.SqlStore,
|
||||
}
|
||||
|
||||
opts := store.ChannelSearchOpts{}
|
||||
|
||||
@@ -12,13 +12,13 @@ import (
|
||||
)
|
||||
|
||||
type sqlClusterDiscoveryStore struct {
|
||||
*SqlSupplier
|
||||
*SqlStore
|
||||
}
|
||||
|
||||
func newSqlClusterDiscoveryStore(sqlSupplier *SqlSupplier) store.ClusterDiscoveryStore {
|
||||
s := &sqlClusterDiscoveryStore{sqlSupplier}
|
||||
func newSqlClusterDiscoveryStore(sqlStore *SqlStore) store.ClusterDiscoveryStore {
|
||||
s := &sqlClusterDiscoveryStore{sqlStore}
|
||||
|
||||
for _, db := range sqlSupplier.GetAllConns() {
|
||||
for _, db := range sqlStore.GetAllConns() {
|
||||
table := db.AddTableWithName(model.ClusterDiscovery{}, "ClusterDiscovery").SetKeys(false, "Id")
|
||||
table.ColMap("Id").SetMaxSize(26)
|
||||
table.ColMap("Type").SetMaxSize(64)
|
||||
|
||||
@@ -14,18 +14,18 @@ import (
|
||||
)
|
||||
|
||||
type SqlCommandStore struct {
|
||||
*SqlSupplier
|
||||
*SqlStore
|
||||
|
||||
commandsQuery sq.SelectBuilder
|
||||
}
|
||||
|
||||
func newSqlCommandStore(sqlSupplier *SqlSupplier) store.CommandStore {
|
||||
s := &SqlCommandStore{SqlSupplier: sqlSupplier}
|
||||
func newSqlCommandStore(sqlStore *SqlStore) store.CommandStore {
|
||||
s := &SqlCommandStore{SqlStore: sqlStore}
|
||||
|
||||
s.commandsQuery = s.getQueryBuilder().
|
||||
Select("*").
|
||||
From("Commands")
|
||||
for _, db := range sqlSupplier.GetAllConns() {
|
||||
for _, db := range sqlStore.GetAllConns() {
|
||||
tableo := db.AddTableWithName(model.Command{}, "Commands").SetKeys(false, "Id")
|
||||
tableo.ColMap("Id").SetMaxSize(26)
|
||||
tableo.ColMap("Token").SetMaxSize(26)
|
||||
|
||||
@@ -16,13 +16,13 @@ import (
|
||||
)
|
||||
|
||||
type SqlCommandWebhookStore struct {
|
||||
*SqlSupplier
|
||||
*SqlStore
|
||||
}
|
||||
|
||||
func newSqlCommandWebhookStore(sqlSupplier *SqlSupplier) store.CommandWebhookStore {
|
||||
s := &SqlCommandWebhookStore{sqlSupplier}
|
||||
func newSqlCommandWebhookStore(sqlStore *SqlStore) store.CommandWebhookStore {
|
||||
s := &SqlCommandWebhookStore{sqlStore}
|
||||
|
||||
for _, db := range sqlSupplier.GetAllConns() {
|
||||
for _, db := range sqlStore.GetAllConns() {
|
||||
tablec := db.AddTableWithName(model.CommandWebhook{}, "CommandWebhooks").SetKeys(false, "Id")
|
||||
tablec.ColMap("Id").SetMaxSize(26)
|
||||
tablec.ColMap("CommandId").SetMaxSize(26)
|
||||
|
||||
@@ -14,13 +14,13 @@ import (
|
||||
)
|
||||
|
||||
type SqlComplianceStore struct {
|
||||
*SqlSupplier
|
||||
*SqlStore
|
||||
}
|
||||
|
||||
func newSqlComplianceStore(sqlSupplier *SqlSupplier) store.ComplianceStore {
|
||||
s := &SqlComplianceStore{sqlSupplier}
|
||||
func newSqlComplianceStore(sqlStore *SqlStore) store.ComplianceStore {
|
||||
s := &SqlComplianceStore{sqlStore}
|
||||
|
||||
for _, db := range sqlSupplier.GetAllConns() {
|
||||
for _, db := range sqlStore.GetAllConns() {
|
||||
table := db.AddTableWithName(model.Compliance{}, "Compliances").SetKeys(false, "Id")
|
||||
table.ColMap("Id").SetMaxSize(26)
|
||||
table.ColMap("UserId").SetMaxSize(26)
|
||||
|
||||
@@ -15,17 +15,17 @@ import (
|
||||
)
|
||||
|
||||
type SqlEmojiStore struct {
|
||||
*SqlSupplier
|
||||
*SqlStore
|
||||
metrics einterfaces.MetricsInterface
|
||||
}
|
||||
|
||||
func newSqlEmojiStore(sqlSupplier *SqlSupplier, metrics einterfaces.MetricsInterface) store.EmojiStore {
|
||||
func newSqlEmojiStore(sqlStore *SqlStore, metrics einterfaces.MetricsInterface) store.EmojiStore {
|
||||
s := &SqlEmojiStore{
|
||||
SqlSupplier: sqlSupplier,
|
||||
metrics: metrics,
|
||||
SqlStore: sqlStore,
|
||||
metrics: metrics,
|
||||
}
|
||||
|
||||
for _, db := range sqlSupplier.GetAllConns() {
|
||||
for _, db := range sqlStore.GetAllConns() {
|
||||
table := db.AddTableWithName(model.Emoji{}, "Emoji").SetKeys(false, "Id")
|
||||
table.ColMap("Id").SetMaxSize(26)
|
||||
table.ColMap("CreatorId").SetMaxSize(26)
|
||||
|
||||
@@ -16,7 +16,7 @@ import (
|
||||
)
|
||||
|
||||
type SqlFileInfoStore struct {
|
||||
*SqlSupplier
|
||||
*SqlStore
|
||||
metrics einterfaces.MetricsInterface
|
||||
queryFields []string
|
||||
}
|
||||
@@ -24,10 +24,10 @@ type SqlFileInfoStore struct {
|
||||
func (fs SqlFileInfoStore) ClearCaches() {
|
||||
}
|
||||
|
||||
func newSqlFileInfoStore(sqlSupplier *SqlSupplier, metrics einterfaces.MetricsInterface) store.FileInfoStore {
|
||||
func newSqlFileInfoStore(sqlStore *SqlStore, metrics einterfaces.MetricsInterface) store.FileInfoStore {
|
||||
s := &SqlFileInfoStore{
|
||||
SqlSupplier: sqlSupplier,
|
||||
metrics: metrics,
|
||||
SqlStore: sqlStore,
|
||||
metrics: metrics,
|
||||
}
|
||||
|
||||
s.queryFields = []string{
|
||||
@@ -51,7 +51,7 @@ func newSqlFileInfoStore(sqlSupplier *SqlSupplier, metrics einterfaces.MetricsIn
|
||||
"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.ColMap("Id").SetMaxSize(26)
|
||||
table.ColMap("CreatorId").SetMaxSize(26)
|
||||
|
||||
@@ -48,12 +48,12 @@ type groupChannelJoin struct {
|
||||
}
|
||||
|
||||
type SqlGroupStore struct {
|
||||
*SqlSupplier
|
||||
*SqlStore
|
||||
}
|
||||
|
||||
func newSqlGroupStore(sqlSupplier *SqlSupplier) store.GroupStore {
|
||||
s := &SqlGroupStore{SqlSupplier: sqlSupplier}
|
||||
for _, db := range sqlSupplier.GetAllConns() {
|
||||
func newSqlGroupStore(sqlStore *SqlStore) store.GroupStore {
|
||||
s := &SqlGroupStore{SqlStore: sqlStore}
|
||||
for _, db := range sqlStore.GetAllConns() {
|
||||
groups := db.AddTableWithName(model.Group{}, "UserGroups").SetKeys(false, "Id")
|
||||
groups.ColMap("Id").SetMaxSize(26)
|
||||
groups.ColMap("Name").SetMaxSize(model.GroupNameMaxLength).SetUnique(true)
|
||||
|
||||
@@ -20,7 +20,7 @@ type relationalCheckConfig struct {
|
||||
filter interface{}
|
||||
}
|
||||
|
||||
func getOrphanedRecords(ss *SqlSupplier, cfg relationalCheckConfig) ([]model.OrphanedRecord, error) {
|
||||
func getOrphanedRecords(ss *SqlStore, cfg relationalCheckConfig) ([]model.OrphanedRecord, error) {
|
||||
var records []model.OrphanedRecord
|
||||
|
||||
sub := ss.getQueryBuilder().
|
||||
@@ -59,7 +59,7 @@ func getOrphanedRecords(ss *SqlSupplier, cfg relationalCheckConfig) ([]model.Orp
|
||||
return records, err
|
||||
}
|
||||
|
||||
func checkParentChildIntegrity(ss *SqlSupplier, config relationalCheckConfig) model.IntegrityCheckResult {
|
||||
func checkParentChildIntegrity(ss *SqlStore, config relationalCheckConfig) model.IntegrityCheckResult {
|
||||
var result model.IntegrityCheckResult
|
||||
var data model.RelationalIntegrityCheckData
|
||||
|
||||
@@ -78,7 +78,7 @@ func checkParentChildIntegrity(ss *SqlSupplier, config relationalCheckConfig) mo
|
||||
return result
|
||||
}
|
||||
|
||||
func checkChannelsCommandWebhooksIntegrity(ss *SqlSupplier) model.IntegrityCheckResult {
|
||||
func checkChannelsCommandWebhooksIntegrity(ss *SqlStore) model.IntegrityCheckResult {
|
||||
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
||||
parentName: "Channels",
|
||||
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{
|
||||
parentName: "Channels",
|
||||
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{
|
||||
parentName: "Channels",
|
||||
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{
|
||||
parentName: "Channels",
|
||||
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{
|
||||
parentName: "Channels",
|
||||
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{
|
||||
parentName: "Channels",
|
||||
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{
|
||||
parentName: "Commands",
|
||||
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{
|
||||
parentName: "Posts",
|
||||
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{
|
||||
parentName: "Posts",
|
||||
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{
|
||||
parentName: "Posts",
|
||||
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{
|
||||
parentName: "Posts",
|
||||
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{
|
||||
parentName: "Schemes",
|
||||
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{
|
||||
parentName: "Schemes",
|
||||
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{
|
||||
parentName: "Sessions",
|
||||
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{
|
||||
parentName: "Teams",
|
||||
parentIdAttr: "TeamId",
|
||||
@@ -232,7 +232,7 @@ func checkTeamsChannelsIntegrity(ss *SqlSupplier) model.IntegrityCheckResult {
|
||||
return res1
|
||||
}
|
||||
|
||||
func checkTeamsCommandsIntegrity(ss *SqlSupplier) model.IntegrityCheckResult {
|
||||
func checkTeamsCommandsIntegrity(ss *SqlStore) model.IntegrityCheckResult {
|
||||
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
||||
parentName: "Teams",
|
||||
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{
|
||||
parentName: "Teams",
|
||||
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{
|
||||
parentName: "Teams",
|
||||
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{
|
||||
parentName: "Teams",
|
||||
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{
|
||||
parentName: "Users",
|
||||
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{
|
||||
parentName: "Users",
|
||||
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{
|
||||
parentName: "Users",
|
||||
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{
|
||||
parentName: "Users",
|
||||
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{
|
||||
parentName: "Users",
|
||||
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{
|
||||
parentName: "Users",
|
||||
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{
|
||||
parentName: "Users",
|
||||
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{
|
||||
parentName: "Users",
|
||||
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{
|
||||
parentName: "Users",
|
||||
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{
|
||||
parentName: "Users",
|
||||
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{
|
||||
parentName: "Users",
|
||||
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{
|
||||
parentName: "Users",
|
||||
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{
|
||||
parentName: "Users",
|
||||
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{
|
||||
parentName: "Users",
|
||||
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{
|
||||
parentName: "Users",
|
||||
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{
|
||||
parentName: "Users",
|
||||
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{
|
||||
parentName: "Users",
|
||||
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{
|
||||
parentName: "Users",
|
||||
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{
|
||||
parentName: "Users",
|
||||
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{
|
||||
parentName: "Users",
|
||||
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{
|
||||
parentName: "Users",
|
||||
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 <- checkChannelsChannelMemberHistoryIntegrity(ss)
|
||||
results <- checkChannelsChannelMembersIntegrity(ss)
|
||||
@@ -468,27 +468,27 @@ func checkChannelsIntegrity(ss *SqlSupplier, results chan<- model.IntegrityCheck
|
||||
results <- checkChannelsPostsIntegrity(ss)
|
||||
}
|
||||
|
||||
func checkCommandsIntegrity(ss *SqlSupplier, results chan<- model.IntegrityCheckResult) {
|
||||
func checkCommandsIntegrity(ss *SqlStore, results chan<- model.IntegrityCheckResult) {
|
||||
results <- checkCommandsCommandWebhooksIntegrity(ss)
|
||||
}
|
||||
|
||||
func checkPostsIntegrity(ss *SqlSupplier, results chan<- model.IntegrityCheckResult) {
|
||||
func checkPostsIntegrity(ss *SqlStore, results chan<- model.IntegrityCheckResult) {
|
||||
results <- checkPostsFileInfoIntegrity(ss)
|
||||
results <- checkPostsPostsParentIdIntegrity(ss)
|
||||
results <- checkPostsPostsRootIdIntegrity(ss)
|
||||
results <- checkPostsReactionsIntegrity(ss)
|
||||
}
|
||||
|
||||
func checkSchemesIntegrity(ss *SqlSupplier, results chan<- model.IntegrityCheckResult) {
|
||||
func checkSchemesIntegrity(ss *SqlStore, results chan<- model.IntegrityCheckResult) {
|
||||
results <- checkSchemesChannelsIntegrity(ss)
|
||||
results <- checkSchemesTeamsIntegrity(ss)
|
||||
}
|
||||
|
||||
func checkSessionsIntegrity(ss *SqlSupplier, results chan<- model.IntegrityCheckResult) {
|
||||
func checkSessionsIntegrity(ss *SqlStore, results chan<- model.IntegrityCheckResult) {
|
||||
results <- checkSessionsAuditsIntegrity(ss)
|
||||
}
|
||||
|
||||
func checkTeamsIntegrity(ss *SqlSupplier, results chan<- model.IntegrityCheckResult) {
|
||||
func checkTeamsIntegrity(ss *SqlStore, results chan<- model.IntegrityCheckResult) {
|
||||
results <- checkTeamsChannelsIntegrity(ss)
|
||||
results <- checkTeamsCommandsIntegrity(ss)
|
||||
results <- checkTeamsIncomingWebhooksIntegrity(ss)
|
||||
@@ -496,7 +496,7 @@ func checkTeamsIntegrity(ss *SqlSupplier, results chan<- model.IntegrityCheckRes
|
||||
results <- checkTeamsTeamMembersIntegrity(ss)
|
||||
}
|
||||
|
||||
func checkUsersIntegrity(ss *SqlSupplier, results chan<- model.IntegrityCheckResult) {
|
||||
func checkUsersIntegrity(ss *SqlStore, results chan<- model.IntegrityCheckResult) {
|
||||
results <- checkUsersAuditsIntegrity(ss)
|
||||
results <- checkUsersCommandWebhooksIntegrity(ss)
|
||||
results <- checkUsersChannelMemberHistoryIntegrity(ss)
|
||||
@@ -520,7 +520,7 @@ func checkUsersIntegrity(ss *SqlSupplier, results chan<- model.IntegrityCheckRes
|
||||
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...")
|
||||
checkChannelsIntegrity(ss, results)
|
||||
checkCommandsIntegrity(ss, results)
|
||||
|
||||
@@ -362,7 +362,7 @@ func TestCheckIntegrity(t *testing.T) {
|
||||
|
||||
func TestCheckParentChildIntegrity(t *testing.T) {
|
||||
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) {
|
||||
config := relationalCheckConfig{
|
||||
parentName: "NotValid",
|
||||
@@ -370,7 +370,7 @@ func TestCheckParentChildIntegrity(t *testing.T) {
|
||||
childName: "NotValid",
|
||||
childIdAttr: "NotValid",
|
||||
}
|
||||
result := checkParentChildIntegrity(supplier, config)
|
||||
result := checkParentChildIntegrity(store, config)
|
||||
require.NotNil(t, result.Err)
|
||||
require.Empty(t, result.Data)
|
||||
})
|
||||
@@ -379,11 +379,11 @@ func TestCheckParentChildIntegrity(t *testing.T) {
|
||||
|
||||
func TestCheckChannelsCommandWebhooksIntegrity(t *testing.T) {
|
||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||
supplier := ss.(*SqlSupplier)
|
||||
dbmap := supplier.GetMaster()
|
||||
store := ss.(*SqlStore)
|
||||
dbmap := store.GetMaster()
|
||||
|
||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||
result := checkChannelsCommandWebhooksIntegrity(supplier)
|
||||
result := checkChannelsCommandWebhooksIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
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) {
|
||||
channelId := model.NewId()
|
||||
cwh := createCommandWebhook(ss, model.NewId(), model.NewId(), channelId)
|
||||
result := checkChannelsCommandWebhooksIntegrity(supplier)
|
||||
result := checkChannelsCommandWebhooksIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Len(t, data.Records, 1)
|
||||
@@ -407,11 +407,11 @@ func TestCheckChannelsCommandWebhooksIntegrity(t *testing.T) {
|
||||
|
||||
func TestCheckChannelsChannelMemberHistoryIntegrity(t *testing.T) {
|
||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||
supplier := ss.(*SqlSupplier)
|
||||
dbmap := supplier.GetMaster()
|
||||
store := ss.(*SqlStore)
|
||||
dbmap := store.GetMaster()
|
||||
|
||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||
result := checkChannelsChannelMemberHistoryIntegrity(supplier)
|
||||
result := checkChannelsChannelMemberHistoryIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Empty(t, data.Records)
|
||||
@@ -422,7 +422,7 @@ func TestCheckChannelsChannelMemberHistoryIntegrity(t *testing.T) {
|
||||
user := createUser(ss)
|
||||
cmh := createChannelMemberHistory(ss, channel.Id, user.Id)
|
||||
dbmap.Delete(channel)
|
||||
result := checkChannelsChannelMemberHistoryIntegrity(supplier)
|
||||
result := checkChannelsChannelMemberHistoryIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Len(t, data.Records, 1)
|
||||
@@ -437,11 +437,11 @@ func TestCheckChannelsChannelMemberHistoryIntegrity(t *testing.T) {
|
||||
|
||||
func TestCheckChannelsChannelMembersIntegrity(t *testing.T) {
|
||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||
supplier := ss.(*SqlSupplier)
|
||||
dbmap := supplier.GetMaster()
|
||||
store := ss.(*SqlStore)
|
||||
dbmap := store.GetMaster()
|
||||
|
||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||
result := checkChannelsChannelMembersIntegrity(supplier)
|
||||
result := checkChannelsChannelMembersIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Empty(t, data.Records)
|
||||
@@ -451,7 +451,7 @@ func TestCheckChannelsChannelMembersIntegrity(t *testing.T) {
|
||||
channel := createChannel(ss, model.NewId(), model.NewId())
|
||||
member := createChannelMemberWithChannelId(ss, channel.Id)
|
||||
dbmap.Delete(channel)
|
||||
result := checkChannelsChannelMembersIntegrity(supplier)
|
||||
result := checkChannelsChannelMembersIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Len(t, data.Records, 1)
|
||||
@@ -465,11 +465,11 @@ func TestCheckChannelsChannelMembersIntegrity(t *testing.T) {
|
||||
|
||||
func TestCheckChannelsIncomingWebhooksIntegrity(t *testing.T) {
|
||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||
supplier := ss.(*SqlSupplier)
|
||||
dbmap := supplier.GetMaster()
|
||||
store := ss.(*SqlStore)
|
||||
dbmap := store.GetMaster()
|
||||
|
||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||
result := checkChannelsIncomingWebhooksIntegrity(supplier)
|
||||
result := checkChannelsIncomingWebhooksIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
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) {
|
||||
channelId := model.NewId()
|
||||
wh := createIncomingWebhook(ss, model.NewId(), channelId, model.NewId())
|
||||
result := checkChannelsIncomingWebhooksIntegrity(supplier)
|
||||
result := checkChannelsIncomingWebhooksIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Len(t, data.Records, 1)
|
||||
@@ -493,11 +493,11 @@ func TestCheckChannelsIncomingWebhooksIntegrity(t *testing.T) {
|
||||
|
||||
func TestCheckChannelsOutgoingWebhooksIntegrity(t *testing.T) {
|
||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||
supplier := ss.(*SqlSupplier)
|
||||
dbmap := supplier.GetMaster()
|
||||
store := ss.(*SqlStore)
|
||||
dbmap := store.GetMaster()
|
||||
|
||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||
result := checkChannelsOutgoingWebhooksIntegrity(supplier)
|
||||
result := checkChannelsOutgoingWebhooksIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Empty(t, data.Records)
|
||||
@@ -508,7 +508,7 @@ func TestCheckChannelsOutgoingWebhooksIntegrity(t *testing.T) {
|
||||
channelId := channel.Id
|
||||
wh := createOutgoingWebhook(ss, model.NewId(), channelId, model.NewId())
|
||||
dbmap.Delete(channel)
|
||||
result := checkChannelsOutgoingWebhooksIntegrity(supplier)
|
||||
result := checkChannelsOutgoingWebhooksIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Len(t, data.Records, 1)
|
||||
@@ -523,11 +523,11 @@ func TestCheckChannelsOutgoingWebhooksIntegrity(t *testing.T) {
|
||||
|
||||
func TestCheckChannelsPostsIntegrity(t *testing.T) {
|
||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||
supplier := ss.(*SqlSupplier)
|
||||
dbmap := supplier.GetMaster()
|
||||
store := ss.(*SqlStore)
|
||||
dbmap := store.GetMaster()
|
||||
|
||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||
result := checkChannelsPostsIntegrity(supplier)
|
||||
result := checkChannelsPostsIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
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) {
|
||||
post := createPostWithChannelId(ss, model.NewId())
|
||||
result := checkChannelsPostsIntegrity(supplier)
|
||||
result := checkChannelsPostsIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Len(t, data.Records, 1)
|
||||
@@ -550,11 +550,11 @@ func TestCheckChannelsPostsIntegrity(t *testing.T) {
|
||||
|
||||
func TestCheckCommandsCommandWebhooksIntegrity(t *testing.T) {
|
||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||
supplier := ss.(*SqlSupplier)
|
||||
dbmap := supplier.GetMaster()
|
||||
store := ss.(*SqlStore)
|
||||
dbmap := store.GetMaster()
|
||||
|
||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||
result := checkCommandsCommandWebhooksIntegrity(supplier)
|
||||
result := checkCommandsCommandWebhooksIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
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) {
|
||||
commandId := model.NewId()
|
||||
cwh := createCommandWebhook(ss, commandId, model.NewId(), model.NewId())
|
||||
result := checkCommandsCommandWebhooksIntegrity(supplier)
|
||||
result := checkCommandsCommandWebhooksIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Len(t, data.Records, 1)
|
||||
@@ -578,11 +578,11 @@ func TestCheckCommandsCommandWebhooksIntegrity(t *testing.T) {
|
||||
|
||||
func TestCheckPostsFileInfoIntegrity(t *testing.T) {
|
||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||
supplier := ss.(*SqlSupplier)
|
||||
dbmap := supplier.GetMaster()
|
||||
store := ss.(*SqlStore)
|
||||
dbmap := store.GetMaster()
|
||||
|
||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||
result := checkPostsFileInfoIntegrity(supplier)
|
||||
result := checkPostsFileInfoIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
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) {
|
||||
postId := model.NewId()
|
||||
info := createFileInfo(ss, postId, model.NewId())
|
||||
result := checkPostsFileInfoIntegrity(supplier)
|
||||
result := checkPostsFileInfoIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Len(t, data.Records, 1)
|
||||
@@ -606,11 +606,11 @@ func TestCheckPostsFileInfoIntegrity(t *testing.T) {
|
||||
|
||||
func TestCheckPostsPostsParentIdIntegrity(t *testing.T) {
|
||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||
supplier := ss.(*SqlSupplier)
|
||||
dbmap := supplier.GetMaster()
|
||||
store := ss.(*SqlStore)
|
||||
dbmap := store.GetMaster()
|
||||
|
||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||
result := checkPostsPostsParentIdIntegrity(supplier)
|
||||
result := checkPostsPostsParentIdIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Empty(t, data.Records)
|
||||
@@ -620,7 +620,7 @@ func TestCheckPostsPostsParentIdIntegrity(t *testing.T) {
|
||||
root := createPost(ss, model.NewId(), model.NewId(), "", "")
|
||||
parent := createPost(ss, model.NewId(), model.NewId(), root.Id, root.Id)
|
||||
post := createPost(ss, model.NewId(), model.NewId(), root.Id, parent.Id)
|
||||
result := checkPostsPostsParentIdIntegrity(supplier)
|
||||
result := checkPostsPostsParentIdIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Empty(t, data.Records)
|
||||
@@ -635,7 +635,7 @@ func TestCheckPostsPostsParentIdIntegrity(t *testing.T) {
|
||||
parentId := parent.Id
|
||||
post := createPost(ss, model.NewId(), model.NewId(), root.Id, parent.Id)
|
||||
dbmap.Delete(parent)
|
||||
result := checkPostsPostsParentIdIntegrity(supplier)
|
||||
result := checkPostsPostsParentIdIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Len(t, data.Records, 1)
|
||||
@@ -651,11 +651,11 @@ func TestCheckPostsPostsParentIdIntegrity(t *testing.T) {
|
||||
|
||||
func TestCheckPostsPostsRootIdIntegrity(t *testing.T) {
|
||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||
supplier := ss.(*SqlSupplier)
|
||||
dbmap := supplier.GetMaster()
|
||||
store := ss.(*SqlStore)
|
||||
dbmap := store.GetMaster()
|
||||
|
||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||
result := checkPostsPostsRootIdIntegrity(supplier)
|
||||
result := checkPostsPostsRootIdIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Empty(t, data.Records)
|
||||
@@ -666,7 +666,7 @@ func TestCheckPostsPostsRootIdIntegrity(t *testing.T) {
|
||||
rootId := root.Id
|
||||
post := createPost(ss, model.NewId(), model.NewId(), root.Id, root.Id)
|
||||
dbmap.Delete(root)
|
||||
result := checkPostsPostsRootIdIntegrity(supplier)
|
||||
result := checkPostsPostsRootIdIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Len(t, data.Records, 1)
|
||||
@@ -681,11 +681,11 @@ func TestCheckPostsPostsRootIdIntegrity(t *testing.T) {
|
||||
|
||||
func TestCheckPostsReactionsIntegrity(t *testing.T) {
|
||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||
supplier := ss.(*SqlSupplier)
|
||||
dbmap := supplier.GetMaster()
|
||||
store := ss.(*SqlStore)
|
||||
dbmap := store.GetMaster()
|
||||
|
||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||
result := checkPostsReactionsIntegrity(supplier)
|
||||
result := checkPostsReactionsIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
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) {
|
||||
postId := model.NewId()
|
||||
reaction := createReaction(ss, model.NewId(), postId)
|
||||
result := checkPostsReactionsIntegrity(supplier)
|
||||
result := checkPostsReactionsIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Len(t, data.Records, 1)
|
||||
@@ -708,11 +708,11 @@ func TestCheckPostsReactionsIntegrity(t *testing.T) {
|
||||
|
||||
func TestCheckSchemesChannelsIntegrity(t *testing.T) {
|
||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||
supplier := ss.(*SqlSupplier)
|
||||
dbmap := supplier.GetMaster()
|
||||
store := ss.(*SqlStore)
|
||||
dbmap := store.GetMaster()
|
||||
|
||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||
result := checkSchemesChannelsIntegrity(supplier)
|
||||
result := checkSchemesChannelsIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Empty(t, data.Records)
|
||||
@@ -724,7 +724,7 @@ func TestCheckSchemesChannelsIntegrity(t *testing.T) {
|
||||
schemeId := scheme.Id
|
||||
channel := createChannelWithSchemeId(ss, &schemeId)
|
||||
dbmap.Delete(scheme)
|
||||
result := checkSchemesChannelsIntegrity(supplier)
|
||||
result := checkSchemesChannelsIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Len(t, data.Records, 1)
|
||||
@@ -739,11 +739,11 @@ func TestCheckSchemesChannelsIntegrity(t *testing.T) {
|
||||
|
||||
func TestCheckSchemesTeamsIntegrity(t *testing.T) {
|
||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||
supplier := ss.(*SqlSupplier)
|
||||
dbmap := supplier.GetMaster()
|
||||
store := ss.(*SqlStore)
|
||||
dbmap := store.GetMaster()
|
||||
|
||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||
result := checkSchemesTeamsIntegrity(supplier)
|
||||
result := checkSchemesTeamsIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Empty(t, data.Records)
|
||||
@@ -755,7 +755,7 @@ func TestCheckSchemesTeamsIntegrity(t *testing.T) {
|
||||
schemeId := scheme.Id
|
||||
team := createTeamWithSchemeId(ss, &schemeId)
|
||||
dbmap.Delete(scheme)
|
||||
result := checkSchemesTeamsIntegrity(supplier)
|
||||
result := checkSchemesTeamsIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Len(t, data.Records, 1)
|
||||
@@ -770,11 +770,11 @@ func TestCheckSchemesTeamsIntegrity(t *testing.T) {
|
||||
|
||||
func TestCheckSessionsAuditsIntegrity(t *testing.T) {
|
||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||
supplier := ss.(*SqlSupplier)
|
||||
dbmap := supplier.GetMaster()
|
||||
store := ss.(*SqlStore)
|
||||
dbmap := store.GetMaster()
|
||||
|
||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||
result := checkSessionsAuditsIntegrity(supplier)
|
||||
result := checkSessionsAuditsIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Empty(t, data.Records)
|
||||
@@ -786,7 +786,7 @@ func TestCheckSessionsAuditsIntegrity(t *testing.T) {
|
||||
sessionId := session.Id
|
||||
audit := createAudit(ss, userId, sessionId)
|
||||
dbmap.Delete(session)
|
||||
result := checkSessionsAuditsIntegrity(supplier)
|
||||
result := checkSessionsAuditsIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Len(t, data.Records, 1)
|
||||
@@ -801,11 +801,11 @@ func TestCheckSessionsAuditsIntegrity(t *testing.T) {
|
||||
|
||||
func TestCheckTeamsChannelsIntegrity(t *testing.T) {
|
||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||
supplier := ss.(*SqlSupplier)
|
||||
dbmap := supplier.GetMaster()
|
||||
store := ss.(*SqlStore)
|
||||
dbmap := store.GetMaster()
|
||||
|
||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||
result := checkTeamsChannelsIntegrity(supplier)
|
||||
result := checkTeamsChannelsIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
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) {
|
||||
channel := createChannelWithTeamId(ss, model.NewId())
|
||||
result := checkTeamsChannelsIntegrity(supplier)
|
||||
result := checkTeamsChannelsIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Len(t, data.Records, 1)
|
||||
@@ -831,7 +831,7 @@ func TestCheckTeamsChannelsIntegrity(t *testing.T) {
|
||||
direct, err := ss.Channel().CreateDirectChannel(userA, userB)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, direct)
|
||||
result := checkTeamsChannelsIntegrity(supplier)
|
||||
result := checkTeamsChannelsIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Len(t, data.Records, 1)
|
||||
@@ -854,7 +854,7 @@ func TestCheckTeamsChannelsIntegrity(t *testing.T) {
|
||||
require.NotNil(t, direct)
|
||||
_, err = dbmap.Exec(`UPDATE Channels SET TeamId = 'test' WHERE Id = '` + direct.Id + `'`)
|
||||
require.NoError(t, err)
|
||||
result := checkTeamsChannelsIntegrity(supplier)
|
||||
result := checkTeamsChannelsIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Len(t, data.Records, 2)
|
||||
@@ -877,11 +877,11 @@ func TestCheckTeamsChannelsIntegrity(t *testing.T) {
|
||||
|
||||
func TestCheckTeamsCommandsIntegrity(t *testing.T) {
|
||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||
supplier := ss.(*SqlSupplier)
|
||||
dbmap := supplier.GetMaster()
|
||||
store := ss.(*SqlStore)
|
||||
dbmap := store.GetMaster()
|
||||
|
||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||
result := checkTeamsCommandsIntegrity(supplier)
|
||||
result := checkTeamsCommandsIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
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) {
|
||||
teamId := model.NewId()
|
||||
cmd := createCommand(ss, model.NewId(), teamId)
|
||||
result := checkTeamsCommandsIntegrity(supplier)
|
||||
result := checkTeamsCommandsIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Len(t, data.Records, 1)
|
||||
@@ -905,11 +905,11 @@ func TestCheckTeamsCommandsIntegrity(t *testing.T) {
|
||||
|
||||
func TestCheckTeamsIncomingWebhooksIntegrity(t *testing.T) {
|
||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||
supplier := ss.(*SqlSupplier)
|
||||
dbmap := supplier.GetMaster()
|
||||
store := ss.(*SqlStore)
|
||||
dbmap := store.GetMaster()
|
||||
|
||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||
result := checkTeamsIncomingWebhooksIntegrity(supplier)
|
||||
result := checkTeamsIncomingWebhooksIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
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) {
|
||||
teamId := model.NewId()
|
||||
wh := createIncomingWebhook(ss, model.NewId(), model.NewId(), teamId)
|
||||
result := checkTeamsIncomingWebhooksIntegrity(supplier)
|
||||
result := checkTeamsIncomingWebhooksIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Len(t, data.Records, 1)
|
||||
@@ -933,11 +933,11 @@ func TestCheckTeamsIncomingWebhooksIntegrity(t *testing.T) {
|
||||
|
||||
func TestCheckTeamsOutgoingWebhooksIntegrity(t *testing.T) {
|
||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||
supplier := ss.(*SqlSupplier)
|
||||
dbmap := supplier.GetMaster()
|
||||
store := ss.(*SqlStore)
|
||||
dbmap := store.GetMaster()
|
||||
|
||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||
result := checkTeamsOutgoingWebhooksIntegrity(supplier)
|
||||
result := checkTeamsOutgoingWebhooksIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
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) {
|
||||
teamId := model.NewId()
|
||||
wh := createOutgoingWebhook(ss, model.NewId(), model.NewId(), teamId)
|
||||
result := checkTeamsOutgoingWebhooksIntegrity(supplier)
|
||||
result := checkTeamsOutgoingWebhooksIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Len(t, data.Records, 1)
|
||||
@@ -961,11 +961,11 @@ func TestCheckTeamsOutgoingWebhooksIntegrity(t *testing.T) {
|
||||
|
||||
func TestCheckTeamsTeamMembersIntegrity(t *testing.T) {
|
||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||
supplier := ss.(*SqlSupplier)
|
||||
dbmap := supplier.GetMaster()
|
||||
store := ss.(*SqlStore)
|
||||
dbmap := store.GetMaster()
|
||||
|
||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||
result := checkTeamsTeamMembersIntegrity(supplier)
|
||||
result := checkTeamsTeamMembersIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Empty(t, data.Records)
|
||||
@@ -975,7 +975,7 @@ func TestCheckTeamsTeamMembersIntegrity(t *testing.T) {
|
||||
team := createTeam(ss, model.NewId())
|
||||
member := createTeamMember(ss, team.Id, model.NewId())
|
||||
dbmap.Delete(team)
|
||||
result := checkTeamsTeamMembersIntegrity(supplier)
|
||||
result := checkTeamsTeamMembersIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Len(t, data.Records, 1)
|
||||
@@ -989,11 +989,11 @@ func TestCheckTeamsTeamMembersIntegrity(t *testing.T) {
|
||||
|
||||
func TestCheckUsersAuditsIntegrity(t *testing.T) {
|
||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||
supplier := ss.(*SqlSupplier)
|
||||
dbmap := supplier.GetMaster()
|
||||
store := ss.(*SqlStore)
|
||||
dbmap := store.GetMaster()
|
||||
|
||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||
result := checkUsersAuditsIntegrity(supplier)
|
||||
result := checkUsersAuditsIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Empty(t, data.Records)
|
||||
@@ -1004,7 +1004,7 @@ func TestCheckUsersAuditsIntegrity(t *testing.T) {
|
||||
userId := user.Id
|
||||
audit := createAudit(ss, userId, model.NewId())
|
||||
dbmap.Delete(user)
|
||||
result := checkUsersAuditsIntegrity(supplier)
|
||||
result := checkUsersAuditsIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Len(t, data.Records, 1)
|
||||
@@ -1019,11 +1019,11 @@ func TestCheckUsersAuditsIntegrity(t *testing.T) {
|
||||
|
||||
func TestCheckUsersCommandWebhooksIntegrity(t *testing.T) {
|
||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||
supplier := ss.(*SqlSupplier)
|
||||
dbmap := supplier.GetMaster()
|
||||
store := ss.(*SqlStore)
|
||||
dbmap := store.GetMaster()
|
||||
|
||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||
result := checkUsersCommandWebhooksIntegrity(supplier)
|
||||
result := checkUsersCommandWebhooksIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
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) {
|
||||
userId := model.NewId()
|
||||
cwh := createCommandWebhook(ss, model.NewId(), userId, model.NewId())
|
||||
result := checkUsersCommandWebhooksIntegrity(supplier)
|
||||
result := checkUsersCommandWebhooksIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Len(t, data.Records, 1)
|
||||
@@ -1047,11 +1047,11 @@ func TestCheckUsersCommandWebhooksIntegrity(t *testing.T) {
|
||||
|
||||
func TestCheckUsersChannelsIntegrity(t *testing.T) {
|
||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||
supplier := ss.(*SqlSupplier)
|
||||
dbmap := supplier.GetMaster()
|
||||
store := ss.(*SqlStore)
|
||||
dbmap := store.GetMaster()
|
||||
|
||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||
result := checkUsersChannelsIntegrity(supplier)
|
||||
result := checkUsersChannelsIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
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) {
|
||||
channel := createChannelWithCreatorId(ss, model.NewId())
|
||||
result := checkUsersChannelsIntegrity(supplier)
|
||||
result := checkUsersChannelsIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Len(t, data.Records, 1)
|
||||
@@ -1074,11 +1074,11 @@ func TestCheckUsersChannelsIntegrity(t *testing.T) {
|
||||
|
||||
func TestCheckUsersChannelMemberHistoryIntegrity(t *testing.T) {
|
||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||
supplier := ss.(*SqlSupplier)
|
||||
dbmap := supplier.GetMaster()
|
||||
store := ss.(*SqlStore)
|
||||
dbmap := store.GetMaster()
|
||||
|
||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||
result := checkUsersChannelMemberHistoryIntegrity(supplier)
|
||||
result := checkUsersChannelMemberHistoryIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Empty(t, data.Records)
|
||||
@@ -1089,7 +1089,7 @@ func TestCheckUsersChannelMemberHistoryIntegrity(t *testing.T) {
|
||||
channel := createChannel(ss, model.NewId(), model.NewId())
|
||||
cmh := createChannelMemberHistory(ss, channel.Id, user.Id)
|
||||
dbmap.Delete(user)
|
||||
result := checkUsersChannelMemberHistoryIntegrity(supplier)
|
||||
result := checkUsersChannelMemberHistoryIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Len(t, data.Records, 1)
|
||||
@@ -1104,11 +1104,11 @@ func TestCheckUsersChannelMemberHistoryIntegrity(t *testing.T) {
|
||||
|
||||
func TestCheckUsersChannelMembersIntegrity(t *testing.T) {
|
||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||
supplier := ss.(*SqlSupplier)
|
||||
dbmap := supplier.GetMaster()
|
||||
store := ss.(*SqlStore)
|
||||
dbmap := store.GetMaster()
|
||||
|
||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||
result := checkUsersChannelMembersIntegrity(supplier)
|
||||
result := checkUsersChannelMembersIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Empty(t, data.Records)
|
||||
@@ -1119,7 +1119,7 @@ func TestCheckUsersChannelMembersIntegrity(t *testing.T) {
|
||||
channel := createChannelWithCreatorId(ss, user.Id)
|
||||
member := createChannelMember(ss, channel.Id, user.Id)
|
||||
dbmap.Delete(user)
|
||||
result := checkUsersChannelMembersIntegrity(supplier)
|
||||
result := checkUsersChannelMembersIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Len(t, data.Records, 1)
|
||||
@@ -1134,11 +1134,11 @@ func TestCheckUsersChannelMembersIntegrity(t *testing.T) {
|
||||
|
||||
func TestCheckUsersCommandsIntegrity(t *testing.T) {
|
||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||
supplier := ss.(*SqlSupplier)
|
||||
dbmap := supplier.GetMaster()
|
||||
store := ss.(*SqlStore)
|
||||
dbmap := store.GetMaster()
|
||||
|
||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||
result := checkUsersCommandsIntegrity(supplier)
|
||||
result := checkUsersCommandsIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
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) {
|
||||
userId := model.NewId()
|
||||
cmd := createCommand(ss, userId, model.NewId())
|
||||
result := checkUsersCommandsIntegrity(supplier)
|
||||
result := checkUsersCommandsIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Len(t, data.Records, 1)
|
||||
@@ -1162,11 +1162,11 @@ func TestCheckUsersCommandsIntegrity(t *testing.T) {
|
||||
|
||||
func TestCheckUsersCompliancesIntegrity(t *testing.T) {
|
||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||
supplier := ss.(*SqlSupplier)
|
||||
dbmap := supplier.GetMaster()
|
||||
store := ss.(*SqlStore)
|
||||
dbmap := store.GetMaster()
|
||||
|
||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||
result := checkUsersCompliancesIntegrity(supplier)
|
||||
result := checkUsersCompliancesIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Empty(t, data.Records)
|
||||
@@ -1177,7 +1177,7 @@ func TestCheckUsersCompliancesIntegrity(t *testing.T) {
|
||||
userId := user.Id
|
||||
compliance := createCompliance(ss, userId)
|
||||
dbmap.Delete(user)
|
||||
result := checkUsersCompliancesIntegrity(supplier)
|
||||
result := checkUsersCompliancesIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Len(t, data.Records, 1)
|
||||
@@ -1192,11 +1192,11 @@ func TestCheckUsersCompliancesIntegrity(t *testing.T) {
|
||||
|
||||
func TestCheckUsersEmojiIntegrity(t *testing.T) {
|
||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||
supplier := ss.(*SqlSupplier)
|
||||
dbmap := supplier.GetMaster()
|
||||
store := ss.(*SqlStore)
|
||||
dbmap := store.GetMaster()
|
||||
|
||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||
result := checkUsersEmojiIntegrity(supplier)
|
||||
result := checkUsersEmojiIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Empty(t, data.Records)
|
||||
@@ -1207,7 +1207,7 @@ func TestCheckUsersEmojiIntegrity(t *testing.T) {
|
||||
userId := user.Id
|
||||
emoji := createEmoji(ss, userId)
|
||||
dbmap.Delete(user)
|
||||
result := checkUsersEmojiIntegrity(supplier)
|
||||
result := checkUsersEmojiIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Len(t, data.Records, 1)
|
||||
@@ -1222,11 +1222,11 @@ func TestCheckUsersEmojiIntegrity(t *testing.T) {
|
||||
|
||||
func TestCheckUsersFileInfoIntegrity(t *testing.T) {
|
||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||
supplier := ss.(*SqlSupplier)
|
||||
dbmap := supplier.GetMaster()
|
||||
store := ss.(*SqlStore)
|
||||
dbmap := store.GetMaster()
|
||||
|
||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||
result := checkUsersFileInfoIntegrity(supplier)
|
||||
result := checkUsersFileInfoIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Empty(t, data.Records)
|
||||
@@ -1237,7 +1237,7 @@ func TestCheckUsersFileInfoIntegrity(t *testing.T) {
|
||||
userId := user.Id
|
||||
info := createFileInfo(ss, model.NewId(), userId)
|
||||
dbmap.Delete(user)
|
||||
result := checkUsersFileInfoIntegrity(supplier)
|
||||
result := checkUsersFileInfoIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Len(t, data.Records, 1)
|
||||
@@ -1252,11 +1252,11 @@ func TestCheckUsersFileInfoIntegrity(t *testing.T) {
|
||||
|
||||
func TestCheckUsersIncomingWebhooksIntegrity(t *testing.T) {
|
||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||
supplier := ss.(*SqlSupplier)
|
||||
dbmap := supplier.GetMaster()
|
||||
store := ss.(*SqlStore)
|
||||
dbmap := store.GetMaster()
|
||||
|
||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||
result := checkUsersIncomingWebhooksIntegrity(supplier)
|
||||
result := checkUsersIncomingWebhooksIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
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) {
|
||||
userId := model.NewId()
|
||||
wh := createIncomingWebhook(ss, userId, model.NewId(), model.NewId())
|
||||
result := checkUsersIncomingWebhooksIntegrity(supplier)
|
||||
result := checkUsersIncomingWebhooksIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Len(t, data.Records, 1)
|
||||
@@ -1280,11 +1280,11 @@ func TestCheckUsersIncomingWebhooksIntegrity(t *testing.T) {
|
||||
|
||||
func TestCheckUsersOAuthAccessDataIntegrity(t *testing.T) {
|
||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||
supplier := ss.(*SqlSupplier)
|
||||
dbmap := supplier.GetMaster()
|
||||
store := ss.(*SqlStore)
|
||||
dbmap := store.GetMaster()
|
||||
|
||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||
result := checkUsersOAuthAccessDataIntegrity(supplier)
|
||||
result := checkUsersOAuthAccessDataIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Empty(t, data.Records)
|
||||
@@ -1295,7 +1295,7 @@ func TestCheckUsersOAuthAccessDataIntegrity(t *testing.T) {
|
||||
userId := user.Id
|
||||
ad := createOAuthAccessData(ss, userId)
|
||||
dbmap.Delete(user)
|
||||
result := checkUsersOAuthAccessDataIntegrity(supplier)
|
||||
result := checkUsersOAuthAccessDataIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Len(t, data.Records, 1)
|
||||
@@ -1310,11 +1310,11 @@ func TestCheckUsersOAuthAccessDataIntegrity(t *testing.T) {
|
||||
|
||||
func TestCheckUsersOAuthAppsIntegrity(t *testing.T) {
|
||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||
supplier := ss.(*SqlSupplier)
|
||||
dbmap := supplier.GetMaster()
|
||||
store := ss.(*SqlStore)
|
||||
dbmap := store.GetMaster()
|
||||
|
||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||
result := checkUsersOAuthAppsIntegrity(supplier)
|
||||
result := checkUsersOAuthAppsIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Empty(t, data.Records)
|
||||
@@ -1325,7 +1325,7 @@ func TestCheckUsersOAuthAppsIntegrity(t *testing.T) {
|
||||
userId := user.Id
|
||||
app := createOAuthApp(ss, userId)
|
||||
dbmap.Delete(user)
|
||||
result := checkUsersOAuthAppsIntegrity(supplier)
|
||||
result := checkUsersOAuthAppsIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Len(t, data.Records, 1)
|
||||
@@ -1340,11 +1340,11 @@ func TestCheckUsersOAuthAppsIntegrity(t *testing.T) {
|
||||
|
||||
func TestCheckUsersOAuthAuthDataIntegrity(t *testing.T) {
|
||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||
supplier := ss.(*SqlSupplier)
|
||||
dbmap := supplier.GetMaster()
|
||||
store := ss.(*SqlStore)
|
||||
dbmap := store.GetMaster()
|
||||
|
||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||
result := checkUsersOAuthAuthDataIntegrity(supplier)
|
||||
result := checkUsersOAuthAuthDataIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Empty(t, data.Records)
|
||||
@@ -1355,7 +1355,7 @@ func TestCheckUsersOAuthAuthDataIntegrity(t *testing.T) {
|
||||
userId := user.Id
|
||||
ad := createOAuthAuthData(ss, userId)
|
||||
dbmap.Delete(user)
|
||||
result := checkUsersOAuthAuthDataIntegrity(supplier)
|
||||
result := checkUsersOAuthAuthDataIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Len(t, data.Records, 1)
|
||||
@@ -1370,11 +1370,11 @@ func TestCheckUsersOAuthAuthDataIntegrity(t *testing.T) {
|
||||
|
||||
func TestCheckUsersOutgoingWebhooksIntegrity(t *testing.T) {
|
||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||
supplier := ss.(*SqlSupplier)
|
||||
dbmap := supplier.GetMaster()
|
||||
store := ss.(*SqlStore)
|
||||
dbmap := store.GetMaster()
|
||||
|
||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||
result := checkUsersOutgoingWebhooksIntegrity(supplier)
|
||||
result := checkUsersOutgoingWebhooksIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
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) {
|
||||
userId := model.NewId()
|
||||
wh := createOutgoingWebhook(ss, userId, model.NewId(), model.NewId())
|
||||
result := checkUsersOutgoingWebhooksIntegrity(supplier)
|
||||
result := checkUsersOutgoingWebhooksIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Len(t, data.Records, 1)
|
||||
@@ -1398,11 +1398,11 @@ func TestCheckUsersOutgoingWebhooksIntegrity(t *testing.T) {
|
||||
|
||||
func TestCheckUsersPostsIntegrity(t *testing.T) {
|
||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||
supplier := ss.(*SqlSupplier)
|
||||
dbmap := supplier.GetMaster()
|
||||
store := ss.(*SqlStore)
|
||||
dbmap := store.GetMaster()
|
||||
|
||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||
result := checkUsersPostsIntegrity(supplier)
|
||||
result := checkUsersPostsIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
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) {
|
||||
post := createPostWithUserId(ss, model.NewId())
|
||||
result := checkUsersPostsIntegrity(supplier)
|
||||
result := checkUsersPostsIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Len(t, data.Records, 1)
|
||||
@@ -1425,11 +1425,11 @@ func TestCheckUsersPostsIntegrity(t *testing.T) {
|
||||
|
||||
func TestCheckUsersPreferencesIntegrity(t *testing.T) {
|
||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||
supplier := ss.(*SqlSupplier)
|
||||
dbmap := supplier.GetMaster()
|
||||
store := ss.(*SqlStore)
|
||||
dbmap := store.GetMaster()
|
||||
|
||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||
result := checkUsersPreferencesIntegrity(supplier)
|
||||
result := checkUsersPreferencesIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Empty(t, data.Records)
|
||||
@@ -1441,7 +1441,7 @@ func TestCheckUsersPreferencesIntegrity(t *testing.T) {
|
||||
userId := user.Id
|
||||
preferences := createPreferences(ss, userId)
|
||||
require.NotNil(t, preferences)
|
||||
result := checkUsersPreferencesIntegrity(supplier)
|
||||
result := checkUsersPreferencesIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Empty(t, data.Records)
|
||||
@@ -1456,7 +1456,7 @@ func TestCheckUsersPreferencesIntegrity(t *testing.T) {
|
||||
preferences := createPreferences(ss, userId)
|
||||
require.NotNil(t, preferences)
|
||||
dbmap.Delete(user)
|
||||
result := checkUsersPreferencesIntegrity(supplier)
|
||||
result := checkUsersPreferencesIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Len(t, data.Records, 1)
|
||||
@@ -1471,11 +1471,11 @@ func TestCheckUsersPreferencesIntegrity(t *testing.T) {
|
||||
|
||||
func TestCheckUsersReactionsIntegrity(t *testing.T) {
|
||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||
supplier := ss.(*SqlSupplier)
|
||||
dbmap := supplier.GetMaster()
|
||||
store := ss.(*SqlStore)
|
||||
dbmap := store.GetMaster()
|
||||
|
||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||
result := checkUsersReactionsIntegrity(supplier)
|
||||
result := checkUsersReactionsIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Empty(t, data.Records)
|
||||
@@ -1486,7 +1486,7 @@ func TestCheckUsersReactionsIntegrity(t *testing.T) {
|
||||
userId := user.Id
|
||||
reaction := createReaction(ss, user.Id, model.NewId())
|
||||
dbmap.Delete(user)
|
||||
result := checkUsersReactionsIntegrity(supplier)
|
||||
result := checkUsersReactionsIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Len(t, data.Records, 1)
|
||||
@@ -1500,11 +1500,11 @@ func TestCheckUsersReactionsIntegrity(t *testing.T) {
|
||||
|
||||
func TestCheckUsersSessionsIntegrity(t *testing.T) {
|
||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||
supplier := ss.(*SqlSupplier)
|
||||
dbmap := supplier.GetMaster()
|
||||
store := ss.(*SqlStore)
|
||||
dbmap := store.GetMaster()
|
||||
|
||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||
result := checkUsersSessionsIntegrity(supplier)
|
||||
result := checkUsersSessionsIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
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) {
|
||||
userId := model.NewId()
|
||||
session := createSession(ss, userId)
|
||||
result := checkUsersSessionsIntegrity(supplier)
|
||||
result := checkUsersSessionsIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Len(t, data.Records, 1)
|
||||
@@ -1528,11 +1528,11 @@ func TestCheckUsersSessionsIntegrity(t *testing.T) {
|
||||
|
||||
func TestCheckUsersStatusIntegrity(t *testing.T) {
|
||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||
supplier := ss.(*SqlSupplier)
|
||||
dbmap := supplier.GetMaster()
|
||||
store := ss.(*SqlStore)
|
||||
dbmap := store.GetMaster()
|
||||
|
||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||
result := checkUsersStatusIntegrity(supplier)
|
||||
result := checkUsersStatusIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Empty(t, data.Records)
|
||||
@@ -1543,7 +1543,7 @@ func TestCheckUsersStatusIntegrity(t *testing.T) {
|
||||
userId := user.Id
|
||||
status := createStatus(ss, user.Id)
|
||||
dbmap.Delete(user)
|
||||
result := checkUsersStatusIntegrity(supplier)
|
||||
result := checkUsersStatusIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Len(t, data.Records, 1)
|
||||
@@ -1557,11 +1557,11 @@ func TestCheckUsersStatusIntegrity(t *testing.T) {
|
||||
|
||||
func TestCheckUsersTeamMembersIntegrity(t *testing.T) {
|
||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||
supplier := ss.(*SqlSupplier)
|
||||
dbmap := supplier.GetMaster()
|
||||
store := ss.(*SqlStore)
|
||||
dbmap := store.GetMaster()
|
||||
|
||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||
result := checkUsersTeamMembersIntegrity(supplier)
|
||||
result := checkUsersTeamMembersIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Empty(t, data.Records)
|
||||
@@ -1572,7 +1572,7 @@ func TestCheckUsersTeamMembersIntegrity(t *testing.T) {
|
||||
team := createTeam(ss, user.Id)
|
||||
member := createTeamMember(ss, team.Id, user.Id)
|
||||
dbmap.Delete(user)
|
||||
result := checkUsersTeamMembersIntegrity(supplier)
|
||||
result := checkUsersTeamMembersIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Len(t, data.Records, 1)
|
||||
@@ -1587,11 +1587,11 @@ func TestCheckUsersTeamMembersIntegrity(t *testing.T) {
|
||||
|
||||
func TestCheckUsersUserAccessTokensIntegrity(t *testing.T) {
|
||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||
supplier := ss.(*SqlSupplier)
|
||||
dbmap := supplier.GetMaster()
|
||||
store := ss.(*SqlStore)
|
||||
dbmap := store.GetMaster()
|
||||
|
||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
||||
result := checkUsersUserAccessTokensIntegrity(supplier)
|
||||
result := checkUsersUserAccessTokensIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Empty(t, data.Records)
|
||||
@@ -1602,7 +1602,7 @@ func TestCheckUsersUserAccessTokensIntegrity(t *testing.T) {
|
||||
userId := user.Id
|
||||
uat := createUserAccessToken(ss, user.Id)
|
||||
dbmap.Delete(user)
|
||||
result := checkUsersUserAccessTokensIntegrity(supplier)
|
||||
result := checkUsersUserAccessTokensIntegrity(store)
|
||||
require.Nil(t, result.Err)
|
||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
||||
require.Len(t, data.Records, 1)
|
||||
|
||||
@@ -17,13 +17,13 @@ import (
|
||||
)
|
||||
|
||||
type SqlJobStore struct {
|
||||
*SqlSupplier
|
||||
*SqlStore
|
||||
}
|
||||
|
||||
func newSqlJobStore(sqlSupplier *SqlSupplier) store.JobStore {
|
||||
s := &SqlJobStore{sqlSupplier}
|
||||
func newSqlJobStore(sqlStore *SqlStore) store.JobStore {
|
||||
s := &SqlJobStore{sqlStore}
|
||||
|
||||
for _, db := range sqlSupplier.GetAllConns() {
|
||||
for _, db := range sqlStore.GetAllConns() {
|
||||
table := db.AddTableWithName(model.Job{}, "Jobs").SetKeys(false, "Id")
|
||||
table.ColMap("Id").SetMaxSize(26)
|
||||
table.ColMap("Type").SetMaxSize(32)
|
||||
|
||||
@@ -15,13 +15,13 @@ import (
|
||||
// SqlLicenseStore encapsulates the database writes and reads for
|
||||
// model.LicenseRecord objects.
|
||||
type SqlLicenseStore struct {
|
||||
*SqlSupplier
|
||||
*SqlStore
|
||||
}
|
||||
|
||||
func newSqlLicenseStore(sqlSupplier *SqlSupplier) store.LicenseStore {
|
||||
ls := &SqlLicenseStore{sqlSupplier}
|
||||
func newSqlLicenseStore(sqlStore *SqlStore) store.LicenseStore {
|
||||
ls := &SqlLicenseStore{sqlStore}
|
||||
|
||||
for _, db := range sqlSupplier.GetAllConns() {
|
||||
for _, db := range sqlStore.GetAllConns() {
|
||||
table := db.AddTableWithName(model.LicenseRecord{}, "Licenses").SetKeys(false, "Id")
|
||||
table.ColMap("Id").SetMaxSize(26)
|
||||
table.ColMap("Bytes").SetMaxSize(10000)
|
||||
|
||||
@@ -14,13 +14,13 @@ import (
|
||||
)
|
||||
|
||||
type SqlLinkMetadataStore struct {
|
||||
*SqlSupplier
|
||||
*SqlStore
|
||||
}
|
||||
|
||||
func newSqlLinkMetadataStore(sqlSupplier *SqlSupplier) store.LinkMetadataStore {
|
||||
s := &SqlLinkMetadataStore{sqlSupplier}
|
||||
func newSqlLinkMetadataStore(sqlStore *SqlStore) store.LinkMetadataStore {
|
||||
s := &SqlLinkMetadataStore{sqlStore}
|
||||
|
||||
for _, db := range sqlSupplier.GetAllConns() {
|
||||
for _, db := range sqlStore.GetAllConns() {
|
||||
table := db.AddTableWithName(model.LinkMetadata{}, "LinkMetadata").SetKeys(false, "Hash")
|
||||
table.ColMap("URL").SetMaxSize(2048)
|
||||
table.ColMap("Type").SetMaxSize(16)
|
||||
|
||||
@@ -15,13 +15,13 @@ import (
|
||||
)
|
||||
|
||||
type SqlOAuthStore struct {
|
||||
*SqlSupplier
|
||||
*SqlStore
|
||||
}
|
||||
|
||||
func newSqlOAuthStore(sqlSupplier *SqlSupplier) store.OAuthStore {
|
||||
as := &SqlOAuthStore{sqlSupplier}
|
||||
func newSqlOAuthStore(sqlStore *SqlStore) store.OAuthStore {
|
||||
as := &SqlOAuthStore{sqlStore}
|
||||
|
||||
for _, db := range sqlSupplier.GetAllConns() {
|
||||
for _, db := range sqlStore.GetAllConns() {
|
||||
table := db.AddTableWithName(model.OAuthApp{}, "OAuthApps").SetKeys(false, "Id")
|
||||
table.ColMap("Id").SetMaxSize(26)
|
||||
table.ColMap("CreatorId").SetMaxSize(26)
|
||||
|
||||
@@ -20,13 +20,13 @@ const (
|
||||
)
|
||||
|
||||
type SqlPluginStore struct {
|
||||
*SqlSupplier
|
||||
*SqlStore
|
||||
}
|
||||
|
||||
func newSqlPluginStore(sqlSupplier *SqlSupplier) store.PluginStore {
|
||||
s := &SqlPluginStore{sqlSupplier}
|
||||
func newSqlPluginStore(sqlStore *SqlStore) store.PluginStore {
|
||||
s := &SqlPluginStore{sqlStore}
|
||||
|
||||
for _, db := range sqlSupplier.GetAllConns() {
|
||||
for _, db := range sqlStore.GetAllConns() {
|
||||
table := db.AddTableWithName(model.PluginKeyValue{}, "PluginKeyValueStore").SetKeys(false, "PluginId", "Key")
|
||||
table.ColMap("PluginId").SetMaxSize(190)
|
||||
table.ColMap("Key").SetMaxSize(50)
|
||||
|
||||
@@ -10,5 +10,5 @@ import (
|
||||
)
|
||||
|
||||
func TestPluginStore(t *testing.T) {
|
||||
StoreTestWithSqlSupplier(t, storetest.TestPluginStore)
|
||||
StoreTestWithSqlStore(t, storetest.TestPluginStore)
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ import (
|
||||
)
|
||||
|
||||
type SqlPostStore struct {
|
||||
*SqlSupplier
|
||||
*SqlStore
|
||||
metrics einterfaces.MetricsInterface
|
||||
maxPostSizeOnce sync.Once
|
||||
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{
|
||||
SqlSupplier: sqlSupplier,
|
||||
SqlStore: sqlStore,
|
||||
metrics: metrics,
|
||||
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.ColMap("Id").SetMaxSize(26)
|
||||
table.ColMap("UserId").SetMaxSize(26)
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func TestPostStore(t *testing.T) {
|
||||
StoreTestWithSqlSupplier(t, storetest.TestPostStore)
|
||||
StoreTestWithSqlStore(t, storetest.TestPostStore)
|
||||
}
|
||||
|
||||
func TestSearchPostStore(t *testing.T) {
|
||||
|
||||
@@ -15,13 +15,13 @@ import (
|
||||
)
|
||||
|
||||
type SqlPreferenceStore struct {
|
||||
*SqlSupplier
|
||||
*SqlStore
|
||||
}
|
||||
|
||||
func newSqlPreferenceStore(sqlSupplier *SqlSupplier) store.PreferenceStore {
|
||||
s := &SqlPreferenceStore{sqlSupplier}
|
||||
func newSqlPreferenceStore(sqlStore *SqlStore) store.PreferenceStore {
|
||||
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.ColMap("UserId").SetMaxSize(26)
|
||||
table.ColMap("Category").SetMaxSize(32)
|
||||
|
||||
@@ -14,13 +14,13 @@ import (
|
||||
)
|
||||
|
||||
type SqlProductNoticesStore struct {
|
||||
*SqlSupplier
|
||||
*SqlStore
|
||||
}
|
||||
|
||||
func newSqlProductNoticesStore(sqlSupplier *SqlSupplier) store.ProductNoticesStore {
|
||||
s := SqlProductNoticesStore{sqlSupplier}
|
||||
func newSqlProductNoticesStore(sqlStore *SqlStore) store.ProductNoticesStore {
|
||||
s := SqlProductNoticesStore{sqlStore}
|
||||
|
||||
for _, db := range sqlSupplier.GetAllConns() {
|
||||
for _, db := range sqlStore.GetAllConns() {
|
||||
table := db.AddTableWithName(model.ProductNoticeViewState{}, "ProductNoticeViewState").SetKeys(false, "UserId", "NoticeId")
|
||||
table.ColMap("UserId").SetMaxSize(26)
|
||||
table.ColMap("NoticeId").SetMaxSize(26)
|
||||
|
||||
@@ -13,13 +13,13 @@ import (
|
||||
)
|
||||
|
||||
type SqlReactionStore struct {
|
||||
*SqlSupplier
|
||||
*SqlStore
|
||||
}
|
||||
|
||||
func newSqlReactionStore(sqlSupplier *SqlSupplier) store.ReactionStore {
|
||||
s := &SqlReactionStore{sqlSupplier}
|
||||
func newSqlReactionStore(sqlStore *SqlStore) store.ReactionStore {
|
||||
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.ColMap("UserId").SetMaxSize(26)
|
||||
table.ColMap("PostId").SetMaxSize(26)
|
||||
@@ -17,7 +17,7 @@ import (
|
||||
)
|
||||
|
||||
type SqlRoleStore struct {
|
||||
*SqlSupplier
|
||||
*SqlStore
|
||||
}
|
||||
|
||||
type Role struct {
|
||||
@@ -82,10 +82,10 @@ func (role Role) ToModel() *model.Role {
|
||||
}
|
||||
}
|
||||
|
||||
func newSqlRoleStore(sqlSupplier *SqlSupplier) store.RoleStore {
|
||||
s := &SqlRoleStore{sqlSupplier}
|
||||
func newSqlRoleStore(sqlStore *SqlStore) store.RoleStore {
|
||||
s := &SqlRoleStore{sqlStore}
|
||||
|
||||
for _, db := range sqlSupplier.GetAllConns() {
|
||||
for _, db := range sqlStore.GetAllConns() {
|
||||
table := db.AddTableWithName(Role{}, "Roles").SetKeys(false, "Id")
|
||||
table.ColMap("Id").SetMaxSize(26)
|
||||
table.ColMap("Name").SetMaxSize(64).SetUnique(true)
|
||||
|
||||
@@ -10,5 +10,5 @@ import (
|
||||
)
|
||||
|
||||
func TestRoleStore(t *testing.T) {
|
||||
StoreTestWithSqlSupplier(t, storetest.TestRoleStore)
|
||||
StoreTestWithSqlStore(t, storetest.TestRoleStore)
|
||||
}
|
||||
|
||||
@@ -16,13 +16,13 @@ import (
|
||||
)
|
||||
|
||||
type SqlSchemeStore struct {
|
||||
*SqlSupplier
|
||||
*SqlStore
|
||||
}
|
||||
|
||||
func newSqlSchemeStore(sqlSupplier *SqlSupplier) store.SchemeStore {
|
||||
s := &SqlSchemeStore{sqlSupplier}
|
||||
func newSqlSchemeStore(sqlStore *SqlStore) store.SchemeStore {
|
||||
s := &SqlSchemeStore{sqlStore}
|
||||
|
||||
for _, db := range sqlSupplier.GetAllConns() {
|
||||
for _, db := range sqlStore.GetAllConns() {
|
||||
table := db.AddTableWithName(model.Scheme{}, "Schemes").SetKeys(false, "Id")
|
||||
table.ColMap("Id").SetMaxSize(26)
|
||||
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.
|
||||
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)
|
||||
roles, appErr := s.SqlSupplier.Role().GetByNames(defaultRoleNames)
|
||||
roles, appErr := s.SqlStore.Role().GetByNames(defaultRoleNames)
|
||||
if appErr != nil {
|
||||
return nil, appErr
|
||||
}
|
||||
@@ -121,7 +121,7 @@ func (s *SqlSchemeStore) createScheme(scheme *model.Scheme, transaction *gorp.Tr
|
||||
SchemeManaged: true,
|
||||
}
|
||||
|
||||
savedRole, err := s.SqlSupplier.Role().(*SqlRoleStore).createRole(teamAdminRole, transaction)
|
||||
savedRole, err := s.SqlStore.Role().(*SqlRoleStore).createRole(teamAdminRole, transaction)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -135,7 +135,7 @@ func (s *SqlSchemeStore) createScheme(scheme *model.Scheme, transaction *gorp.Tr
|
||||
SchemeManaged: true,
|
||||
}
|
||||
|
||||
savedRole, err = s.SqlSupplier.Role().(*SqlRoleStore).createRole(teamUserRole, transaction)
|
||||
savedRole, err = s.SqlStore.Role().(*SqlRoleStore).createRole(teamUserRole, transaction)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -149,7 +149,7 @@ func (s *SqlSchemeStore) createScheme(scheme *model.Scheme, transaction *gorp.Tr
|
||||
SchemeManaged: true,
|
||||
}
|
||||
|
||||
savedRole, err = s.SqlSupplier.Role().(*SqlRoleStore).createRole(teamGuestRole, transaction)
|
||||
savedRole, err = s.SqlStore.Role().(*SqlRoleStore).createRole(teamGuestRole, transaction)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -169,7 +169,7 @@ func (s *SqlSchemeStore) createScheme(scheme *model.Scheme, transaction *gorp.Tr
|
||||
channelAdminRole.Permissions = []string{}
|
||||
}
|
||||
|
||||
savedRole, err := s.SqlSupplier.Role().(*SqlRoleStore).createRole(channelAdminRole, transaction)
|
||||
savedRole, err := s.SqlStore.Role().(*SqlRoleStore).createRole(channelAdminRole, transaction)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -187,7 +187,7 @@ func (s *SqlSchemeStore) createScheme(scheme *model.Scheme, transaction *gorp.Tr
|
||||
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 {
|
||||
return nil, err
|
||||
}
|
||||
@@ -205,7 +205,7 @@ func (s *SqlSchemeStore) createScheme(scheme *model.Scheme, transaction *gorp.Tr
|
||||
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 {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -21,13 +21,13 @@ const (
|
||||
)
|
||||
|
||||
type SqlSessionStore struct {
|
||||
*SqlSupplier
|
||||
*SqlStore
|
||||
}
|
||||
|
||||
func newSqlSessionStore(sqlSupplier *SqlSupplier) store.SessionStore {
|
||||
us := &SqlSessionStore{sqlSupplier}
|
||||
func newSqlSessionStore(sqlStore *SqlStore) store.SessionStore {
|
||||
us := &SqlSessionStore{sqlStore}
|
||||
|
||||
for _, db := range sqlSupplier.GetAllConns() {
|
||||
for _, db := range sqlStore.GetAllConns() {
|
||||
table := db.AddTableWithName(model.Session{}, "Sessions").SetKeys(false, "Id")
|
||||
table.ColMap("Id").SetMaxSize(26)
|
||||
table.ColMap("Token").SetMaxSize(26)
|
||||
|
||||
@@ -16,13 +16,13 @@ import (
|
||||
)
|
||||
|
||||
type SqlStatusStore struct {
|
||||
*SqlSupplier
|
||||
*SqlStore
|
||||
}
|
||||
|
||||
func newSqlStatusStore(sqlSupplier *SqlSupplier) store.StatusStore {
|
||||
s := &SqlStatusStore{sqlSupplier}
|
||||
func newSqlStatusStore(sqlStore *SqlStore) store.StatusStore {
|
||||
s := &SqlStatusStore{sqlStore}
|
||||
|
||||
for _, db := range sqlSupplier.GetAllConns() {
|
||||
for _, db := range sqlStore.GetAllConns() {
|
||||
table := db.AddTableWithName(model.Status{}, "Status").SetKeys(false, "UserId")
|
||||
table.ColMap("UserId").SetMaxSize(26)
|
||||
table.ColMap("Status").SetMaxSize(32)
|
||||
|
||||
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
@@ -4,20 +4,30 @@
|
||||
package sqlstore
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"regexp"
|
||||
"sync"
|
||||
"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/store"
|
||||
"github.com/mattermost/mattermost-server/v5/store/searchtest"
|
||||
"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 {
|
||||
Name string
|
||||
SqlSettings *model.SqlSettings
|
||||
SqlSupplier *SqlSupplier
|
||||
SqlStore *SqlStore
|
||||
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() {
|
||||
if err := recover(); err != nil {
|
||||
tearDownStores()
|
||||
@@ -79,7 +89,7 @@ func StoreTestWithSqlSupplier(t *testing.T, f func(*testing.T, store.Store, stor
|
||||
if testing.Short() {
|
||||
t.SkipNow()
|
||||
}
|
||||
f(t, st.Store, st.SqlSupplier)
|
||||
f(t, st.Store, st.SqlStore)
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -114,8 +124,8 @@ func initStores() {
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
st.SqlSupplier = NewSqlSupplier(*st.SqlSettings, nil)
|
||||
st.Store = st.SqlSupplier
|
||||
st.SqlStore = New(*st.SqlSettings, nil)
|
||||
st.Store = st.SqlStore
|
||||
st.Store.DropAllTables()
|
||||
st.Store.MarkSystemRanUnitTests()
|
||||
}()
|
||||
@@ -147,3 +157,347 @@ func tearDownStores() {
|
||||
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 {
|
||||
*SqlSupplier
|
||||
*SqlStore
|
||||
}
|
||||
|
||||
func newSqlSystemStore(sqlSupplier *SqlSupplier) store.SystemStore {
|
||||
s := &SqlSystemStore{sqlSupplier}
|
||||
func newSqlSystemStore(sqlStore *SqlStore) store.SystemStore {
|
||||
s := &SqlSystemStore{sqlStore}
|
||||
|
||||
for _, db := range sqlSupplier.GetAllConns() {
|
||||
for _, db := range sqlStore.GetAllConns() {
|
||||
table := db.AddTableWithName(model.System{}, "Systems").SetKeys(false, "Name")
|
||||
table.ColMap("Name").SetMaxSize(64)
|
||||
table.ColMap("Value").SetMaxSize(1024)
|
||||
|
||||
@@ -23,7 +23,7 @@ const (
|
||||
)
|
||||
|
||||
type SqlTeamStore struct {
|
||||
*SqlSupplier
|
||||
*SqlStore
|
||||
|
||||
teamsQuery sq.SelectBuilder
|
||||
}
|
||||
@@ -202,16 +202,16 @@ func (db teamMemberWithSchemeRolesList) ToModel() []*model.TeamMember {
|
||||
return tms
|
||||
}
|
||||
|
||||
func newSqlTeamStore(sqlSupplier *SqlSupplier) store.TeamStore {
|
||||
func newSqlTeamStore(sqlStore *SqlStore) store.TeamStore {
|
||||
s := &SqlTeamStore{
|
||||
SqlSupplier: sqlSupplier,
|
||||
SqlStore: sqlStore,
|
||||
}
|
||||
|
||||
s.teamsQuery = s.getQueryBuilder().
|
||||
Select("Teams.*").
|
||||
From("Teams")
|
||||
|
||||
for _, db := range sqlSupplier.GetAllConns() {
|
||||
for _, db := range sqlStore.GetAllConns() {
|
||||
table := db.AddTableWithName(model.Team{}, "Teams").SetKeys(false, "Id")
|
||||
table.ColMap("Id").SetMaxSize(26)
|
||||
table.ColMap("DisplayName").SetMaxSize(64)
|
||||
|
||||
@@ -14,14 +14,14 @@ import (
|
||||
)
|
||||
|
||||
type SqlTermsOfServiceStore struct {
|
||||
*SqlSupplier
|
||||
*SqlStore
|
||||
metrics einterfaces.MetricsInterface
|
||||
}
|
||||
|
||||
func newSqlTermsOfServiceStore(sqlSupplier *SqlSupplier, metrics einterfaces.MetricsInterface) store.TermsOfServiceStore {
|
||||
s := SqlTermsOfServiceStore{sqlSupplier, metrics}
|
||||
func newSqlTermsOfServiceStore(sqlStore *SqlStore, metrics einterfaces.MetricsInterface) store.TermsOfServiceStore {
|
||||
s := SqlTermsOfServiceStore{sqlStore, metrics}
|
||||
|
||||
for _, db := range sqlSupplier.GetAllConns() {
|
||||
for _, db := range sqlStore.GetAllConns() {
|
||||
table := db.AddTableWithName(model.TermsOfService{}, "TermsOfService").SetKeys(false, "Id")
|
||||
table.ColMap("Id").SetMaxSize(26)
|
||||
table.ColMap("UserId").SetMaxSize(26)
|
||||
|
||||
@@ -16,18 +16,18 @@ import (
|
||||
)
|
||||
|
||||
type SqlThreadStore struct {
|
||||
*SqlSupplier
|
||||
*SqlStore
|
||||
}
|
||||
|
||||
func (s *SqlThreadStore) ClearCaches() {
|
||||
}
|
||||
|
||||
func newSqlThreadStore(sqlSupplier *SqlSupplier) store.ThreadStore {
|
||||
func newSqlThreadStore(sqlStore *SqlStore) store.ThreadStore {
|
||||
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.ColMap("PostId").SetMaxSize(26)
|
||||
tableThreads.ColMap("ChannelId").SetMaxSize(26)
|
||||
|
||||
@@ -10,5 +10,5 @@ import (
|
||||
)
|
||||
|
||||
func TestThreadStore(t *testing.T) {
|
||||
StoreTestWithSqlSupplier(t, storetest.TestThreadStore)
|
||||
StoreTestWithSqlStore(t, storetest.TestThreadStore)
|
||||
}
|
||||
|
||||
@@ -15,13 +15,13 @@ import (
|
||||
)
|
||||
|
||||
type SqlTokenStore struct {
|
||||
*SqlSupplier
|
||||
*SqlStore
|
||||
}
|
||||
|
||||
func newSqlTokenStore(sqlSupplier *SqlSupplier) store.TokenStore {
|
||||
s := &SqlTokenStore{sqlSupplier}
|
||||
func newSqlTokenStore(sqlStore *SqlStore) store.TokenStore {
|
||||
s := &SqlTokenStore{sqlStore}
|
||||
|
||||
for _, db := range sqlSupplier.GetAllConns() {
|
||||
for _, db := range sqlStore.GetAllConns() {
|
||||
table := db.AddTableWithName(model.Token{}, "Tokens").SetKeys(false, "Token")
|
||||
table.ColMap("Token").SetMaxSize(64)
|
||||
table.ColMap("Type").SetMaxSize(64)
|
||||
|
||||
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
@@ -12,7 +12,7 @@ import (
|
||||
|
||||
func TestStoreUpgrade(t *testing.T) {
|
||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||
sqlStore := ss.(*SqlSupplier)
|
||||
sqlStore := ss.(*SqlStore)
|
||||
|
||||
t.Run("invalid currentModelVersion", func(t *testing.T) {
|
||||
err := upgradeDatabase(sqlStore, "notaversion")
|
||||
@@ -81,7 +81,7 @@ func TestStoreUpgrade(t *testing.T) {
|
||||
|
||||
func TestSaveSchemaVersion(t *testing.T) {
|
||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||
sqlStore := ss.(*SqlSupplier)
|
||||
sqlStore := ss.(*SqlStore)
|
||||
|
||||
t.Run("set earliest version", func(t *testing.T) {
|
||||
saveSchemaVersion(sqlStore, VERSION_3_0_0)
|
||||
|
||||
@@ -15,14 +15,14 @@ import (
|
||||
)
|
||||
|
||||
type SqlUploadSessionStore struct {
|
||||
*SqlSupplier
|
||||
*SqlStore
|
||||
}
|
||||
|
||||
func newSqlUploadSessionStore(sqlSupplier *SqlSupplier) store.UploadSessionStore {
|
||||
func newSqlUploadSessionStore(sqlStore *SqlStore) store.UploadSessionStore {
|
||||
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.ColMap("Id").SetMaxSize(26)
|
||||
table.ColMap("Type").SetMaxSize(32)
|
||||
|
||||
@@ -15,13 +15,13 @@ import (
|
||||
)
|
||||
|
||||
type SqlUserAccessTokenStore struct {
|
||||
*SqlSupplier
|
||||
*SqlStore
|
||||
}
|
||||
|
||||
func newSqlUserAccessTokenStore(sqlSupplier *SqlSupplier) store.UserAccessTokenStore {
|
||||
s := &SqlUserAccessTokenStore{sqlSupplier}
|
||||
func newSqlUserAccessTokenStore(sqlStore *SqlStore) store.UserAccessTokenStore {
|
||||
s := &SqlUserAccessTokenStore{sqlStore}
|
||||
|
||||
for _, db := range sqlSupplier.GetAllConns() {
|
||||
for _, db := range sqlStore.GetAllConns() {
|
||||
table := db.AddTableWithName(model.UserAccessToken{}, "UserAccessTokens").SetKeys(false, "Id")
|
||||
table.ColMap("Id").SetMaxSize(26)
|
||||
table.ColMap("Token").SetMaxSize(26).SetUnique(true)
|
||||
|
||||
@@ -31,7 +31,7 @@ var (
|
||||
)
|
||||
|
||||
type SqlUserStore struct {
|
||||
*SqlSupplier
|
||||
*SqlStore
|
||||
metrics einterfaces.MetricsInterface
|
||||
|
||||
// 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 newSqlUserStore(sqlSupplier *SqlSupplier, metrics einterfaces.MetricsInterface) store.UserStore {
|
||||
func newSqlUserStore(sqlStore *SqlStore, metrics einterfaces.MetricsInterface) store.UserStore {
|
||||
us := &SqlUserStore{
|
||||
SqlSupplier: sqlSupplier,
|
||||
metrics: metrics,
|
||||
SqlStore: sqlStore,
|
||||
metrics: metrics,
|
||||
}
|
||||
|
||||
// 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").
|
||||
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.ColMap("Id").SetMaxSize(26)
|
||||
table.ColMap("Username").SetMaxSize(64).SetUnique(true)
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
)
|
||||
|
||||
func TestUserStore(t *testing.T) {
|
||||
StoreTestWithSqlSupplier(t, storetest.TestUserStore)
|
||||
StoreTestWithSqlStore(t, storetest.TestUserStore)
|
||||
}
|
||||
|
||||
func TestSearchUserStore(t *testing.T) {
|
||||
|
||||
@@ -13,13 +13,13 @@ import (
|
||||
)
|
||||
|
||||
type SqlUserTermsOfServiceStore struct {
|
||||
*SqlSupplier
|
||||
*SqlStore
|
||||
}
|
||||
|
||||
func newSqlUserTermsOfServiceStore(sqlSupplier *SqlSupplier) store.UserTermsOfServiceStore {
|
||||
s := SqlUserTermsOfServiceStore{sqlSupplier}
|
||||
func newSqlUserTermsOfServiceStore(sqlStore *SqlStore) store.UserTermsOfServiceStore {
|
||||
s := SqlUserTermsOfServiceStore{sqlStore}
|
||||
|
||||
for _, db := range sqlSupplier.GetAllConns() {
|
||||
for _, db := range sqlStore.GetAllConns() {
|
||||
table := db.AddTableWithName(model.UserTermsOfService{}, "UserTermsOfService").SetKeys(false, "UserId")
|
||||
table.ColMap("UserId").SetMaxSize(26)
|
||||
table.ColMap("TermsOfServiceId").SetMaxSize(26)
|
||||
|
||||
@@ -15,20 +15,20 @@ import (
|
||||
)
|
||||
|
||||
type SqlWebhookStore struct {
|
||||
*SqlSupplier
|
||||
*SqlStore
|
||||
metrics einterfaces.MetricsInterface
|
||||
}
|
||||
|
||||
func (s SqlWebhookStore) ClearCaches() {
|
||||
}
|
||||
|
||||
func newSqlWebhookStore(sqlSupplier *SqlSupplier, metrics einterfaces.MetricsInterface) store.WebhookStore {
|
||||
func newSqlWebhookStore(sqlStore *SqlStore, metrics einterfaces.MetricsInterface) store.WebhookStore {
|
||||
s := &SqlWebhookStore{
|
||||
SqlSupplier: sqlSupplier,
|
||||
metrics: metrics,
|
||||
SqlStore: sqlStore,
|
||||
metrics: metrics,
|
||||
}
|
||||
|
||||
for _, db := range sqlSupplier.GetAllConns() {
|
||||
for _, db := range sqlStore.GetAllConns() {
|
||||
table := db.AddTableWithName(model.IncomingWebhook{}, "IncomingWebhooks").SetKeys(false, "Id")
|
||||
table.ColMap("Id").SetMaxSize(26)
|
||||
table.ColMap("UserId").SetMaxSize(26)
|
||||
|
||||
Ссылка в новой задаче
Block a user