diff options
author | Joram Wilander <jwawilander@gmail.com> | 2016-11-03 11:24:45 -0400 |
---|---|---|
committer | Corey Hulen <corey@hulen.com> | 2016-11-03 08:24:45 -0700 |
commit | 6da0ccd94447ddc5bcf51285ebac411dd3188cce (patch) | |
tree | 9334fa81ebbd23463134c6e5673e089ebf222836 /store/sql_user_store_test.go | |
parent | 1b141681ae6a169272003fa83fb83ba245dbafc7 (diff) | |
download | chat-6da0ccd94447ddc5bcf51285ebac411dd3188cce.tar.gz chat-6da0ccd94447ddc5bcf51285ebac411dd3188cce.tar.bz2 chat-6da0ccd94447ddc5bcf51285ebac411dd3188cce.zip |
Update user search to match against username, full name, nickname and email (#4421)
Diffstat (limited to 'store/sql_user_store_test.go')
-rw-r--r-- | store/sql_user_store_test.go | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/store/sql_user_store_test.go b/store/sql_user_store_test.go index bc7cc69c5..e58e1fe40 100644 --- a/store/sql_user_store_test.go +++ b/store/sql_user_store_test.go @@ -934,7 +934,7 @@ func TestUserStoreSearch(t *testing.T) { u1.FirstName = "Tim" u1.LastName = "Bill" u1.Nickname = "Rob" - u1.Email = model.NewId() + u1.Email = "harold" + model.NewId() Must(store.User().Save(u1)) u2 := &model.User{} @@ -954,7 +954,7 @@ func TestUserStoreSearch(t *testing.T) { Must(store.Team().SaveMember(&model.TeamMember{TeamId: tid, UserId: u3.Id})) searchOptions := map[string]bool{} - searchOptions[USER_SEARCH_OPTION_USERNAME_ONLY] = true + searchOptions[USER_SEARCH_OPTION_NAMES_ONLY] = true if r1 := <-store.User().Search(tid, "jimb", searchOptions); r1.Err != nil { t.Fatal(r1.Err) @@ -981,6 +981,22 @@ func TestUserStoreSearch(t *testing.T) { } } + if r1 := <-store.User().Search(tid, "harol", searchOptions); r1.Err != nil { + t.Fatal(r1.Err) + } else { + profiles := r1.Data.([]*model.User) + found1 := false + for _, profile := range profiles { + if profile.Id == u1.Id { + found1 = true + } + } + + if found1 { + t.Fatal("should not have found user") + } + } + searchOptions[USER_SEARCH_OPTION_ALLOW_INACTIVE] = true if r1 := <-store.User().Search(tid, "jimb", searchOptions); r1.Err != nil { @@ -1162,6 +1178,22 @@ func TestUserStoreSearch(t *testing.T) { searchOptions = map[string]bool{} + if r1 := <-store.User().Search(tid, "harol", searchOptions); r1.Err != nil { + t.Fatal(r1.Err) + } else { + profiles := r1.Data.([]*model.User) + found1 := false + for _, profile := range profiles { + if profile.Id == u1.Id { + found1 = true + } + } + + if !found1 { + t.Fatal("should have found user") + } + } + if r1 := <-store.User().Search(tid, "Tim", searchOptions); r1.Err != nil { t.Fatal(r1.Err) } else { |