diff options
author | Joram Wilander <jwawilander@gmail.com> | 2017-02-03 09:30:57 -0500 |
---|---|---|
committer | Corey Hulen <corey@hulen.com> | 2017-02-03 09:30:57 -0500 |
commit | ccb034382850b7e8ea924a4559e47ef44203155c (patch) | |
tree | 72026c58e6bb8e8ad679ac07476906281ffbb1d5 /api4/user_test.go | |
parent | 177589b1e26fcabd7749dd0fbe8c39999c206609 (diff) | |
download | chat-ccb034382850b7e8ea924a4559e47ef44203155c.tar.gz chat-ccb034382850b7e8ea924a4559e47ef44203155c.tar.bz2 chat-ccb034382850b7e8ea924a4559e47ef44203155c.zip |
Implement POST /users/ids endpoint for APIv4 (#5274)
Diffstat (limited to 'api4/user_test.go')
-rw-r--r-- | api4/user_test.go | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/api4/user_test.go b/api4/user_test.go index 501bb38e3..54aae4e49 100644 --- a/api4/user_test.go +++ b/api4/user_test.go @@ -131,6 +131,38 @@ func TestGetUser(t *testing.T) { } } +func TestGetUsersByIds(t *testing.T) { + th := Setup().InitBasic() + Client := th.Client + + users, resp := Client.GetUsersByIds([]string{th.BasicUser.Id}) + CheckNoError(t, resp) + + if users[0].Id != th.BasicUser.Id { + t.Fatal("returned wrong user") + } + CheckUserSanitization(t, users[0]) + + _, resp = Client.GetUsersByIds([]string{}) + CheckBadRequestStatus(t, resp) + + users, resp = Client.GetUsersByIds([]string{"junk"}) + CheckNoError(t, resp) + if len(users) > 0 { + t.Fatal("no users should be returned") + } + + users, resp = Client.GetUsersByIds([]string{"junk", th.BasicUser.Id}) + CheckNoError(t, resp) + if len(users) != 1 { + t.Fatal("1 user should be returned") + } + + Client.Logout() + _, resp = Client.GetUsersByIds([]string{th.BasicUser.Id}) + CheckUnauthorizedStatus(t, resp) +} + func TestUpdateUser(t *testing.T) { th := Setup().InitBasic().InitSystemAdmin() defer TearDown() |