diff options
author | Joram Wilander <jwawilander@gmail.com> | 2017-06-30 12:07:23 -0400 |
---|---|---|
committer | Harrison Healey <harrisonmhealey@gmail.com> | 2017-06-30 12:07:23 -0400 |
commit | 5507154992eedd323385c37e59b2008586b9aaa0 (patch) | |
tree | b017d2a40207cb437b9aa84703990577539df9f8 /api4/user_test.go | |
parent | 6b77a054c25acb0437a58107c4592ad66c830993 (diff) | |
download | chat-5507154992eedd323385c37e59b2008586b9aaa0.tar.gz chat-5507154992eedd323385c37e59b2008586b9aaa0.tar.bz2 chat-5507154992eedd323385c37e59b2008586b9aaa0.zip |
Add some basic sorting support for GET /users endpoint (#6801)
Diffstat (limited to 'api4/user_test.go')
-rw-r--r-- | api4/user_test.go | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/api4/user_test.go b/api4/user_test.go index 1067ebaf6..77157e250 100644 --- a/api4/user_test.go +++ b/api4/user_test.go @@ -1224,6 +1224,64 @@ func TestGetUsers(t *testing.T) { CheckUnauthorizedStatus(t, resp) } +func TestGetNewUsersInTeam(t *testing.T) { + th := Setup().InitBasic() + defer TearDown() + Client := th.Client + teamId := th.BasicTeam.Id + + rusers, resp := Client.GetNewUsersInTeam(teamId, 0, 60, "") + CheckNoError(t, resp) + + lastCreateAt := model.GetMillis() + for _, u := range rusers { + if u.CreateAt > lastCreateAt { + t.Fatal("bad sorting") + } + lastCreateAt = u.CreateAt + CheckUserSanitization(t, u) + } + + rusers, resp = Client.GetNewUsersInTeam(teamId, 1, 1, "") + CheckNoError(t, resp) + if len(rusers) != 1 { + t.Fatal("should be 1 per page") + } + + Client.Logout() + _, resp = Client.GetNewUsersInTeam(teamId, 1, 1, "") + CheckUnauthorizedStatus(t, resp) +} + +func TestGetRecentlyActiveUsersInTeam(t *testing.T) { + th := Setup().InitBasic() + defer TearDown() + Client := th.Client + teamId := th.BasicTeam.Id + + app.SetStatusOnline(th.BasicUser.Id, "", true) + + rusers, resp := Client.GetRecentlyActiveUsersInTeam(teamId, 0, 60, "") + CheckNoError(t, resp) + + for _, u := range rusers { + if u.LastActivityAt == 0 { + t.Fatal("did not return last activity at") + } + CheckUserSanitization(t, u) + } + + rusers, resp = Client.GetRecentlyActiveUsersInTeam(teamId, 0, 1, "") + CheckNoError(t, resp) + if len(rusers) != 1 { + t.Fatal("should be 1 per page") + } + + Client.Logout() + _, resp = Client.GetRecentlyActiveUsersInTeam(teamId, 0, 1, "") + CheckUnauthorizedStatus(t, resp) +} + func TestGetUsersWithoutTeam(t *testing.T) { th := Setup().InitBasic().InitSystemAdmin() defer TearDown() |