PLT-6909 Remove deleted emojis from cache (#6757)

* PLT-6909 Remove deleted emojis from cache

* Fixed unit tests
Этот коммит содержится в:
Harrison Healey
2017-06-28 23:06:45 -04:00
коммит произвёл Saturnino Abril
родитель 9e600fcdcc
Коммит 520cedea16
2 изменённых файлов: 9 добавлений и 5 удалений

Просмотреть файл

@@ -251,11 +251,11 @@ func TestDeleteEmoji(t *testing.T) {
// Try to delete just deleted emoji // Try to delete just deleted emoji
_, resp = Client.DeleteEmoji(newEmoji.Id) _, resp = Client.DeleteEmoji(newEmoji.Id)
CheckInternalErrorStatus(t, resp) CheckNotFoundStatus(t, resp)
//Try to delete non-existing emoji //Try to delete non-existing emoji
_, resp = Client.DeleteEmoji(model.NewId()) _, resp = Client.DeleteEmoji(model.NewId())
CheckInternalErrorStatus(t, resp) CheckNotFoundStatus(t, resp)
//Try to delete without Id //Try to delete without Id
_, resp = Client.DeleteEmoji("") _, resp = Client.DeleteEmoji("")
@@ -297,7 +297,7 @@ func TestGetEmoji(t *testing.T) {
} }
_, resp = Client.GetEmoji(model.NewId()) _, resp = Client.GetEmoji(model.NewId())
CheckInternalErrorStatus(t, resp) CheckNotFoundStatus(t, resp)
} }
func TestGetEmojiImage(t *testing.T) { func TestGetEmojiImage(t *testing.T) {
@@ -413,7 +413,7 @@ func TestGetEmojiImage(t *testing.T) {
CheckNotFoundStatus(t, resp) CheckNotFoundStatus(t, resp)
_, resp = Client.GetEmojiImage(model.NewId()) _, resp = Client.GetEmojiImage(model.NewId())
CheckInternalErrorStatus(t, resp) CheckNotFoundStatus(t, resp)
_, resp = Client.GetEmojiImage("") _, resp = Client.GetEmojiImage("")
CheckBadRequestStatus(t, resp) CheckBadRequestStatus(t, resp)

Просмотреть файл

@@ -4,6 +4,8 @@
package store package store
import ( import (
"net/http"
"github.com/mattermost/platform/einterfaces" "github.com/mattermost/platform/einterfaces"
"github.com/mattermost/platform/model" "github.com/mattermost/platform/model"
"github.com/mattermost/platform/utils" "github.com/mattermost/platform/utils"
@@ -104,7 +106,7 @@ func (es SqlEmojiStore) Get(id string, allowFromCache bool) StoreChannel {
WHERE WHERE
Id = :Id Id = :Id
AND DeleteAt = 0`, map[string]interface{}{"Id": id}); err != nil { AND DeleteAt = 0`, map[string]interface{}{"Id": id}); err != nil {
result.Err = model.NewLocAppError("SqlEmojiStore.Get", "store.sql_emoji.get.app_error", nil, "id="+id+", "+err.Error()) result.Err = model.NewAppError("SqlEmojiStore.Get", "store.sql_emoji.get.app_error", nil, "id="+id+", "+err.Error(), http.StatusNotFound)
} else { } else {
result.Data = emoji result.Data = emoji
@@ -195,6 +197,8 @@ func (es SqlEmojiStore) Delete(id string, time int64) StoreChannel {
result.Err = model.NewLocAppError("SqlEmojiStore.Delete", "store.sql_emoji.delete.no_results", nil, "id="+id+", err="+err.Error()) result.Err = model.NewLocAppError("SqlEmojiStore.Delete", "store.sql_emoji.delete.no_results", nil, "id="+id+", err="+err.Error())
} }
emojiCache.Remove(id)
storeChannel <- result storeChannel <- result
close(storeChannel) close(storeChannel)
}() }()