diff options
author | Joram Wilander <jwawilander@gmail.com> | 2017-03-23 06:34:22 -0400 |
---|---|---|
committer | George Goldberg <george@gberg.me> | 2017-03-23 10:34:22 +0000 |
commit | 2a753949f10f70de26dba9fbff7c5ef9583d6c86 (patch) | |
tree | 4430844f254e62afdcf7b0e61da5870f2c8f7061 /api/user_test.go | |
parent | 7e2e8238842c7d158211faafe03f814bffa78a8f (diff) | |
download | chat-2a753949f10f70de26dba9fbff7c5ef9583d6c86.tar.gz chat-2a753949f10f70de26dba9fbff7c5ef9583d6c86.tar.bz2 chat-2a753949f10f70de26dba9fbff7c5ef9583d6c86.zip |
Implement POST /users/search endpoint for APIv4 (#5822)
* Implement POST /users/search endpoint for APIv4
* PLT-2713 Added store functions for searching users that don't have a team
* PLT-2713 Added 'without_team' option when searching users
* PLT-2713 Added 'without_team' option when searching users (v4)
Diffstat (limited to 'api/user_test.go')
-rw-r--r-- | api/user_test.go | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/api/user_test.go b/api/user_test.go index 1fdb3a290..cdbccc57e 100644 --- a/api/user_test.go +++ b/api/user_test.go @@ -2440,6 +2440,59 @@ func TestSearchUsers(t *testing.T) { } if _, err := Client.SearchUsers(model.UserSearch{Term: th.BasicUser.Username, NotInChannelId: th.BasicChannel.Id}); err == nil { + t.Fatal("should not have access") + } + + userWithoutTeam := th.CreateUser(Client) + if result, err := Client.SearchUsers(model.UserSearch{Term: userWithoutTeam.Username}); err != nil { + t.Fatal(err) + } else { + users := result.Data.([]*model.User) + + found := false + for _, user := range users { + if user.Id == userWithoutTeam.Id { + found = true + } + } + + if !found { + t.Fatal("should have found user without team") + } + } + + if result, err := Client.SearchUsers(model.UserSearch{Term: userWithoutTeam.Username, WithoutTeam: true}); err != nil { + t.Fatal(err) + } else { + users := result.Data.([]*model.User) + + found := false + for _, user := range users { + if user.Id == userWithoutTeam.Id { + found = true + } + } + + if !found { + t.Fatal("should have found user without team") + } + } + + if result, err := Client.SearchUsers(model.UserSearch{Term: th.BasicUser.Username, WithoutTeam: true}); err != nil { + t.Fatal(err) + } else { + users := result.Data.([]*model.User) + + found := false + for _, user := range users { + if user.Id == th.BasicUser.Id { + found = true + } + } + + if found { + t.Fatal("should not have found user with team") + } } } |