Max size to return == 500

This commit is contained in:
Deluan
2016-03-04 17:09:17 -05:00
parent 9783db1781
commit 184bdc0118
2 changed files with 8 additions and 1 deletions
+2 -1
View File
@@ -32,11 +32,12 @@ func (c *GetAlbumListController) Get() {
if !found { if !found {
beego.Error("getAlbumList type", typ, "not implemented!") beego.Error("getAlbumList type", typ, "not implemented!")
c.SendError(responses.ERROR_GENERIC, "Not implemented yet!") c.SendError(responses.ERROR_GENERIC, "Not implemented!")
} }
qo.Size = 10 qo.Size = 10
c.Ctx.Input.Bind(&qo.Size, "size") c.Ctx.Input.Bind(&qo.Size, "size")
qo.Size = utils.MinInt(qo.Size, 500)
c.Ctx.Input.Bind(&qo.Offset, "offset") c.Ctx.Input.Bind(&qo.Offset, "offset")
albums, err := c.albumRepo.GetAll(qo) albums, err := c.albumRepo.GetAll(qo)
+6
View File
@@ -41,6 +41,12 @@ func TestGetAlbumList(t *testing.T) {
So(w.Body, ShouldReceiveError, responses.ERROR_GENERIC) So(w.Body, ShouldReceiveError, responses.ERROR_GENERIC)
}) })
Convey("Max size = 500", func() {
_, w := Get(AddParams("/rest/getAlbumList.view", "type=newest", "size=501"), "TestGetAlbumList")
So(w.Body, ShouldBeAValid, responses.AlbumList{})
So(mockAlbumRepo.Options.Size, ShouldEqual, 500)
So(mockAlbumRepo.Options.Alpha, ShouldBeTrue)
})
Convey("Type == newest", func() { Convey("Type == newest", func() {
_, w := Get(AddParams("/rest/getAlbumList.view", "type=newest"), "TestGetAlbumList") _, w := Get(AddParams("/rest/getAlbumList.view", "type=newest"), "TestGetAlbumList")
So(w.Body, ShouldBeAValid, responses.AlbumList{}) So(w.Body, ShouldBeAValid, responses.AlbumList{})