func (rest *TestCommentREST) TestListCommentsByParentWorkItem() { // given wiid := rest.createDefaultWorkItem() application.Transactional(rest.db, func(app application.Application) error { repo := app.Comments() repo.Create(context.Background(), &comment.Comment{ParentID: wiid, Body: "Test 1", CreatedBy: uuid.NewV4()}) repo.Create(context.Background(), &comment.Comment{ParentID: wiid, Body: "Test 2", CreatedBy: uuid.NewV4()}) repo.Create(context.Background(), &comment.Comment{ParentID: wiid, Body: "Test 3", CreatedBy: uuid.NewV4()}) repo.Create(context.Background(), &comment.Comment{ParentID: wiid + "_other", Body: "Test 1", CreatedBy: uuid.NewV4()}) return nil }) // when svc, ctrl := rest.UnSecuredController() offset := "0" limit := 3 _, cs := test.ListWorkItemCommentsOK(rest.T(), svc.Context, svc, ctrl, wiid, &limit, &offset) // then require.Equal(rest.T(), 3, len(cs.Data)) rest.assertComment(cs.Data[0], "Test 3", rendering.SystemMarkupDefault) // items are returned in reverse order or creation // given wiid2 := rest.createDefaultWorkItem() // when _, cs2 := test.ListWorkItemCommentsOK(rest.T(), svc.Context, svc, ctrl, wiid2, &limit, &offset) // then assert.Equal(rest.T(), 0, len(cs2.Data)) }
func (rest *TestCommentREST) TestEmptyListCommentsByParentWorkItem() { // given wiid := rest.createDefaultWorkItem() // when svc, ctrl := rest.UnSecuredController() offset := "0" limit := 1 _, cs := test.ListWorkItemCommentsOK(rest.T(), svc.Context, svc, ctrl, wiid, &limit, &offset) // then assert.Equal(rest.T(), 0, len(cs.Data)) }