mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Merge branch 'master' into mark-as-unread
This commit is contained in:
@@ -191,7 +191,7 @@ func (s *SqlPostStore) GetFlaggedPosts(userId string, offset int, limit int) (*m
|
||||
pl := model.NewPostList()
|
||||
|
||||
var posts []*model.Post
|
||||
if _, err := s.GetReplica().Select(&posts, "SELECT * FROM Posts WHERE Id IN (SELECT Name FROM Preferences WHERE UserId = :UserId AND Category = :Category) AND DeleteAt = 0 ORDER BY CreateAt DESC LIMIT :Limit OFFSET :Offset", map[string]interface{}{"UserId": userId, "Category": model.PREFERENCE_CATEGORY_FLAGGED_POST, "Offset": offset, "Limit": limit}); err != nil {
|
||||
if _, err := s.GetReplica().Select(&posts, "SELECT *, (SELECT count(Posts.Id) FROM Posts WHERE Posts.RootId = p.Id AND Posts.DeleteAt = 0) as ReplyCount FROM Posts p WHERE Id IN (SELECT Name FROM Preferences WHERE UserId = :UserId AND Category = :Category) AND DeleteAt = 0 ORDER BY CreateAt DESC LIMIT :Limit OFFSET :Offset", map[string]interface{}{"UserId": userId, "Category": model.PREFERENCE_CATEGORY_FLAGGED_POST, "Offset": offset, "Limit": limit}); err != nil {
|
||||
return nil, model.NewAppError("SqlPostStore.GetFlaggedPosts", "store.sql_post.get_flagged_posts.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
@@ -210,7 +210,7 @@ func (s *SqlPostStore) GetFlaggedPostsForTeam(userId, teamId string, offset int,
|
||||
|
||||
query := `
|
||||
SELECT
|
||||
A.*
|
||||
A.*, (SELECT count(Posts.Id) FROM Posts WHERE Posts.RootId = A.Id AND Posts.DeleteAt = 0) as ReplyCount
|
||||
FROM
|
||||
(SELECT
|
||||
*
|
||||
@@ -252,8 +252,8 @@ func (s *SqlPostStore) GetFlaggedPostsForChannel(userId, channelId string, offse
|
||||
var posts []*model.Post
|
||||
query := `
|
||||
SELECT
|
||||
*
|
||||
FROM Posts
|
||||
*, (SELECT count(Posts.Id) FROM Posts WHERE Posts.RootId = p.Id AND Posts.DeleteAt = 0) as ReplyCount
|
||||
FROM Posts p
|
||||
WHERE
|
||||
Id IN (SELECT Name FROM Preferences WHERE UserId = :UserId AND Category = :Category)
|
||||
AND ChannelId = :ChannelId
|
||||
@@ -280,12 +280,7 @@ func (s *SqlPostStore) Get(id string, skipFetchThreads bool) (*model.PostList, *
|
||||
}
|
||||
|
||||
var post model.Post
|
||||
var postFetchQuery string
|
||||
if skipFetchThreads {
|
||||
postFetchQuery = "SELECT p.*, (SELECT count(Posts.Id) FROM Posts WHERE Posts.RootId = p.Id) as ReplyCount FROM Posts p WHERE p.Id = :Id AND p.DeleteAt = 0"
|
||||
} else {
|
||||
postFetchQuery = "SELECT * FROM Posts WHERE Id = :Id AND DeleteAt = 0"
|
||||
}
|
||||
postFetchQuery := "SELECT p.*, (SELECT count(Posts.Id) FROM Posts WHERE Posts.RootId = p.Id AND Posts.DeleteAt = 0) as ReplyCount FROM Posts p WHERE p.Id = :Id AND p.DeleteAt = 0"
|
||||
err := s.GetReplica().SelectOne(&post, postFetchQuery, map[string]interface{}{"Id": id})
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("SqlPostStore.GetPost", "store.sql_post.get.app_error", nil, "id="+id+err.Error(), http.StatusNotFound)
|
||||
@@ -304,7 +299,7 @@ func (s *SqlPostStore) Get(id string, skipFetchThreads bool) (*model.PostList, *
|
||||
}
|
||||
|
||||
var posts []*model.Post
|
||||
_, err = s.GetReplica().Select(&posts, "SELECT * FROM Posts WHERE (Id = :Id OR RootId = :RootId) AND DeleteAt = 0", map[string]interface{}{"Id": rootId, "RootId": rootId})
|
||||
_, err = s.GetReplica().Select(&posts, "SELECT *, (SELECT count(Id) FROM Posts WHERE RootId = p.Id AND Posts.DeleteAt = 0) as ReplyCount FROM Posts p WHERE (Id = :Id OR RootId = :RootId) AND DeleteAt = 0", map[string]interface{}{"Id": rootId, "RootId": rootId})
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("SqlPostStore.GetPost", "store.sql_post.get.app_error", nil, "root_id="+rootId+err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -545,8 +540,8 @@ func (s *SqlPostStore) GetPostsSince(options model.GetPostsSinceOptions, allowFr
|
||||
replyCountQuery1 := ""
|
||||
replyCountQuery2 := ""
|
||||
if options.SkipFetchThreads {
|
||||
replyCountQuery1 = ` ,(SELECT COUNT(Posts.Id) FROM Posts WHERE p1.RootId = '' AND Posts.RootId = p1.Id) as ReplyCount`
|
||||
replyCountQuery2 = ` ,(SELECT COUNT(Posts.Id) FROM Posts WHERE p2.RootId = '' AND Posts.RootId = p2.Id) as ReplyCount`
|
||||
replyCountQuery1 = ` ,(SELECT COUNT(Posts.Id) FROM Posts WHERE p1.RootId = '' AND Posts.RootId = p1.Id AND Posts.DeleteAt = 0) as ReplyCount`
|
||||
replyCountQuery2 = ` ,(SELECT COUNT(Posts.Id) FROM Posts WHERE p2.RootId = '' AND Posts.RootId = p2.Id AND Posts.DeleteAt = 0) as ReplyCount`
|
||||
}
|
||||
|
||||
_, err := s.GetReplica().Select(&posts,
|
||||
@@ -621,7 +616,7 @@ func (s *SqlPostStore) getPostsAround(before bool, options model.GetPostsOptions
|
||||
direction = ">"
|
||||
sort = "ASC"
|
||||
}
|
||||
replyCountSubQuery := s.getQueryBuilder().Select("COUNT(Posts.Id)").From("Posts").Where(sq.Expr("p.RootId = '' AND RootId = p.Id"))
|
||||
replyCountSubQuery := s.getQueryBuilder().Select("COUNT(Posts.Id)").From("Posts").Where(sq.Expr("p.RootId = '' AND RootId = p.Id AND DeleteAt = 0"))
|
||||
query := s.getQueryBuilder().Select("p.*")
|
||||
if options.SkipFetchThreads {
|
||||
query = query.Column(sq.Alias(replyCountSubQuery, "ReplyCount"))
|
||||
@@ -782,7 +777,7 @@ func (s *SqlPostStore) getRootPosts(channelId string, offset int, limit int, ski
|
||||
var posts []*model.Post
|
||||
var fetchQuery string
|
||||
if skipFetchThreads {
|
||||
fetchQuery = "SELECT p.*, (SELECT COUNT(Posts.Id) FROM Posts WHERE p.RootId = '' AND Posts.RootId = p.Id) as ReplyCount FROM Posts p WHERE ChannelId = :ChannelId AND DeleteAt = 0 ORDER BY CreateAt DESC LIMIT :Limit OFFSET :Offset"
|
||||
fetchQuery = "SELECT p.*, (SELECT COUNT(Posts.Id) FROM Posts WHERE p.RootId = '' AND Posts.RootId = p.Id AND Posts.DeleteAt = 0) as ReplyCount FROM Posts p WHERE ChannelId = :ChannelId AND DeleteAt = 0 ORDER BY CreateAt DESC LIMIT :Limit OFFSET :Offset"
|
||||
} else {
|
||||
fetchQuery = "SELECT * FROM Posts WHERE ChannelId = :ChannelId AND DeleteAt = 0 ORDER BY CreateAt DESC LIMIT :Limit OFFSET :Offset"
|
||||
}
|
||||
@@ -798,7 +793,7 @@ func (s *SqlPostStore) getParentsPosts(channelId string, offset int, limit int,
|
||||
replyCountQuery := ""
|
||||
onStatement := "q1.RootId = q2.Id"
|
||||
if skipFetchThreads {
|
||||
replyCountQuery = ` ,(SELECT COUNT(Posts.Id) FROM Posts WHERE q2.RootId = '' AND Posts.RootId = q2.Id) as ReplyCount`
|
||||
replyCountQuery = ` ,(SELECT COUNT(Posts.Id) FROM Posts WHERE q2.RootId = '' AND Posts.RootId = q2.Id AND Posts.DeleteAt = 0) as ReplyCount`
|
||||
} else {
|
||||
onStatement += " OR q1.RootId = q2.RootId"
|
||||
}
|
||||
@@ -988,9 +983,9 @@ func (s *SqlPostStore) Search(teamId string, userId string, params *model.Search
|
||||
|
||||
searchQuery := `
|
||||
SELECT
|
||||
*
|
||||
* ,(SELECT COUNT(Posts.Id) FROM Posts WHERE q2.RootId = '' AND Posts.RootId = q2.Id AND Posts.DeleteAt = 0) as ReplyCount
|
||||
FROM
|
||||
Posts
|
||||
Posts q2
|
||||
WHERE
|
||||
DeleteAt = 0
|
||||
AND Type NOT LIKE '` + model.POST_SYSTEM_MESSAGE_PREFIX + `%'
|
||||
|
||||
@@ -713,17 +713,6 @@ func UpgradeDatabaseToVersion513(sqlStore SqlStore) {
|
||||
|
||||
func UpgradeDatabaseToVersion514(sqlStore SqlStore) {
|
||||
if shouldPerformUpgrade(sqlStore, VERSION_5_13_0, VERSION_5_14_0) {
|
||||
sqlStore.AlterColumnTypeIfExists("TeamMembers", "SchemeGuest", "tinyint(4)", "boolean")
|
||||
sqlStore.AlterColumnTypeIfExists("ChannelMembers", "SchemeGuest", "tinyint(4)", "boolean")
|
||||
sqlStore.AlterColumnTypeIfExists("Schemes", "DefaultTeamGuestRole", "varchar(64)", "VARCHAR(64)")
|
||||
sqlStore.AlterColumnTypeIfExists("Schemes", "DefaultChannelGuestRole", "varchar(64)", "VARCHAR(64)")
|
||||
sqlStore.AlterColumnTypeIfExists("Teams", "AllowedDomains", "text", "VARCHAR(1000)")
|
||||
sqlStore.AlterColumnTypeIfExists("Channels", "GroupConstrained", "tinyint(1)", "boolean")
|
||||
sqlStore.AlterColumnTypeIfExists("Teams", "GroupConstrained", "tinyint(1)", "boolean")
|
||||
|
||||
sqlStore.CreateIndexIfNotExists("idx_groupteams_teamid", "GroupTeams", "TeamId")
|
||||
sqlStore.CreateIndexIfNotExists("idx_groupchannels_channelid", "GroupChannels", "ChannelId")
|
||||
|
||||
saveSchemaVersion(sqlStore, VERSION_5_14_0)
|
||||
}
|
||||
}
|
||||
@@ -742,5 +731,21 @@ func UpgradeDatabaseToVersion516(sqlStore SqlStore) {
|
||||
sqlStore.GetMaster().Exec("ALTER TABLE Tokens MODIFY Extra text")
|
||||
}
|
||||
saveSchemaVersion(sqlStore, VERSION_5_16_0)
|
||||
|
||||
// Fix mismatches between the canonical and migrated schemas.
|
||||
sqlStore.AlterColumnTypeIfExists("TeamMembers", "SchemeGuest", "tinyint(4)", "boolean")
|
||||
sqlStore.AlterColumnTypeIfExists("Schemes", "DefaultTeamGuestRole", "varchar(64)", "VARCHAR(64)")
|
||||
sqlStore.AlterColumnTypeIfExists("Schemes", "DefaultChannelGuestRole", "varchar(64)", "VARCHAR(64)")
|
||||
sqlStore.AlterColumnTypeIfExists("Teams", "AllowedDomains", "text", "VARCHAR(1000)")
|
||||
sqlStore.AlterColumnTypeIfExists("Channels", "GroupConstrained", "tinyint(1)", "boolean")
|
||||
sqlStore.AlterColumnTypeIfExists("Teams", "GroupConstrained", "tinyint(1)", "boolean")
|
||||
|
||||
// One known mismatch remains: ChannelMembers.SchemeGuest. The requisite migration
|
||||
// is left here for posterity, but we're avoiding fix this given the corresponding
|
||||
// table rewrite in most MySQL and Postgres instances.
|
||||
// sqlStore.AlterColumnTypeIfExists("ChannelMembers", "SchemeGuest", "tinyint(4)", "boolean")
|
||||
|
||||
sqlStore.CreateIndexIfNotExists("idx_groupteams_teamid", "GroupTeams", "TeamId")
|
||||
sqlStore.CreateIndexIfNotExists("idx_groupchannels_channelid", "GroupChannels", "ChannelId")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2018,7 +2018,7 @@ func testGetGroups(t *testing.T, ss store.Store) {
|
||||
require.Nil(t, err)
|
||||
|
||||
group2, err := ss.Group().Create(&model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewId() + "-group-2",
|
||||
DisplayName: "group-2",
|
||||
RemoteId: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
@@ -2062,7 +2062,7 @@ func testGetGroups(t *testing.T, ss store.Store) {
|
||||
|
||||
// Create Group3
|
||||
group3, err := ss.Group().Create(&model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewId() + "-group-3",
|
||||
DisplayName: "group-3",
|
||||
RemoteId: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
@@ -2122,7 +2122,7 @@ func testGetGroups(t *testing.T, ss store.Store) {
|
||||
user2.DeleteAt = 1
|
||||
ss.User().Update(user2, true)
|
||||
|
||||
group2NameSubstring := string([]rune(group2.Name)[2:5])
|
||||
group2NameSubstring := "group-2"
|
||||
|
||||
testCases := []struct {
|
||||
Name string
|
||||
|
||||
@@ -34,9 +34,8 @@ func testSessionStoreSave(t *testing.T, ss store.Store) {
|
||||
s1 := &model.Session{}
|
||||
s1.UserId = model.NewId()
|
||||
|
||||
if _, err := ss.Session().Save(s1); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
_, err := ss.Session().Save(s1)
|
||||
require.Nil(t, err)
|
||||
}
|
||||
|
||||
func testSessionGet(t *testing.T, ss store.Store) {
|
||||
@@ -59,21 +58,13 @@ func testSessionGet(t *testing.T, ss store.Store) {
|
||||
s3, err = ss.Session().Save(s3)
|
||||
require.Nil(t, err)
|
||||
|
||||
if session, err := ss.Session().Get(s1.Id); err != nil {
|
||||
t.Fatal(err)
|
||||
} else {
|
||||
if session.Id != s1.Id {
|
||||
t.Fatal("should match")
|
||||
}
|
||||
}
|
||||
session, err := ss.Session().Get(s1.Id)
|
||||
require.Nil(t, err)
|
||||
require.Equal(t, session.Id, s1.Id, "should match")
|
||||
|
||||
if session, err := ss.Session().GetSessions(s1.UserId); err != nil {
|
||||
t.Fatal(err)
|
||||
} else {
|
||||
if len(session) != 3 {
|
||||
t.Fatal("should match len")
|
||||
}
|
||||
}
|
||||
data, err := ss.Session().GetSessions(s1.UserId)
|
||||
require.Nil(t, err)
|
||||
require.Len(t, data, 3, "should match len")
|
||||
}
|
||||
|
||||
func testSessionGetWithDeviceId(t *testing.T, ss store.Store) {
|
||||
@@ -100,13 +91,9 @@ func testSessionGetWithDeviceId(t *testing.T, ss store.Store) {
|
||||
s3, err = ss.Session().Save(s3)
|
||||
require.Nil(t, err)
|
||||
|
||||
if data, err := ss.Session().GetSessionsWithActiveDeviceIds(s1.UserId); err != nil {
|
||||
t.Fatal(err)
|
||||
} else {
|
||||
if len(data) != 1 {
|
||||
t.Fatal("should match len")
|
||||
}
|
||||
}
|
||||
data, err := ss.Session().GetSessionsWithActiveDeviceIds(s1.UserId)
|
||||
require.Nil(t, err)
|
||||
require.Len(t, data, 1, "should match len")
|
||||
}
|
||||
|
||||
func testSessionRemove(t *testing.T, ss store.Store) {
|
||||
@@ -116,19 +103,15 @@ func testSessionRemove(t *testing.T, ss store.Store) {
|
||||
s1, err := ss.Session().Save(s1)
|
||||
require.Nil(t, err)
|
||||
|
||||
if session, err := ss.Session().Get(s1.Id); err != nil {
|
||||
t.Fatal(err)
|
||||
} else {
|
||||
if session.Id != s1.Id {
|
||||
t.Fatal("should match")
|
||||
}
|
||||
}
|
||||
session, err := ss.Session().Get(s1.Id)
|
||||
require.Nil(t, err)
|
||||
require.Equal(t, session.Id, s1.Id, "should match")
|
||||
|
||||
removeErr := ss.Session().Remove(s1.Id)
|
||||
require.Nil(t, removeErr)
|
||||
if _, err := ss.Session().Get(s1.Id); err == nil {
|
||||
t.Fatal("should have been removed")
|
||||
}
|
||||
|
||||
_, err = ss.Session().Get(s1.Id)
|
||||
require.NotNil(t, err, "should have been removed")
|
||||
}
|
||||
|
||||
func testSessionRemoveAll(t *testing.T, ss store.Store) {
|
||||
@@ -138,20 +121,15 @@ func testSessionRemoveAll(t *testing.T, ss store.Store) {
|
||||
s1, err := ss.Session().Save(s1)
|
||||
require.Nil(t, err)
|
||||
|
||||
if session, err := ss.Session().Get(s1.Id); err != nil {
|
||||
t.Fatal(err)
|
||||
} else {
|
||||
if session.Id != s1.Id {
|
||||
t.Fatal("should match")
|
||||
}
|
||||
}
|
||||
session, err := ss.Session().Get(s1.Id)
|
||||
require.Nil(t, err)
|
||||
require.Equal(t, session.Id, s1.Id, "should match")
|
||||
|
||||
removeErr := ss.Session().RemoveAllSessions()
|
||||
require.Nil(t, removeErr)
|
||||
|
||||
if _, err := ss.Session().Get(s1.Id); err == nil {
|
||||
t.Fatal("should have been removed")
|
||||
}
|
||||
_, err = ss.Session().Get(s1.Id)
|
||||
require.NotNil(t, err, "should have been removed")
|
||||
}
|
||||
|
||||
func testSessionRemoveByUser(t *testing.T, ss store.Store) {
|
||||
@@ -161,20 +139,15 @@ func testSessionRemoveByUser(t *testing.T, ss store.Store) {
|
||||
s1, err := ss.Session().Save(s1)
|
||||
require.Nil(t, err)
|
||||
|
||||
if session, err := ss.Session().Get(s1.Id); err != nil {
|
||||
t.Fatal(err)
|
||||
} else {
|
||||
if session.Id != s1.Id {
|
||||
t.Fatal("should match")
|
||||
}
|
||||
}
|
||||
session, err := ss.Session().Get(s1.Id)
|
||||
require.Nil(t, err)
|
||||
require.Equal(t, session.Id, s1.Id, "should match")
|
||||
|
||||
deleteErr := ss.Session().PermanentDeleteSessionsByUser(s1.UserId)
|
||||
require.Nil(t, deleteErr)
|
||||
|
||||
if _, err := ss.Session().Get(s1.Id); err == nil {
|
||||
t.Fatal("should have been removed")
|
||||
}
|
||||
_, err = ss.Session().Get(s1.Id)
|
||||
require.NotNil(t, err, "should have been removed")
|
||||
}
|
||||
|
||||
func testSessionRemoveToken(t *testing.T, ss store.Store) {
|
||||
@@ -184,28 +157,19 @@ func testSessionRemoveToken(t *testing.T, ss store.Store) {
|
||||
s1, err := ss.Session().Save(s1)
|
||||
require.Nil(t, err)
|
||||
|
||||
if session, err := ss.Session().Get(s1.Id); err != nil {
|
||||
t.Fatal(err)
|
||||
} else {
|
||||
if session.Id != s1.Id {
|
||||
t.Fatal("should match")
|
||||
}
|
||||
}
|
||||
session, err := ss.Session().Get(s1.Id)
|
||||
require.Nil(t, err)
|
||||
require.Equal(t, session.Id, s1.Id, "should match")
|
||||
|
||||
removeErr := ss.Session().Remove(s1.Token)
|
||||
require.Nil(t, removeErr)
|
||||
|
||||
if _, err := ss.Session().Get(s1.Id); err == nil {
|
||||
t.Fatal("should have been removed")
|
||||
}
|
||||
_, err = ss.Session().Get(s1.Id)
|
||||
require.NotNil(t, err, "should have been removed")
|
||||
|
||||
if session, err := ss.Session().GetSessions(s1.UserId); err != nil {
|
||||
t.Fatal(err)
|
||||
} else {
|
||||
if len(session) != 0 {
|
||||
t.Fatal("should match len")
|
||||
}
|
||||
}
|
||||
data, err := ss.Session().GetSessions(s1.UserId)
|
||||
require.Nil(t, err)
|
||||
require.Len(t, data, 0, "should match len")
|
||||
}
|
||||
|
||||
func testSessionUpdateDeviceId(t *testing.T, ss store.Store) {
|
||||
@@ -215,9 +179,8 @@ func testSessionUpdateDeviceId(t *testing.T, ss store.Store) {
|
||||
s1, err := ss.Session().Save(s1)
|
||||
require.Nil(t, err)
|
||||
|
||||
if _, err = ss.Session().UpdateDeviceId(s1.Id, model.PUSH_NOTIFY_APPLE+":1234567890", s1.ExpiresAt); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
_, err = ss.Session().UpdateDeviceId(s1.Id, model.PUSH_NOTIFY_APPLE+":1234567890", s1.ExpiresAt)
|
||||
require.Nil(t, err)
|
||||
|
||||
s2 := &model.Session{}
|
||||
s2.UserId = model.NewId()
|
||||
@@ -225,9 +188,8 @@ func testSessionUpdateDeviceId(t *testing.T, ss store.Store) {
|
||||
s2, err = ss.Session().Save(s2)
|
||||
require.Nil(t, err)
|
||||
|
||||
if _, err := ss.Session().UpdateDeviceId(s2.Id, model.PUSH_NOTIFY_APPLE+":1234567890", s1.ExpiresAt); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
_, err = ss.Session().UpdateDeviceId(s2.Id, model.PUSH_NOTIFY_APPLE+":1234567890", s1.ExpiresAt)
|
||||
require.Nil(t, err)
|
||||
}
|
||||
|
||||
func testSessionUpdateDeviceId2(t *testing.T, ss store.Store) {
|
||||
@@ -237,9 +199,8 @@ func testSessionUpdateDeviceId2(t *testing.T, ss store.Store) {
|
||||
s1, err := ss.Session().Save(s1)
|
||||
require.Nil(t, err)
|
||||
|
||||
if _, err = ss.Session().UpdateDeviceId(s1.Id, model.PUSH_NOTIFY_APPLE_REACT_NATIVE+":1234567890", s1.ExpiresAt); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
_, err = ss.Session().UpdateDeviceId(s1.Id, model.PUSH_NOTIFY_APPLE_REACT_NATIVE+":1234567890", s1.ExpiresAt)
|
||||
require.Nil(t, err)
|
||||
|
||||
s2 := &model.Session{}
|
||||
s2.UserId = model.NewId()
|
||||
@@ -247,9 +208,8 @@ func testSessionUpdateDeviceId2(t *testing.T, ss store.Store) {
|
||||
s2, err = ss.Session().Save(s2)
|
||||
require.Nil(t, err)
|
||||
|
||||
if _, err := ss.Session().UpdateDeviceId(s2.Id, model.PUSH_NOTIFY_APPLE_REACT_NATIVE+":1234567890", s1.ExpiresAt); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
_, err = ss.Session().UpdateDeviceId(s2.Id, model.PUSH_NOTIFY_APPLE_REACT_NATIVE+":1234567890", s1.ExpiresAt)
|
||||
require.Nil(t, err)
|
||||
}
|
||||
|
||||
func testSessionStoreUpdateLastActivityAt(t *testing.T, ss store.Store) {
|
||||
@@ -262,14 +222,9 @@ func testSessionStoreUpdateLastActivityAt(t *testing.T, ss store.Store) {
|
||||
err = ss.Session().UpdateLastActivityAt(s1.Id, 1234567890)
|
||||
require.Nil(t, err)
|
||||
|
||||
if session, err := ss.Session().Get(s1.Id); err != nil {
|
||||
t.Fatal(err)
|
||||
} else {
|
||||
if session.LastActivityAt != 1234567890 {
|
||||
t.Fatal("LastActivityAt not updated correctly")
|
||||
}
|
||||
}
|
||||
|
||||
session, err := ss.Session().Get(s1.Id)
|
||||
require.Nil(t, err)
|
||||
require.EqualValues(t, session.LastActivityAt, 1234567890, "LastActivityAt not updated correctly")
|
||||
}
|
||||
|
||||
func testSessionCount(t *testing.T, ss store.Store) {
|
||||
@@ -280,13 +235,9 @@ func testSessionCount(t *testing.T, ss store.Store) {
|
||||
s1, err := ss.Session().Save(s1)
|
||||
require.Nil(t, err)
|
||||
|
||||
if count, err := ss.Session().AnalyticsSessionCount(); err != nil {
|
||||
t.Fatal(err)
|
||||
} else {
|
||||
if count == 0 {
|
||||
t.Fatal("should have at least 1 session")
|
||||
}
|
||||
}
|
||||
count, err := ss.Session().AnalyticsSessionCount()
|
||||
require.Nil(t, err)
|
||||
require.NotZero(t, count, "should have at least 1 session")
|
||||
}
|
||||
|
||||
func testSessionCleanup(t *testing.T, ss store.Store) {
|
||||
|
||||
Reference in New Issue
Block a user