summaryrefslogtreecommitdiffstats
path: root/store
diff options
context:
space:
mode:
Diffstat (limited to 'store')
-rw-r--r--store/sqlstore/channel_store.go49
-rw-r--r--store/sqlstore/team_store.go2
-rw-r--r--store/sqlstore/upgrade.go12
-rw-r--r--store/sqlstore/user_store.go2
-rw-r--r--store/sqlstore/webhook_store.go4
-rw-r--r--store/store.go1
-rw-r--r--store/storetest/channel_store.go93
-rw-r--r--store/storetest/command_store.go2
-rw-r--r--store/storetest/compliance_store.go10
-rw-r--r--store/storetest/job_store.go1
-rw-r--r--store/storetest/mocks/ChannelStore.go16
-rw-r--r--store/storetest/post_store.go28
-rw-r--r--store/storetest/scheme_store.go1
-rw-r--r--store/storetest/team_store.go14
-rw-r--r--store/storetest/webhook_store.go4
15 files changed, 201 insertions, 38 deletions
diff --git a/store/sqlstore/channel_store.go b/store/sqlstore/channel_store.go
index fba37d7cb..820fe1e9f 100644
--- a/store/sqlstore/channel_store.go
+++ b/store/sqlstore/channel_store.go
@@ -1589,6 +1589,53 @@ func (s SqlChannelStore) AutocompleteInTeam(teamId string, term string, includeD
})
}
+func (s SqlChannelStore) AutocompleteInTeamForSearch(teamId string, userId string, term string, includeDeleted bool) store.StoreChannel {
+ return store.Do(func(result *store.StoreResult) {
+ deleteFilter := "AND DeleteAt = 0"
+ if includeDeleted {
+ deleteFilter = ""
+ }
+
+ queryFormat := `
+ SELECT
+ C.*
+ FROM
+ Channels AS C
+ JOIN
+ ChannelMembers AS CM ON CM.ChannelId = C.Id
+ WHERE
+ C.TeamId = :TeamId
+ AND CM.UserId = :UserId
+ ` + deleteFilter + `
+ %v
+ LIMIT 50`
+
+ var channels model.ChannelList
+
+ if likeClause, likeTerm := s.buildLIKEClause(term); likeClause == "" {
+ if _, err := s.GetReplica().Select(&channels, fmt.Sprintf(queryFormat, ""), map[string]interface{}{"TeamId": teamId, "UserId": userId}); err != nil {
+ result.Err = model.NewAppError("SqlChannelStore.AutocompleteInTeamForSearch", "store.sql_channel.search.app_error", nil, "term="+term+", "+", "+err.Error(), http.StatusInternalServerError)
+ }
+ } else {
+ // Using a UNION results in index_merge and fulltext queries and is much faster than the ref
+ // query you would get using an OR of the LIKE and full-text clauses.
+ fulltextClause, fulltextTerm := s.buildFulltextClause(term)
+ likeQuery := fmt.Sprintf(queryFormat, "AND "+likeClause)
+ fulltextQuery := fmt.Sprintf(queryFormat, "AND "+fulltextClause)
+ query := fmt.Sprintf("(%v) UNION (%v) LIMIT 50", likeQuery, fulltextQuery)
+
+ if _, err := s.GetReplica().Select(&channels, query, map[string]interface{}{"TeamId": teamId, "UserId": userId, "LikeTerm": likeTerm, "FulltextTerm": fulltextTerm}); err != nil {
+ result.Err = model.NewAppError("SqlChannelStore.AutocompleteInTeamForSearch", "store.sql_channel.search.app_error", nil, "term="+term+", "+", "+err.Error(), http.StatusInternalServerError)
+ }
+ }
+
+ sort.Slice(channels, func(a, b int) bool {
+ return strings.ToLower(channels[a].DisplayName) < strings.ToLower(channels[b].DisplayName)
+ })
+ result.Data = &channels
+ })
+}
+
func (s SqlChannelStore) SearchInTeam(teamId string, term string, includeDeleted bool) store.StoreChannel {
return store.Do(func(result *store.StoreResult) {
deleteFilter := "AND DeleteAt = 0"
@@ -1864,7 +1911,7 @@ func (s SqlChannelStore) ClearAllCustomRoleAssignments() store.StoreChannel {
lastUserId := strings.Repeat("0", 26)
lastChannelId := strings.Repeat("0", 26)
- for true {
+ for {
var transaction *gorp.Transaction
var err error
diff --git a/store/sqlstore/team_store.go b/store/sqlstore/team_store.go
index d9e33df76..3ea6feced 100644
--- a/store/sqlstore/team_store.go
+++ b/store/sqlstore/team_store.go
@@ -851,7 +851,7 @@ func (s SqlTeamStore) ClearAllCustomRoleAssignments() store.StoreChannel {
lastUserId := strings.Repeat("0", 26)
lastTeamId := strings.Repeat("0", 26)
- for true {
+ for {
var transaction *gorp.Transaction
var err error
diff --git a/store/sqlstore/upgrade.go b/store/sqlstore/upgrade.go
index cd45dfcb3..5f74dbfb1 100644
--- a/store/sqlstore/upgrade.go
+++ b/store/sqlstore/upgrade.go
@@ -15,6 +15,7 @@ import (
)
const (
+ VERSION_5_4_0 = "5.4.0"
VERSION_5_3_0 = "5.3.0"
VERSION_5_2_0 = "5.2.0"
VERSION_5_1_0 = "5.1.0"
@@ -84,6 +85,7 @@ func UpgradeDatabase(sqlStore SqlStore) {
UpgradeDatabaseToVersion51(sqlStore)
UpgradeDatabaseToVersion52(sqlStore)
UpgradeDatabaseToVersion53(sqlStore)
+ UpgradeDatabaseToVersion54(sqlStore)
// If the SchemaVersion is empty this this is the first time it has ran
// so lets set it to the current version.
@@ -487,4 +489,14 @@ func UpgradeDatabaseToVersion53(sqlStore SqlStore) {
if shouldPerformUpgrade(sqlStore, VERSION_5_2_0, VERSION_5_3_0) {
saveSchemaVersion(sqlStore, VERSION_5_3_0)
}
+
+}
+
+func UpgradeDatabaseToVersion54(sqlStore SqlStore) {
+ // TODO: Uncomment following condition when version 5.4.0 is released
+ // if shouldPerformUpgrade(sqlStore, VERSION_5_3_0, VERSION_5_4_0) {
+ sqlStore.AlterColumnTypeIfExists("OutgoingWebhooks", "Description", "varchar(500)", "varchar(500)")
+ sqlStore.AlterColumnTypeIfExists("IncomingWebhooks", "Description", "varchar(500)", "varchar(500)")
+ // saveSchemaVersion(sqlStore, VERSION_5_4_0)
+ // }
}
diff --git a/store/sqlstore/user_store.go b/store/sqlstore/user_store.go
index d8a77cd9d..c89c445ad 100644
--- a/store/sqlstore/user_store.go
+++ b/store/sqlstore/user_store.go
@@ -1255,7 +1255,7 @@ func (us SqlUserStore) ClearAllCustomRoleAssignments() store.StoreChannel {
builtInRoles := model.MakeDefaultRoles()
lastUserId := strings.Repeat("0", 26)
- for true {
+ for {
var transaction *gorp.Transaction
var err error
diff --git a/store/sqlstore/webhook_store.go b/store/sqlstore/webhook_store.go
index f3c572aaf..94eadf836 100644
--- a/store/sqlstore/webhook_store.go
+++ b/store/sqlstore/webhook_store.go
@@ -47,7 +47,7 @@ func NewSqlWebhookStore(sqlStore SqlStore, metrics einterfaces.MetricsInterface)
table.ColMap("ChannelId").SetMaxSize(26)
table.ColMap("TeamId").SetMaxSize(26)
table.ColMap("DisplayName").SetMaxSize(64)
- table.ColMap("Description").SetMaxSize(128)
+ table.ColMap("Description").SetMaxSize(500)
tableo := db.AddTableWithName(model.OutgoingWebhook{}, "OutgoingWebhooks").SetKeys(false, "Id")
tableo.ColMap("Id").SetMaxSize(26)
@@ -58,7 +58,7 @@ func NewSqlWebhookStore(sqlStore SqlStore, metrics einterfaces.MetricsInterface)
tableo.ColMap("TriggerWords").SetMaxSize(1024)
tableo.ColMap("CallbackURLs").SetMaxSize(1024)
tableo.ColMap("DisplayName").SetMaxSize(64)
- tableo.ColMap("Description").SetMaxSize(128)
+ tableo.ColMap("Description").SetMaxSize(500)
tableo.ColMap("ContentType").SetMaxSize(128)
tableo.ColMap("TriggerWhen").SetMaxSize(1)
tableo.ColMap("Username").SetMaxSize(64)
diff --git a/store/store.go b/store/store.go
index 0c89a0a91..8da70d7ec 100644
--- a/store/store.go
+++ b/store/store.go
@@ -162,6 +162,7 @@ type ChannelStore interface {
AnalyticsTypeCount(teamId string, channelType string) StoreChannel
GetMembersForUser(teamId string, userId string) StoreChannel
AutocompleteInTeam(teamId string, term string, includeDeleted bool) StoreChannel
+ AutocompleteInTeamForSearch(teamId string, userId string, term string, includeDeleted bool) StoreChannel
SearchInTeam(teamId string, term string, includeDeleted bool) StoreChannel
SearchMore(userId string, teamId string, term string) StoreChannel
GetMembersByIds(channelId string, userIds []string) StoreChannel
diff --git a/store/storetest/channel_store.go b/store/storetest/channel_store.go
index c827a4226..54316d1ce 100644
--- a/store/storetest/channel_store.go
+++ b/store/storetest/channel_store.go
@@ -48,6 +48,7 @@ func TestChannelStore(t *testing.T, ss store.Store) {
t.Run("GetMemberCount", func(t *testing.T) { testGetMemberCount(t, ss) })
t.Run("SearchMore", func(t *testing.T) { testChannelStoreSearchMore(t, ss) })
t.Run("SearchInTeam", func(t *testing.T) { testChannelStoreSearchInTeam(t, ss) })
+ t.Run("AutocompleteInTeamForSearch", func(t *testing.T) { testChannelStoreAutocompleteInTeamForSearch(t, ss) })
t.Run("GetMembersByIds", func(t *testing.T) { testChannelStoreGetMembersByIds(t, ss) })
t.Run("AnalyticsDeletedTypeCount", func(t *testing.T) { testChannelStoreAnalyticsDeletedTypeCount(t, ss) })
t.Run("GetPinnedPosts", func(t *testing.T) { testChannelStoreGetPinnedPosts(t, ss) })
@@ -2054,6 +2055,92 @@ func testChannelStoreSearchInTeam(t *testing.T, ss store.Store) {
}
}
+func testChannelStoreAutocompleteInTeamForSearch(t *testing.T, ss store.Store) {
+ o1 := model.Channel{}
+ o1.TeamId = model.NewId()
+ o1.DisplayName = "ChannelA"
+ o1.Name = "zz" + model.NewId() + "b"
+ o1.Type = model.CHANNEL_OPEN
+ store.Must(ss.Channel().Save(&o1, -1))
+
+ m1 := model.ChannelMember{}
+ m1.ChannelId = o1.Id
+ m1.UserId = model.NewId()
+ m1.NotifyProps = model.GetDefaultChannelNotifyProps()
+ store.Must(ss.Channel().SaveMember(&m1))
+
+ o2 := model.Channel{}
+ o2.TeamId = model.NewId()
+ o2.DisplayName = "Channel2"
+ o2.Name = "zz" + model.NewId() + "b"
+ o2.Type = model.CHANNEL_OPEN
+ store.Must(ss.Channel().Save(&o2, -1))
+
+ m2 := model.ChannelMember{}
+ m2.ChannelId = o2.Id
+ m2.UserId = m1.UserId
+ m2.NotifyProps = model.GetDefaultChannelNotifyProps()
+ store.Must(ss.Channel().SaveMember(&m2))
+
+ o3 := model.Channel{}
+ o3.TeamId = o1.TeamId
+ o3.DisplayName = "ChannelA"
+ o3.Name = "zz" + model.NewId() + "b"
+ o3.Type = model.CHANNEL_OPEN
+ store.Must(ss.Channel().Save(&o3, -1))
+
+ m3 := model.ChannelMember{}
+ m3.ChannelId = o3.Id
+ m3.UserId = m1.UserId
+ m3.NotifyProps = model.GetDefaultChannelNotifyProps()
+ store.Must(ss.Channel().SaveMember(&m3))
+
+ store.Must(ss.Channel().SetDeleteAt(o3.Id, 100, 100))
+
+ o4 := model.Channel{}
+ o4.TeamId = o1.TeamId
+ o4.DisplayName = "ChannelA"
+ o4.Name = "zz" + model.NewId() + "b"
+ o4.Type = model.CHANNEL_PRIVATE
+ store.Must(ss.Channel().Save(&o4, -1))
+
+ m4 := model.ChannelMember{}
+ m4.ChannelId = o4.Id
+ m4.UserId = m1.UserId
+ m4.NotifyProps = model.GetDefaultChannelNotifyProps()
+ store.Must(ss.Channel().SaveMember(&m4))
+
+ o5 := model.Channel{}
+ o5.TeamId = o1.TeamId
+ o5.DisplayName = "ChannelC"
+ o5.Name = "zz" + model.NewId() + "b"
+ o5.Type = model.CHANNEL_PRIVATE
+ store.Must(ss.Channel().Save(&o5, -1))
+
+ tt := []struct {
+ name string
+ term string
+ includeDeleted bool
+ expectedMatches int
+ }{
+ {"Empty search (list all)", "", false, 3},
+ {"Narrow search", "ChannelA", false, 2},
+ {"Wide search", "Cha", false, 3},
+ {"Wide search with archived channels", "Cha", true, 4},
+ {"Narrow with archived channels", "ChannelA", true, 3},
+ {"Search without results", "blarg", true, 0},
+ }
+
+ for _, tc := range tt {
+ t.Run(tc.name, func(t *testing.T) {
+ result := <-ss.Channel().AutocompleteInTeamForSearch(o1.TeamId, m1.UserId, "ChannelA", false)
+ require.Nil(t, result.Err)
+ channels := result.Data.(*model.ChannelList)
+ require.Len(t, *channels, 2)
+ })
+ }
+}
+
func testChannelStoreGetMembersByIds(t *testing.T, ss store.Store) {
o1 := model.Channel{}
o1.TeamId = model.NewId()
@@ -2287,9 +2374,9 @@ func testChannelStoreGetChannelsByScheme(t *testing.T, ss store.Store) {
Type: model.CHANNEL_OPEN,
}
- c1 = (<-ss.Channel().Save(c1, 100)).Data.(*model.Channel)
- c2 = (<-ss.Channel().Save(c2, 100)).Data.(*model.Channel)
- c3 = (<-ss.Channel().Save(c3, 100)).Data.(*model.Channel)
+ _ = (<-ss.Channel().Save(c1, 100)).Data.(*model.Channel)
+ _ = (<-ss.Channel().Save(c2, 100)).Data.(*model.Channel)
+ _ = (<-ss.Channel().Save(c3, 100)).Data.(*model.Channel)
// Get the channels by a valid Scheme ID.
res1 := <-ss.Channel().GetChannelsByScheme(s1.Id, 0, 100)
diff --git a/store/storetest/command_store.go b/store/storetest/command_store.go
index ffc575563..ba6c26482 100644
--- a/store/storetest/command_store.go
+++ b/store/storetest/command_store.go
@@ -105,7 +105,7 @@ func testCommandStoreGetByTrigger(t *testing.T, ss store.Store) {
o2.Trigger = "trigger1"
o1 = (<-ss.Command().Save(o1)).Data.(*model.Command)
- o2 = (<-ss.Command().Save(o2)).Data.(*model.Command)
+ _ = (<-ss.Command().Save(o2)).Data.(*model.Command)
if r1 := <-ss.Command().GetByTrigger(o1.TeamId, o1.Trigger); r1.Err != nil {
t.Fatal(r1.Err)
diff --git a/store/storetest/compliance_store.go b/store/storetest/compliance_store.go
index f7f095a00..14ed29865 100644
--- a/store/storetest/compliance_store.go
+++ b/store/storetest/compliance_store.go
@@ -108,14 +108,14 @@ func testComplianceExport(t *testing.T, ss store.Store) {
o1a.UserId = u1.Id
o1a.CreateAt = o1.CreateAt + 10
o1a.Message = "zz" + model.NewId() + "b"
- o1a = store.Must(ss.Post().Save(o1a)).(*model.Post)
+ _ = store.Must(ss.Post().Save(o1a)).(*model.Post)
o2 := &model.Post{}
o2.ChannelId = c1.Id
o2.UserId = u1.Id
o2.CreateAt = o1.CreateAt + 20
o2.Message = "zz" + model.NewId() + "b"
- o2 = store.Must(ss.Post().Save(o2)).(*model.Post)
+ _ = store.Must(ss.Post().Save(o2)).(*model.Post)
o2a := &model.Post{}
o2a.ChannelId = c1.Id
@@ -272,21 +272,21 @@ func testComplianceExportDirectMessages(t *testing.T, ss store.Store) {
o1a.UserId = u1.Id
o1a.CreateAt = o1.CreateAt + 10
o1a.Message = "zz" + model.NewId() + "b"
- o1a = store.Must(ss.Post().Save(o1a)).(*model.Post)
+ _ = store.Must(ss.Post().Save(o1a)).(*model.Post)
o2 := &model.Post{}
o2.ChannelId = c1.Id
o2.UserId = u1.Id
o2.CreateAt = o1.CreateAt + 20
o2.Message = "zz" + model.NewId() + "b"
- o2 = store.Must(ss.Post().Save(o2)).(*model.Post)
+ _ = store.Must(ss.Post().Save(o2)).(*model.Post)
o2a := &model.Post{}
o2a.ChannelId = c1.Id
o2a.UserId = u2.Id
o2a.CreateAt = o1.CreateAt + 30
o2a.Message = "zz" + model.NewId() + "b"
- o2a = store.Must(ss.Post().Save(o2a)).(*model.Post)
+ _ = store.Must(ss.Post().Save(o2a)).(*model.Post)
o3 := &model.Post{}
o3.ChannelId = cDM.Id
diff --git a/store/storetest/job_store.go b/store/storetest/job_store.go
index 631df08fd..936999f52 100644
--- a/store/storetest/job_store.go
+++ b/store/storetest/job_store.go
@@ -492,7 +492,6 @@ func testJobUpdateStatusUpdateStatusOptimistically(t *testing.T, ss store.Store)
if received.LastActivityAt <= lastUpdateAt {
t.Fatal("lastActivityAt wasn't updated")
}
- lastUpdateAt = received.LastActivityAt
}
}
diff --git a/store/storetest/mocks/ChannelStore.go b/store/storetest/mocks/ChannelStore.go
index 747a844ec..63f6bc6a9 100644
--- a/store/storetest/mocks/ChannelStore.go
+++ b/store/storetest/mocks/ChannelStore.go
@@ -61,6 +61,22 @@ func (_m *ChannelStore) AutocompleteInTeam(teamId string, term string, includeDe
return r0
}
+// AutocompleteInTeamForSearch provides a mock function with given fields: teamId, userId, term, includeDeleted
+func (_m *ChannelStore) AutocompleteInTeamForSearch(teamId string, userId string, term string, includeDeleted bool) store.StoreChannel {
+ ret := _m.Called(teamId, userId, term, includeDeleted)
+
+ var r0 store.StoreChannel
+ if rf, ok := ret.Get(0).(func(string, string, string, bool) store.StoreChannel); ok {
+ r0 = rf(teamId, userId, term, includeDeleted)
+ } else {
+ if ret.Get(0) != nil {
+ r0 = ret.Get(0).(store.StoreChannel)
+ }
+ }
+
+ return r0
+}
+
// ClearAllCustomRoleAssignments provides a mock function with given fields:
func (_m *ChannelStore) ClearAllCustomRoleAssignments() store.StoreChannel {
ret := _m.Called()
diff --git a/store/storetest/post_store.go b/store/storetest/post_store.go
index 235d6f9b7..72819f49e 100644
--- a/store/storetest/post_store.go
+++ b/store/storetest/post_store.go
@@ -514,7 +514,7 @@ func testPostStoreGetPostsWithDetails(t *testing.T, ss store.Store) {
o2.Message = "zz" + model.NewId() + "b"
o2.ParentId = o1.Id
o2.RootId = o1.Id
- o2 = (<-ss.Post().Save(o2)).Data.(*model.Post)
+ _ = (<-ss.Post().Save(o2)).Data.(*model.Post)
time.Sleep(2 * time.Millisecond)
o2a := &model.Post{}
@@ -609,7 +609,7 @@ func testPostStoreGetPostsWithDetails(t *testing.T, ss store.Store) {
o6.ChannelId = o1.ChannelId
o6.UserId = model.NewId()
o6.Message = "zz" + model.NewId() + "b"
- o6 = (<-ss.Post().Save(o6)).Data.(*model.Post)
+ _ = (<-ss.Post().Save(o6)).Data.(*model.Post)
// Should only be 6 since we hit the cache
r3 := (<-ss.Post().GetPosts(o1.ChannelId, 0, 30, true)).Data.(*model.PostList)
@@ -627,7 +627,7 @@ func testPostStoreGetPostsBeforeAfter(t *testing.T, ss store.Store) {
o0.ChannelId = model.NewId()
o0.UserId = model.NewId()
o0.Message = "zz" + model.NewId() + "b"
- o0 = (<-ss.Post().Save(o0)).Data.(*model.Post)
+ _ = (<-ss.Post().Save(o0)).Data.(*model.Post)
time.Sleep(2 * time.Millisecond)
o1 := &model.Post{}
@@ -677,7 +677,7 @@ func testPostStoreGetPostsBeforeAfter(t *testing.T, ss store.Store) {
o5.Message = "zz" + model.NewId() + "b"
o5.ParentId = o4.Id
o5.RootId = o4.Id
- o5 = (<-ss.Post().Save(o5)).Data.(*model.Post)
+ _ = (<-ss.Post().Save(o5)).Data.(*model.Post)
r1 := (<-ss.Post().GetPostsBefore(o1.ChannelId, o1.Id, 4, 0)).Data.(*model.PostList)
@@ -731,7 +731,7 @@ func testPostStoreGetPostsSince(t *testing.T, ss store.Store) {
o0.ChannelId = model.NewId()
o0.UserId = model.NewId()
o0.Message = "zz" + model.NewId() + "b"
- o0 = (<-ss.Post().Save(o0)).Data.(*model.Post)
+ _ = (<-ss.Post().Save(o0)).Data.(*model.Post)
time.Sleep(2 * time.Millisecond)
o1 := &model.Post{}
@@ -747,7 +747,7 @@ func testPostStoreGetPostsSince(t *testing.T, ss store.Store) {
o2.Message = "zz" + model.NewId() + "b"
o2.ParentId = o1.Id
o2.RootId = o1.Id
- o2 = (<-ss.Post().Save(o2)).Data.(*model.Post)
+ _ = (<-ss.Post().Save(o2)).Data.(*model.Post)
time.Sleep(2 * time.Millisecond)
o2a := &model.Post{}
@@ -865,7 +865,7 @@ func testPostStoreSearch(t *testing.T, ss store.Store) {
o1a.UserId = model.NewId()
o1a.Message = "corey mattermost new york"
o1a.Type = model.POST_JOIN_CHANNEL
- o1a = (<-ss.Post().Save(o1a)).Data.(*model.Post)
+ _ = (<-ss.Post().Save(o1a)).Data.(*model.Post)
o2 := &model.Post{}
o2.ChannelId = c1.Id
@@ -877,7 +877,7 @@ func testPostStoreSearch(t *testing.T, ss store.Store) {
o3.ChannelId = c2.Id
o3.UserId = model.NewId()
o3.Message = "New Jersey is where John is from corey new york"
- o3 = (<-ss.Post().Save(o3)).Data.(*model.Post)
+ _ = (<-ss.Post().Save(o3)).Data.(*model.Post)
o4 := &model.Post{}
o4.ChannelId = c1.Id
@@ -1045,7 +1045,7 @@ func testUserCountsWithPostsByDay(t *testing.T, ss store.Store) {
o1a.UserId = model.NewId()
o1a.CreateAt = o1.CreateAt
o1a.Message = "zz" + model.NewId() + "b"
- o1a = store.Must(ss.Post().Save(o1a)).(*model.Post)
+ _ = store.Must(ss.Post().Save(o1a)).(*model.Post)
o2 := &model.Post{}
o2.ChannelId = c1.Id
@@ -1059,7 +1059,7 @@ func testUserCountsWithPostsByDay(t *testing.T, ss store.Store) {
o2a.UserId = o2.UserId
o2a.CreateAt = o1.CreateAt - (1000 * 60 * 60 * 24)
o2a.Message = "zz" + model.NewId() + "b"
- o2a = store.Must(ss.Post().Save(o2a)).(*model.Post)
+ _ = store.Must(ss.Post().Save(o2a)).(*model.Post)
if r1 := <-ss.Post().AnalyticsUserCountsWithPostsByDay(t1.Id); r1.Err != nil {
t.Fatal(r1.Err)
@@ -1103,7 +1103,7 @@ func testPostCountsByDay(t *testing.T, ss store.Store) {
o1a.UserId = model.NewId()
o1a.CreateAt = o1.CreateAt
o1a.Message = "zz" + model.NewId() + "b"
- o1a = store.Must(ss.Post().Save(o1a)).(*model.Post)
+ _ = store.Must(ss.Post().Save(o1a)).(*model.Post)
o2 := &model.Post{}
o2.ChannelId = c1.Id
@@ -1117,7 +1117,7 @@ func testPostCountsByDay(t *testing.T, ss store.Store) {
o2a.UserId = o2.UserId
o2a.CreateAt = o1.CreateAt - (1000 * 60 * 60 * 24 * 2)
o2a.Message = "zz" + model.NewId() + "b"
- o2a = store.Must(ss.Post().Save(o2a)).(*model.Post)
+ _ = store.Must(ss.Post().Save(o2a)).(*model.Post)
time.Sleep(1 * time.Second)
@@ -1534,14 +1534,14 @@ func testPostStoreGetPostsCreatedAt(t *testing.T, ss store.Store) {
o2.ParentId = o1.Id
o2.RootId = o1.Id
o2.CreateAt = createTime + 1
- o2 = (<-ss.Post().Save(o2)).Data.(*model.Post)
+ _ = (<-ss.Post().Save(o2)).Data.(*model.Post)
o3 := &model.Post{}
o3.ChannelId = model.NewId()
o3.UserId = model.NewId()
o3.Message = "zz" + model.NewId() + "b"
o3.CreateAt = createTime
- o3 = (<-ss.Post().Save(o3)).Data.(*model.Post)
+ _ = (<-ss.Post().Save(o3)).Data.(*model.Post)
r1 := (<-ss.Post().GetPostsCreatedAt(o1.ChannelId, createTime)).Data.([]*model.Post)
assert.Equal(t, 2, len(r1))
diff --git a/store/storetest/scheme_store.go b/store/storetest/scheme_store.go
index f855ae5d4..a9204fbe2 100644
--- a/store/storetest/scheme_store.go
+++ b/store/storetest/scheme_store.go
@@ -20,6 +20,7 @@ func TestSchemeStore(t *testing.T, ss store.Store) {
t.Run("GetAllPage", func(t *testing.T) { testSchemeStoreGetAllPage(t, ss) })
t.Run("Delete", func(t *testing.T) { testSchemeStoreDelete(t, ss) })
t.Run("PermanentDeleteAll", func(t *testing.T) { testSchemeStorePermanentDeleteAll(t, ss) })
+ t.Run("GetByName", func(t *testing.T) { testSchemeStoreGetByName(t, ss) })
}
func createDefaultRoles(t *testing.T, ss store.Store) {
diff --git a/store/storetest/team_store.go b/store/storetest/team_store.go
index ede1a91d3..1369dc69b 100644
--- a/store/storetest/team_store.go
+++ b/store/storetest/team_store.go
@@ -1088,9 +1088,9 @@ func testGetTeamsByScheme(t *testing.T, ss store.Store) {
Type: model.TEAM_OPEN,
}
- t1 = (<-ss.Team().Save(t1)).Data.(*model.Team)
- t2 = (<-ss.Team().Save(t2)).Data.(*model.Team)
- t3 = (<-ss.Team().Save(t3)).Data.(*model.Team)
+ _ = (<-ss.Team().Save(t1)).Data.(*model.Team)
+ _ = (<-ss.Team().Save(t2)).Data.(*model.Team)
+ _ = (<-ss.Team().Save(t3)).Data.(*model.Team)
// Get the teams by a valid Scheme ID.
res1 := <-ss.Team().GetTeamsByScheme(s1.Id, 0, 100)
@@ -1286,7 +1286,7 @@ func testTeamStoreAnalyticsGetTeamCountForScheme(t *testing.T, ss store.Store) {
Type: model.TEAM_OPEN,
SchemeId: &s1.Id,
}
- t1 = (<-ss.Team().Save(t1)).Data.(*model.Team)
+ _ = (<-ss.Team().Save(t1)).Data.(*model.Team)
count2 := (<-ss.Team().AnalyticsGetTeamCountForScheme(s1.Id)).Data.(int64)
assert.Equal(t, int64(1), count2)
@@ -1298,7 +1298,7 @@ func testTeamStoreAnalyticsGetTeamCountForScheme(t *testing.T, ss store.Store) {
Type: model.TEAM_OPEN,
SchemeId: &s1.Id,
}
- t2 = (<-ss.Team().Save(t2)).Data.(*model.Team)
+ _ = (<-ss.Team().Save(t2)).Data.(*model.Team)
count3 := (<-ss.Team().AnalyticsGetTeamCountForScheme(s1.Id)).Data.(int64)
assert.Equal(t, int64(2), count3)
@@ -1309,7 +1309,7 @@ func testTeamStoreAnalyticsGetTeamCountForScheme(t *testing.T, ss store.Store) {
Email: MakeEmail(),
Type: model.TEAM_OPEN,
}
- t3 = (<-ss.Team().Save(t3)).Data.(*model.Team)
+ _ = (<-ss.Team().Save(t3)).Data.(*model.Team)
count4 := (<-ss.Team().AnalyticsGetTeamCountForScheme(s1.Id)).Data.(int64)
assert.Equal(t, int64(2), count4)
@@ -1322,7 +1322,7 @@ func testTeamStoreAnalyticsGetTeamCountForScheme(t *testing.T, ss store.Store) {
SchemeId: &s1.Id,
DeleteAt: model.GetMillis(),
}
- t4 = (<-ss.Team().Save(t4)).Data.(*model.Team)
+ _ = (<-ss.Team().Save(t4)).Data.(*model.Team)
count5 := (<-ss.Team().AnalyticsGetTeamCountForScheme(s1.Id)).Data.(int64)
assert.Equal(t, int64(2), count5)
diff --git a/store/storetest/webhook_store.go b/store/storetest/webhook_store.go
index 2dfa2ae53..2b30f2d33 100644
--- a/store/storetest/webhook_store.go
+++ b/store/storetest/webhook_store.go
@@ -484,7 +484,7 @@ func testWebhookStoreCountIncoming(t *testing.T, ss store.Store) {
o1.UserId = model.NewId()
o1.TeamId = model.NewId()
- o1 = (<-ss.Webhook().SaveIncoming(o1)).Data.(*model.IncomingWebhook)
+ _ = (<-ss.Webhook().SaveIncoming(o1)).Data.(*model.IncomingWebhook)
if r := <-ss.Webhook().AnalyticsIncomingCount(""); r.Err != nil {
t.Fatal(r.Err)
@@ -502,7 +502,7 @@ func testWebhookStoreCountOutgoing(t *testing.T, ss store.Store) {
o1.TeamId = model.NewId()
o1.CallbackURLs = []string{"http://nowhere.com/"}
- o1 = (<-ss.Webhook().SaveOutgoing(o1)).Data.(*model.OutgoingWebhook)
+ _ = (<-ss.Webhook().SaveOutgoing(o1)).Data.(*model.OutgoingWebhook)
if r := <-ss.Webhook().AnalyticsOutgoingCount(""); r.Err != nil {
t.Fatal(r.Err)