summaryrefslogtreecommitdiffstats
path: root/store/storetest
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2018-01-19 09:37:59 -0500
committerHarrison Healey <harrisonmhealey@gmail.com>2018-01-19 09:37:59 -0500
commita8445775351c32f8a12081f60bda2099571b2758 (patch)
treebf5a6aace4bb5f4356d9103fbe1d68468e88ea22 /store/storetest
parent9d6a9ff4be15f673e8364a984ccc2b2c3a465b73 (diff)
downloadchat-a8445775351c32f8a12081f60bda2099571b2758.tar.gz
chat-a8445775351c32f8a12081f60bda2099571b2758.tar.bz2
chat-a8445775351c32f8a12081f60bda2099571b2758.zip
Add sort query parameter to GET /emojis (#8121)
Diffstat (limited to 'store/storetest')
-rw-r--r--store/storetest/emoji_store.go26
-rw-r--r--store/storetest/mocks/EmojiStore.go10
2 files changed, 27 insertions, 9 deletions
diff --git a/store/storetest/emoji_store.go b/store/storetest/emoji_store.go
index fc5a31a43..a862440e5 100644
--- a/store/storetest/emoji_store.go
+++ b/store/storetest/emoji_store.go
@@ -9,6 +9,8 @@ import (
"github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/store"
+
+ "github.com/stretchr/testify/assert"
)
func TestEmojiStore(t *testing.T, ss store.Store) {
@@ -133,15 +135,15 @@ func testEmojiGetList(t *testing.T, ss store.Store) {
emojis := []model.Emoji{
{
CreatorId: model.NewId(),
- Name: model.NewId(),
+ Name: "00000000000000000000000000a" + model.NewId(),
},
{
CreatorId: model.NewId(),
- Name: model.NewId(),
+ Name: "00000000000000000000000000b" + model.NewId(),
},
{
CreatorId: model.NewId(),
- Name: model.NewId(),
+ Name: "00000000000000000000000000c" + model.NewId(),
},
}
@@ -154,7 +156,7 @@ func testEmojiGetList(t *testing.T, ss store.Store) {
}
}()
- if result := <-ss.Emoji().GetList(0, 100); result.Err != nil {
+ if result := <-ss.Emoji().GetList(0, 100, ""); result.Err != nil {
t.Fatal(result.Err)
} else {
for _, emoji := range emojis {
@@ -172,4 +174,20 @@ func testEmojiGetList(t *testing.T, ss store.Store) {
}
}
}
+
+ result := <-ss.Emoji().GetList(0, 3, model.EMOJI_SORT_BY_NAME)
+ assert.Nil(t, result.Err)
+ remojis := result.Data.([]*model.Emoji)
+ assert.Equal(t, 3, len(remojis))
+ assert.Equal(t, emojis[0].Name, remojis[0].Name)
+ assert.Equal(t, emojis[1].Name, remojis[1].Name)
+ assert.Equal(t, emojis[2].Name, remojis[2].Name)
+
+ result = <-ss.Emoji().GetList(1, 2, model.EMOJI_SORT_BY_NAME)
+ assert.Nil(t, result.Err)
+ remojis = result.Data.([]*model.Emoji)
+ assert.Equal(t, 2, len(remojis))
+ assert.Equal(t, emojis[1].Name, remojis[0].Name)
+ assert.Equal(t, emojis[2].Name, remojis[1].Name)
+
}
diff --git a/store/storetest/mocks/EmojiStore.go b/store/storetest/mocks/EmojiStore.go
index c01e64578..d1bfe7f00 100644
--- a/store/storetest/mocks/EmojiStore.go
+++ b/store/storetest/mocks/EmojiStore.go
@@ -61,13 +61,13 @@ func (_m *EmojiStore) GetByName(name string) store.StoreChannel {
return r0
}
-// GetList provides a mock function with given fields: offset, limit
-func (_m *EmojiStore) GetList(offset int, limit int) store.StoreChannel {
- ret := _m.Called(offset, limit)
+// GetList provides a mock function with given fields: offset, limit, sort
+func (_m *EmojiStore) GetList(offset int, limit int, sort string) store.StoreChannel {
+ ret := _m.Called(offset, limit, sort)
var r0 store.StoreChannel
- if rf, ok := ret.Get(0).(func(int, int) store.StoreChannel); ok {
- r0 = rf(offset, limit)
+ if rf, ok := ret.Get(0).(func(int, int, string) store.StoreChannel); ok {
+ r0 = rf(offset, limit, sort)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(store.StoreChannel)