[MM-61102] Fix errcheck issues in server/channels/app/channel_bookmark_test.go (#28789)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
3eb95af974
Коммит
a5a92d825a
@@ -82,7 +82,6 @@ issues:
|
||||
channels/api4/websocket_test.go|\
|
||||
channels/app/bot_test.go|\
|
||||
channels/app/brand.go|\
|
||||
channels/app/channel_bookmark_test.go|\
|
||||
channels/app/config_test.go|\
|
||||
channels/app/export.go|\
|
||||
channels/app/export_test.go|\
|
||||
|
||||
@@ -102,12 +102,16 @@ func TestUpdateBookmark(t *testing.T) {
|
||||
HasPreviewImage: true,
|
||||
}
|
||||
|
||||
th.App.Srv().Store().FileInfo().Save(th.Context, file)
|
||||
defer th.App.Srv().Store().FileInfo().PermanentDelete(th.Context, file.Id)
|
||||
_, err := th.App.Srv().Store().FileInfo().Save(th.Context, file)
|
||||
assert.NoError(t, err)
|
||||
defer func() {
|
||||
err = th.App.Srv().Store().FileInfo().PermanentDelete(th.Context, file.Id)
|
||||
assert.NoError(t, err)
|
||||
}()
|
||||
|
||||
bookmark2 := createBookmark("File to be updated", model.ChannelBookmarkFile, th.BasicChannel.Id, file.Id)
|
||||
bookmarkResp, err := th.App.CreateChannelBookmark(th.Context, bookmark2, "")
|
||||
require.Nil(t, err)
|
||||
bookmarkResp, appErr := th.App.CreateChannelBookmark(th.Context, bookmark2, "")
|
||||
require.Nil(t, appErr)
|
||||
require.NotNil(t, bookmarkResp)
|
||||
|
||||
file2 := &model.FileInfo{
|
||||
@@ -125,13 +129,18 @@ func TestUpdateBookmark(t *testing.T) {
|
||||
HasPreviewImage: true,
|
||||
}
|
||||
|
||||
th.App.Srv().Store().FileInfo().Save(th.Context, file2)
|
||||
th.App.Srv().Store().FileInfo().AttachToPost(th.Context, file2.Id, model.NewId(), th.BasicChannel.Id, model.BookmarkFileOwner)
|
||||
defer th.App.Srv().Store().FileInfo().PermanentDelete(th.Context, file2.Id)
|
||||
_, err = th.App.Srv().Store().FileInfo().Save(th.Context, file2)
|
||||
assert.NoError(t, err)
|
||||
err = th.App.Srv().Store().FileInfo().AttachToPost(th.Context, file2.Id, model.NewId(), th.BasicChannel.Id, model.BookmarkFileOwner)
|
||||
assert.NoError(t, err)
|
||||
defer func() {
|
||||
err = th.App.Srv().Store().FileInfo().PermanentDelete(th.Context, file2.Id)
|
||||
require.NoError(t, err)
|
||||
}()
|
||||
|
||||
bookmark2.FileId = file2.Id
|
||||
bookmarkResp, err = th.App.CreateChannelBookmark(th.Context, bookmark2, "")
|
||||
require.NotNil(t, err)
|
||||
bookmarkResp, appErr = th.App.CreateChannelBookmark(th.Context, bookmark2, "")
|
||||
require.NotNil(t, appErr)
|
||||
require.Nil(t, bookmarkResp)
|
||||
}
|
||||
|
||||
@@ -251,7 +260,8 @@ func TestGetChannelBookmarks(t *testing.T) {
|
||||
Emoji: ":smile:",
|
||||
}
|
||||
|
||||
th.App.CreateChannelBookmark(th.Context, bookmark1, "")
|
||||
_, appErr := th.App.CreateChannelBookmark(th.Context, bookmark1, "")
|
||||
assert.Nil(t, appErr)
|
||||
|
||||
file := &model.FileInfo{
|
||||
Id: model.NewId(),
|
||||
@@ -268,8 +278,12 @@ func TestGetChannelBookmarks(t *testing.T) {
|
||||
HasPreviewImage: true,
|
||||
}
|
||||
|
||||
th.App.Srv().Store().FileInfo().Save(th.Context, file)
|
||||
defer th.App.Srv().Store().FileInfo().PermanentDelete(th.Context, file.Id)
|
||||
_, err := th.App.Srv().Store().FileInfo().Save(th.Context, file)
|
||||
assert.NoError(t, err)
|
||||
defer func() {
|
||||
err := th.App.Srv().Store().FileInfo().PermanentDelete(th.Context, file.Id)
|
||||
assert.NoError(t, err)
|
||||
}()
|
||||
|
||||
bookmark2 := &model.ChannelBookmark{
|
||||
ChannelId: th.BasicChannel.Id,
|
||||
@@ -279,7 +293,8 @@ func TestGetChannelBookmarks(t *testing.T) {
|
||||
Emoji: ":smile:",
|
||||
}
|
||||
|
||||
th.App.CreateChannelBookmark(th.Context, bookmark2, "")
|
||||
_, appErr = th.App.CreateChannelBookmark(th.Context, bookmark2, "")
|
||||
assert.Nil(t, appErr)
|
||||
|
||||
t.Run("get bookmarks of a channel", func(t *testing.T) {
|
||||
bookmarks, err := th.App.GetChannelBookmarks(th.BasicChannel.Id, 0)
|
||||
@@ -290,7 +305,8 @@ func TestGetChannelBookmarks(t *testing.T) {
|
||||
|
||||
t.Run("get bookmarks of a channel after one is deleted (aka only return the changed bookmarks)", func(t *testing.T) {
|
||||
now := model.GetMillis()
|
||||
th.App.DeleteChannelBookmark(bookmark1.Id, "")
|
||||
_, appErr := th.App.DeleteChannelBookmark(bookmark1.Id, "")
|
||||
assert.Nil(t, appErr)
|
||||
|
||||
bookmarks, err := th.App.GetChannelBookmarks(th.BasicChannel.Id, 0)
|
||||
require.Nil(t, err)
|
||||
@@ -353,7 +369,10 @@ func TestUpdateChannelBookmarkSortOrder(t *testing.T) {
|
||||
|
||||
_, err := th.App.Srv().Store().FileInfo().Save(th.Context, file)
|
||||
require.NoError(t, err)
|
||||
defer th.App.Srv().Store().FileInfo().PermanentDelete(th.Context, file.Id)
|
||||
defer func() {
|
||||
err = th.App.Srv().Store().FileInfo().PermanentDelete(th.Context, file.Id)
|
||||
require.NoError(t, err)
|
||||
}()
|
||||
|
||||
bookmark2 := &model.ChannelBookmark{
|
||||
ChannelId: channelId,
|
||||
@@ -437,7 +456,8 @@ func TestUpdateChannelBookmarkSortOrder(t *testing.T) {
|
||||
assert.Equal(t, find_bookmark(bookmarks, bookmark4.Id).SortOrder, int64(4))
|
||||
|
||||
// now reset order
|
||||
th.App.UpdateChannelBookmarkSortOrder(bookmark0.Id, channelId, int64(0), "")
|
||||
_, appErr = th.App.UpdateChannelBookmarkSortOrder(bookmark0.Id, channelId, int64(0), "")
|
||||
assert.Nil(t, appErr)
|
||||
})
|
||||
|
||||
t.Run("change order of bookmarks second to third", func(t *testing.T) {
|
||||
|
||||
Ссылка в новой задаче
Block a user