summaryrefslogtreecommitdiffstats
path: root/store/sql_user_store_test.go
diff options
context:
space:
mode:
authorHarrison Healey <harrisonmhealey@gmail.com>2017-03-29 21:11:40 -0400
committerJoram Wilander <jwawilander@gmail.com>2017-03-29 21:11:40 -0400
commit6ac87d82e38c83e3b9b3bd12c3122e047f0110b1 (patch)
treeaa3f0f8f41df7c987f8bb62756ca3d8259ecbaa1 /store/sql_user_store_test.go
parenta4764a5c10ec59820eec7338d97be48d41c1a4d6 (diff)
downloadchat-6ac87d82e38c83e3b9b3bd12c3122e047f0110b1.tar.gz
chat-6ac87d82e38c83e3b9b3bd12c3122e047f0110b1.tar.bz2
chat-6ac87d82e38c83e3b9b3bd12c3122e047f0110b1.zip
PLT-2713 Added ability for admins to list users not in any team (#5844)
* PLT-2713 Added ability for admins to list users not in any team * Updated style of unit test
Diffstat (limited to 'store/sql_user_store_test.go')
-rw-r--r--store/sql_user_store_test.go43
1 files changed, 43 insertions, 0 deletions
diff --git a/store/sql_user_store_test.go b/store/sql_user_store_test.go
index 73d42dbcd..6e9642b60 100644
--- a/store/sql_user_store_test.go
+++ b/store/sql_user_store_test.go
@@ -373,6 +373,49 @@ func TestUserStoreGetProfilesInChannel(t *testing.T) {
}
}
+func TestUserStoreGetProfilesWithoutTeam(t *testing.T) {
+ Setup()
+
+ teamId := model.NewId()
+
+ // These usernames need to appear in the first 100 users for this to work
+
+ u1 := &model.User{}
+ u1.Username = "a000000000" + model.NewId()
+ u1.Email = model.NewId()
+ Must(store.User().Save(u1))
+ Must(store.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u1.Id}))
+ defer store.User().PermanentDelete(u1.Id)
+
+ u2 := &model.User{}
+ u2.Username = "a000000001" + model.NewId()
+ u2.Email = model.NewId()
+ Must(store.User().Save(u2))
+ defer store.User().PermanentDelete(u2.Id)
+
+ if r1 := <-store.User().GetProfilesWithoutTeam(0, 100); r1.Err != nil {
+ t.Fatal(r1.Err)
+ } else {
+ users := r1.Data.([]*model.User)
+
+ found1 := false
+ found2 := false
+ for _, u := range users {
+ if u.Id == u1.Id {
+ found1 = true
+ } else if u.Id == u2.Id {
+ found2 = true
+ }
+ }
+
+ if found1 {
+ t.Fatal("shouldn't have returned user on team")
+ } else if !found2 {
+ t.Fatal("should've returned user without any teams")
+ }
+ }
+}
+
func TestUserStoreGetAllProfilesInChannel(t *testing.T) {
Setup()