mirror of
https://github.com/mattermost/mattermost.git
synced 2026-05-28 04:35:04 -04:00
Update emoji_test.go (fix errcheck issue) (#28440)
Co-authored-by: Mattermost Build <build@mattermost.com>
This commit is contained in:
parent
845159d501
commit
1d431e72ac
2 changed files with 21 additions and 12 deletions
|
|
@ -74,7 +74,6 @@ issues:
|
|||
channels/api4/config_local.go|\
|
||||
channels/api4/config_test.go|\
|
||||
channels/api4/data_retention.go|\
|
||||
channels/api4/emoji_test.go|\
|
||||
channels/api4/export.go|\
|
||||
channels/api4/export_test.go|\
|
||||
channels/api4/file_test.go|\
|
||||
|
|
|
|||
|
|
@ -429,7 +429,8 @@ func TestDeleteEmoji(t *testing.T) {
|
|||
th.RemovePermissionFromRole(model.PermissionDeleteEmojis.Id, model.SystemUserRoleId)
|
||||
th.AddPermissionToRole(model.PermissionDeleteOthersEmojis.Id, model.SystemUserRoleId)
|
||||
|
||||
client.Logout(context.Background())
|
||||
_, err = client.Logout(context.Background())
|
||||
require.NoError(t, err)
|
||||
th.LoginBasic2()
|
||||
|
||||
resp, err = client.DeleteEmoji(context.Background(), newEmoji.Id)
|
||||
|
|
@ -439,7 +440,8 @@ func TestDeleteEmoji(t *testing.T) {
|
|||
th.RemovePermissionFromRole(model.PermissionDeleteOthersEmojis.Id, model.SystemUserRoleId)
|
||||
th.AddPermissionToRole(model.PermissionDeleteEmojis.Id, model.SystemUserRoleId)
|
||||
|
||||
client.Logout(context.Background())
|
||||
_, err = client.Logout(context.Background())
|
||||
require.NoError(t, err)
|
||||
th.LoginBasic()
|
||||
|
||||
//Try to delete other user's custom emoji without DELETE_OTHERS_EMOJIS permissions
|
||||
|
|
@ -451,14 +453,16 @@ func TestDeleteEmoji(t *testing.T) {
|
|||
newEmoji, _, err = client.CreateEmoji(context.Background(), emoji, utils.CreateTestGif(t, 10, 10), "image.gif")
|
||||
require.NoError(t, err)
|
||||
|
||||
client.Logout(context.Background())
|
||||
_, err = client.Logout(context.Background())
|
||||
require.NoError(t, err)
|
||||
th.LoginBasic2()
|
||||
|
||||
resp, err = client.DeleteEmoji(context.Background(), newEmoji.Id)
|
||||
require.Error(t, err)
|
||||
CheckForbiddenStatus(t, resp)
|
||||
|
||||
client.Logout(context.Background())
|
||||
_, err = client.Logout(context.Background())
|
||||
require.NoError(t, err)
|
||||
th.LoginBasic()
|
||||
|
||||
//Try to delete other user's custom emoji with permissions
|
||||
|
|
@ -473,13 +477,15 @@ func TestDeleteEmoji(t *testing.T) {
|
|||
th.AddPermissionToRole(model.PermissionDeleteEmojis.Id, model.SystemUserRoleId)
|
||||
th.AddPermissionToRole(model.PermissionDeleteOthersEmojis.Id, model.SystemUserRoleId)
|
||||
|
||||
client.Logout(context.Background())
|
||||
_, err = client.Logout(context.Background())
|
||||
require.NoError(t, err)
|
||||
th.LoginBasic2()
|
||||
|
||||
_, err = client.DeleteEmoji(context.Background(), newEmoji.Id)
|
||||
require.NoError(t, err)
|
||||
|
||||
client.Logout(context.Background())
|
||||
_, err = client.Logout(context.Background())
|
||||
require.NoError(t, err)
|
||||
th.LoginBasic()
|
||||
|
||||
//Try to delete my custom emoji with permissions at team level
|
||||
|
|
@ -508,7 +514,8 @@ func TestDeleteEmoji(t *testing.T) {
|
|||
th.AddPermissionToRole(model.PermissionDeleteEmojis.Id, model.TeamUserRoleId)
|
||||
th.AddPermissionToRole(model.PermissionDeleteOthersEmojis.Id, model.TeamUserRoleId)
|
||||
|
||||
client.Logout(context.Background())
|
||||
_, err = client.Logout(context.Background())
|
||||
require.NoError(t, err)
|
||||
th.LoginBasic2()
|
||||
|
||||
_, err = client.DeleteEmoji(context.Background(), newEmoji.Id)
|
||||
|
|
@ -566,7 +573,8 @@ func TestGetEmojiByName(t *testing.T) {
|
|||
require.Error(t, err)
|
||||
CheckNotFoundStatus(t, resp)
|
||||
|
||||
client.Logout(context.Background())
|
||||
_, err = client.Logout(context.Background())
|
||||
require.NoError(t, err)
|
||||
_, resp, err = client.GetEmojiByName(context.Background(), newEmoji.Name)
|
||||
require.Error(t, err)
|
||||
CheckUnauthorizedStatus(t, resp)
|
||||
|
|
@ -742,7 +750,8 @@ func TestSearchEmoji(t *testing.T) {
|
|||
require.Error(t, err)
|
||||
CheckBadRequestStatus(t, resp)
|
||||
|
||||
client.Logout(context.Background())
|
||||
_, err = client.Logout(context.Background())
|
||||
require.NoError(t, err)
|
||||
_, resp, err = client.SearchEmoji(context.Background(), search)
|
||||
require.Error(t, err)
|
||||
CheckUnauthorizedStatus(t, resp)
|
||||
|
|
@ -775,7 +784,7 @@ func TestAutocompleteEmoji(t *testing.T) {
|
|||
}
|
||||
|
||||
remojis, resp, err := client.AutocompleteEmoji(context.Background(), searchTerm1, "")
|
||||
require.NoError(t, err)
|
||||
require.NoErrorf(t, err, "AutocompleteEmoji failed with search term: %s", searchTerm1)
|
||||
CheckOKStatus(t, resp)
|
||||
|
||||
found1 := false
|
||||
|
|
@ -797,7 +806,8 @@ func TestAutocompleteEmoji(t *testing.T) {
|
|||
require.Error(t, err)
|
||||
CheckBadRequestStatus(t, resp)
|
||||
|
||||
client.Logout(context.Background())
|
||||
_, err = client.Logout(context.Background())
|
||||
require.NoError(t, err)
|
||||
_, resp, err = client.AutocompleteEmoji(context.Background(), searchTerm1, "")
|
||||
require.Error(t, err)
|
||||
CheckUnauthorizedStatus(t, resp)
|
||||
|
|
|
|||
Loading…
Reference in a new issue