MM-24692: Add a since parameter to getGroups api (#14444)

* add a since parameter to getGroups api

* update for lint error

* when using since, return deleted groups as well.

* update flaky test, groups have same create time

Co-authored-by: mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
Scott Bishel
2020-05-07 14:35:09 -06:00
коммит произвёл GitHub
родитель 1031e27fd8
Коммит 80c846412d
6 изменённых файлов: 87 добавлений и 2 удалений

Просмотреть файл

@@ -851,6 +851,8 @@ func TestGetGroups(t *testing.T) {
th := Setup(t).InitBasic()
defer th.TearDown()
// make sure "createdDate" for next group is after one created in InitBasic()
time.Sleep(2 * time.Millisecond)
id := model.NewId()
group, err := th.App.CreateGroup(&model.Group{
DisplayName: "dn-foo_" + id,
@@ -860,6 +862,7 @@ func TestGetGroups(t *testing.T) {
RemoteId: model.NewId(),
})
assert.Nil(t, err)
start := group.UpdateAt - 1
opts := model.GroupSearchOpts{
PageOpts: &model.PageOpts{
@@ -911,6 +914,36 @@ func TestGetGroups(t *testing.T) {
_, response = th.Client.GetGroups(opts)
assert.Nil(t, response.Error)
// test "since", should only return group created in this test, not th.Group
opts.Since = start
groups, response = th.Client.GetGroups(opts)
assert.Nil(t, response.Error)
assert.Len(t, groups, 1)
// test correct group returned
assert.Equal(t, groups[0].Id, group.Id)
// delete group, should still return
th.App.DeleteGroup(group.Id)
groups, response = th.Client.GetGroups(opts)
assert.Nil(t, response.Error)
assert.Len(t, groups, 1)
assert.Equal(t, groups[0].Id, group.Id)
// test with current since value, return none
opts.Since = model.GetMillis()
groups, response = th.Client.GetGroups(opts)
assert.Nil(t, response.Error)
assert.Empty(t, groups)
// make sure delete group is not returned without Since
opts.Since = 0
groups, response = th.Client.GetGroups(opts)
assert.Nil(t, response.Error)
//'Normal getGroups should not return delete groups
assert.Len(t, groups, 1)
// make sure it returned th.Group,not group
assert.Equal(t, groups[0].Id, th.Group.Id)
}
func TestGetGroupsByUserId(t *testing.T) {