From 61b023f5dfe796c7ba8183292853f01817016d14 Mon Sep 17 00:00:00 2001 From: George Goldberg Date: Tue, 24 Oct 2017 19:27:15 +0100 Subject: PLT-7822: Fix search order for SQL search backend. (#7704) --- model/post_list_test.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'model/post_list_test.go') diff --git a/model/post_list_test.go b/model/post_list_test.go index 56886d4fd..b2ecf3bd5 100644 --- a/model/post_list_test.go +++ b/model/post_list_test.go @@ -6,6 +6,8 @@ package model import ( "strings" "testing" + + "github.com/stretchr/testify/assert" ) func TestPostListJson(t *testing.T) { @@ -68,3 +70,23 @@ func TestPostListExtend(t *testing.T) { t.Fatal("extending l2 again changed l2") } } + +func TestPostListSortByCreateAt(t *testing.T) { + pl := PostList{} + p1 := &Post{Id: NewId(), Message: NewId(), CreateAt: 2} + pl.AddPost(p1) + p2 := &Post{Id: NewId(), Message: NewId(), CreateAt: 1} + pl.AddPost(p2) + p3 := &Post{Id: NewId(), Message: NewId(), CreateAt: 3} + pl.AddPost(p3) + + pl.AddOrder(p1.Id) + pl.AddOrder(p2.Id) + pl.AddOrder(p3.Id) + + pl.SortByCreateAt() + + assert.EqualValues(t, pl.Order[0], p3.Id) + assert.EqualValues(t, pl.Order[1], p1.Id) + assert.EqualValues(t, pl.Order[2], p2.Id) +} -- cgit v1.2.3-1-g7c22