summaryrefslogtreecommitdiffstats
path: root/api4
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2017-07-04 02:58:02 -0400
committerChristopher Speller <crspeller@gmail.com>2017-07-03 23:58:02 -0700
commitf54aee1ef5466fdf11803cd75be3b7267e68540f (patch)
tree6a7dbf14839186ab7c2c9c357a0dc43d7d524329 /api4
parent02335ddad42dcd048f8ef9f371dde90bdaedc1eb (diff)
downloadchat-f54aee1ef5466fdf11803cd75be3b7267e68540f.tar.gz
chat-f54aee1ef5466fdf11803cd75be3b7267e68540f.tar.bz2
chat-f54aee1ef5466fdf11803cd75be3b7267e68540f.zip
Add paging to the GET /emojis endpoint (#6802)
Diffstat (limited to 'api4')
-rw-r--r--api4/emoji.go2
-rw-r--r--api4/emoji_test.go11
2 files changed, 10 insertions, 3 deletions
diff --git a/api4/emoji.go b/api4/emoji.go
index 1d9188af0..f29573383 100644
--- a/api4/emoji.go
+++ b/api4/emoji.go
@@ -81,7 +81,7 @@ func getEmojiList(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
- listEmoji, err := app.GetEmojiList()
+ listEmoji, err := app.GetEmojiList(c.Params.Page, c.Params.PerPage)
if err != nil {
c.Err = err
return
diff --git a/api4/emoji_test.go b/api4/emoji_test.go
index dcd6dddb7..2ca18a9cc 100644
--- a/api4/emoji_test.go
+++ b/api4/emoji_test.go
@@ -173,7 +173,7 @@ func TestGetEmojiList(t *testing.T) {
emojis[idx] = emoji
}
- listEmoji, resp := Client.GetEmojiList()
+ listEmoji, resp := Client.GetEmojiList(0, 100)
CheckNoError(t, resp)
for _, emoji := range emojis {
found := false
@@ -190,7 +190,7 @@ func TestGetEmojiList(t *testing.T) {
_, resp = Client.DeleteEmoji(emojis[0].Id)
CheckNoError(t, resp)
- listEmoji, resp = Client.GetEmojiList()
+ listEmoji, resp = Client.GetEmojiList(0, 100)
CheckNoError(t, resp)
found := false
for _, savedEmoji := range listEmoji {
@@ -202,6 +202,13 @@ func TestGetEmojiList(t *testing.T) {
t.Fatalf("should not get a deleted emoji %v", emojis[0].Id)
}
}
+
+ listEmoji, resp = Client.GetEmojiList(0, 1)
+ CheckNoError(t, resp)
+
+ if len(listEmoji) != 1 {
+ t.Fatal("should only return 1")
+ }
}
func TestDeleteEmoji(t *testing.T) {