From f54aee1ef5466fdf11803cd75be3b7267e68540f Mon Sep 17 00:00:00 2001 From: Joram Wilander Date: Tue, 4 Jul 2017 02:58:02 -0400 Subject: Add paging to the GET /emojis endpoint (#6802) --- api4/emoji.go | 2 +- api4/emoji_test.go | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) (limited to 'api4') 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) { -- cgit v1.2.3-1-g7c22