summaryrefslogtreecommitdiffstats
path: root/store
diff options
context:
space:
mode:
author=Corey Hulen <corey@hulen.com>2016-01-20 12:43:44 -0600
committer=Corey Hulen <corey@hulen.com>2016-01-20 12:43:44 -0600
commit75f8729e2d25467500778e633c45c97e78a8f7a0 (patch)
tree47735a3dd609e025837df4460b0d030454358cf1 /store
parentaac8d121a00922f007b9c67d890ea9dbcfbe4b8f (diff)
downloadchat-75f8729e2d25467500778e633c45c97e78a8f7a0.tar.gz
chat-75f8729e2d25467500778e633c45c97e78a8f7a0.tar.bz2
chat-75f8729e2d25467500778e633c45c97e78a8f7a0.zip
PLT-7 adding loc db calls for users table
Diffstat (limited to 'store')
-rw-r--r--store/sql_channel_store_test.go16
-rw-r--r--store/sql_team_store_test.go2
-rw-r--r--store/sql_user_store.go46
-rw-r--r--store/sql_user_store_test.go108
-rw-r--r--store/store.go42
5 files changed, 108 insertions, 106 deletions
diff --git a/store/sql_channel_store_test.go b/store/sql_channel_store_test.go
index 412b03b10..079fab92b 100644
--- a/store/sql_channel_store_test.go
+++ b/store/sql_channel_store_test.go
@@ -72,13 +72,13 @@ func TestChannelStoreSaveDirectChannel(t *testing.T) {
u1.TeamId = model.NewId()
u1.Email = model.NewId()
u1.Nickname = model.NewId()
- Must(store.User().Save(&u1))
+ Must(store.User().Save(utils.T, &u1))
u2 := model.User{}
u2.TeamId = model.NewId()
u2.Email = model.NewId()
u2.Nickname = model.NewId()
- Must(store.User().Save(&u2))
+ Must(store.User().Save(utils.T, &u2))
m1 := model.ChannelMember{}
m1.ChannelId = o1.Id
@@ -168,13 +168,13 @@ func TestChannelStoreGet(t *testing.T) {
u1.TeamId = model.NewId()
u1.Email = model.NewId()
u1.Nickname = model.NewId()
- Must(store.User().Save(&u1))
+ Must(store.User().Save(utils.T, &u1))
u2 := model.User{}
u2.TeamId = model.NewId()
u2.Email = model.NewId()
u2.Nickname = model.NewId()
- Must(store.User().Save(&u2))
+ Must(store.User().Save(utils.T, &u2))
o2 := model.Channel{}
o2.TeamId = model.NewId()
@@ -313,13 +313,13 @@ func TestChannelMemberStore(t *testing.T) {
u1.TeamId = model.NewId()
u1.Email = model.NewId()
u1.Nickname = model.NewId()
- Must(store.User().Save(&u1))
+ Must(store.User().Save(utils.T, &u1))
u2 := model.User{}
u2.TeamId = model.NewId()
u2.Email = model.NewId()
u2.Nickname = model.NewId()
- Must(store.User().Save(&u2))
+ Must(store.User().Save(utils.T, &u2))
o1 := model.ChannelMember{}
o1.ChannelId = c1.Id
@@ -397,13 +397,13 @@ func TestChannelDeleteMemberStore(t *testing.T) {
u1.TeamId = model.NewId()
u1.Email = model.NewId()
u1.Nickname = model.NewId()
- Must(store.User().Save(&u1))
+ Must(store.User().Save(utils.T, &u1))
u2 := model.User{}
u2.TeamId = model.NewId()
u2.Email = model.NewId()
u2.Nickname = model.NewId()
- Must(store.User().Save(&u2))
+ Must(store.User().Save(utils.T, &u2))
o1 := model.ChannelMember{}
o1.ChannelId = c1.Id
diff --git a/store/sql_team_store_test.go b/store/sql_team_store_test.go
index 47708777c..90f4772f1 100644
--- a/store/sql_team_store_test.go
+++ b/store/sql_team_store_test.go
@@ -194,7 +194,7 @@ func TestTeamStoreGetForEmail(t *testing.T) {
u1 := model.User{}
u1.TeamId = o1.Id
u1.Email = model.NewId()
- Must(store.User().Save(&u1))
+ Must(store.User().Save(utils.T, &u1))
if r1 := <-store.Team().GetTeamsForEmail(utils.T, u1.Email); r1.Err != nil {
t.Fatal(r1.Err)
diff --git a/store/sql_user_store.go b/store/sql_user_store.go
index 0f73f73c3..e17db6666 100644
--- a/store/sql_user_store.go
+++ b/store/sql_user_store.go
@@ -5,9 +5,11 @@ package store
import (
"fmt"
+ "strings"
+
"github.com/mattermost/platform/model"
"github.com/mattermost/platform/utils"
- "strings"
+ goi18n "github.com/nicksnyder/go-i18n/i18n"
)
const (
@@ -54,7 +56,7 @@ func (us SqlUserStore) CreateIndexesIfNotExists() {
us.CreateIndexIfNotExists("idx_users_email", "Users", "Email")
}
-func (us SqlUserStore) Save(user *model.User) StoreChannel {
+func (us SqlUserStore) Save(T goi18n.TranslateFunc, user *model.User) StoreChannel {
storeChannel := make(StoreChannel)
@@ -106,7 +108,7 @@ func (us SqlUserStore) Save(user *model.User) StoreChannel {
return storeChannel
}
-func (us SqlUserStore) Update(user *model.User, allowActiveUpdate bool) StoreChannel {
+func (us SqlUserStore) Update(T goi18n.TranslateFunc, user *model.User, allowActiveUpdate bool) StoreChannel {
storeChannel := make(StoreChannel)
@@ -183,7 +185,7 @@ func (us SqlUserStore) Update(user *model.User, allowActiveUpdate bool) StoreCha
return storeChannel
}
-func (us SqlUserStore) UpdateLastPictureUpdate(userId string) StoreChannel {
+func (us SqlUserStore) UpdateLastPictureUpdate(T goi18n.TranslateFunc, userId string) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -204,7 +206,7 @@ func (us SqlUserStore) UpdateLastPictureUpdate(userId string) StoreChannel {
return storeChannel
}
-func (us SqlUserStore) UpdateLastPingAt(userId string, time int64) StoreChannel {
+func (us SqlUserStore) UpdateLastPingAt(T goi18n.TranslateFunc, userId string, time int64) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -223,7 +225,7 @@ func (us SqlUserStore) UpdateLastPingAt(userId string, time int64) StoreChannel
return storeChannel
}
-func (us SqlUserStore) UpdateLastActivityAt(userId string, time int64) StoreChannel {
+func (us SqlUserStore) UpdateLastActivityAt(T goi18n.TranslateFunc, userId string, time int64) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -242,7 +244,7 @@ func (us SqlUserStore) UpdateLastActivityAt(userId string, time int64) StoreChan
return storeChannel
}
-func (us SqlUserStore) UpdateUserAndSessionActivity(userId string, sessionId string, time int64) StoreChannel {
+func (us SqlUserStore) UpdateUserAndSessionActivity(T goi18n.TranslateFunc, userId string, sessionId string, time int64) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -263,7 +265,7 @@ func (us SqlUserStore) UpdateUserAndSessionActivity(userId string, sessionId str
return storeChannel
}
-func (us SqlUserStore) UpdatePassword(userId, hashedPassword string) StoreChannel {
+func (us SqlUserStore) UpdatePassword(T goi18n.TranslateFunc, userId, hashedPassword string) StoreChannel {
storeChannel := make(StoreChannel)
@@ -285,7 +287,7 @@ func (us SqlUserStore) UpdatePassword(userId, hashedPassword string) StoreChanne
return storeChannel
}
-func (us SqlUserStore) UpdateFailedPasswordAttempts(userId string, attempts int) StoreChannel {
+func (us SqlUserStore) UpdateFailedPasswordAttempts(T goi18n.TranslateFunc, userId string, attempts int) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -304,7 +306,7 @@ func (us SqlUserStore) UpdateFailedPasswordAttempts(userId string, attempts int)
return storeChannel
}
-func (us SqlUserStore) UpdateAuthData(userId, service, authData string) StoreChannel {
+func (us SqlUserStore) UpdateAuthData(T goi18n.TranslateFunc, userId, service, authData string) StoreChannel {
storeChannel := make(StoreChannel)
@@ -326,7 +328,7 @@ func (us SqlUserStore) UpdateAuthData(userId, service, authData string) StoreCha
return storeChannel
}
-func (us SqlUserStore) Get(id string) StoreChannel {
+func (us SqlUserStore) Get(T goi18n.TranslateFunc, id string) StoreChannel {
storeChannel := make(StoreChannel)
@@ -349,7 +351,7 @@ func (us SqlUserStore) Get(id string) StoreChannel {
return storeChannel
}
-func (s SqlUserStore) GetEtagForProfiles(teamId string) StoreChannel {
+func (s SqlUserStore) GetEtagForProfiles(T goi18n.TranslateFunc, teamId string) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -369,7 +371,7 @@ func (s SqlUserStore) GetEtagForProfiles(teamId string) StoreChannel {
return storeChannel
}
-func (us SqlUserStore) GetProfiles(teamId string) StoreChannel {
+func (us SqlUserStore) GetProfiles(T goi18n.TranslateFunc, teamId string) StoreChannel {
storeChannel := make(StoreChannel)
@@ -400,7 +402,7 @@ func (us SqlUserStore) GetProfiles(teamId string) StoreChannel {
return storeChannel
}
-func (us SqlUserStore) GetSystemAdminProfiles() StoreChannel {
+func (us SqlUserStore) GetSystemAdminProfiles(T goi18n.TranslateFunc) StoreChannel {
storeChannel := make(StoreChannel)
@@ -431,7 +433,7 @@ func (us SqlUserStore) GetSystemAdminProfiles() StoreChannel {
return storeChannel
}
-func (us SqlUserStore) GetByEmail(teamId string, email string) StoreChannel {
+func (us SqlUserStore) GetByEmail(T goi18n.TranslateFunc, teamId string, email string) StoreChannel {
storeChannel := make(StoreChannel)
@@ -453,7 +455,7 @@ func (us SqlUserStore) GetByEmail(teamId string, email string) StoreChannel {
return storeChannel
}
-func (us SqlUserStore) GetByAuth(teamId string, authData string, authService string) StoreChannel {
+func (us SqlUserStore) GetByAuth(T goi18n.TranslateFunc, teamId string, authData string, authService string) StoreChannel {
storeChannel := make(StoreChannel)
@@ -475,7 +477,7 @@ func (us SqlUserStore) GetByAuth(teamId string, authData string, authService str
return storeChannel
}
-func (us SqlUserStore) GetByUsername(teamId string, username string) StoreChannel {
+func (us SqlUserStore) GetByUsername(T goi18n.TranslateFunc, teamId string, username string) StoreChannel {
storeChannel := make(StoreChannel)
@@ -497,7 +499,7 @@ func (us SqlUserStore) GetByUsername(teamId string, username string) StoreChanne
return storeChannel
}
-func (us SqlUserStore) VerifyEmail(userId string) StoreChannel {
+func (us SqlUserStore) VerifyEmail(T goi18n.TranslateFunc, userId string) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -516,7 +518,7 @@ func (us SqlUserStore) VerifyEmail(userId string) StoreChannel {
return storeChannel
}
-func (us SqlUserStore) GetForExport(teamId string) StoreChannel {
+func (us SqlUserStore) GetForExport(T goi18n.TranslateFunc, teamId string) StoreChannel {
storeChannel := make(StoreChannel)
@@ -543,7 +545,7 @@ func (us SqlUserStore) GetForExport(teamId string) StoreChannel {
return storeChannel
}
-func (us SqlUserStore) GetTotalUsersCount() StoreChannel {
+func (us SqlUserStore) GetTotalUsersCount(T goi18n.TranslateFunc) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -562,7 +564,7 @@ func (us SqlUserStore) GetTotalUsersCount() StoreChannel {
return storeChannel
}
-func (us SqlUserStore) GetTotalActiveUsersCount() StoreChannel {
+func (us SqlUserStore) GetTotalActiveUsersCount(T goi18n.TranslateFunc) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -583,7 +585,7 @@ func (us SqlUserStore) GetTotalActiveUsersCount() StoreChannel {
return storeChannel
}
-func (us SqlUserStore) PermanentDelete(userId string) StoreChannel {
+func (us SqlUserStore) PermanentDelete(T goi18n.TranslateFunc, userId string) StoreChannel {
storeChannel := make(StoreChannel)
diff --git a/store/sql_user_store_test.go b/store/sql_user_store_test.go
index 12bc6d172..50296b251 100644
--- a/store/sql_user_store_test.go
+++ b/store/sql_user_store_test.go
@@ -19,27 +19,27 @@ func TestUserStoreSave(t *testing.T) {
u1.Username = model.NewId()
u1.TeamId = model.NewId()
- if err := (<-store.User().Save(&u1)).Err; err != nil {
+ if err := (<-store.User().Save(utils.T, &u1)).Err; err != nil {
t.Fatal("couldn't save user", err)
}
- if err := (<-store.User().Save(&u1)).Err; err == nil {
+ if err := (<-store.User().Save(utils.T, &u1)).Err; err == nil {
t.Fatal("shouldn't be able to update user from save")
}
u1.Id = ""
- if err := (<-store.User().Save(&u1)).Err; err == nil {
+ if err := (<-store.User().Save(utils.T, &u1)).Err; err == nil {
t.Fatal("should be unique email")
}
u1.Email = ""
- if err := (<-store.User().Save(&u1)).Err; err == nil {
+ if err := (<-store.User().Save(utils.T, &u1)).Err; err == nil {
t.Fatal("should be unique username")
}
u1.Email = strings.Repeat("0123456789", 20)
u1.Username = ""
- if err := (<-store.User().Save(&u1)).Err; err == nil {
+ if err := (<-store.User().Save(utils.T, &u1)).Err; err == nil {
t.Fatal("should be unique username")
}
@@ -47,7 +47,7 @@ func TestUserStoreSave(t *testing.T) {
u1.Id = ""
u1.Email = model.NewId()
u1.Username = model.NewId()
- if err := (<-store.User().Save(&u1)).Err; err != nil {
+ if err := (<-store.User().Save(utils.T, &u1)).Err; err != nil {
t.Fatal("couldn't save item", err)
}
}
@@ -55,7 +55,7 @@ func TestUserStoreSave(t *testing.T) {
u1.Id = ""
u1.Email = model.NewId()
u1.Username = model.NewId()
- if err := (<-store.User().Save(&u1)).Err; err == nil {
+ if err := (<-store.User().Save(utils.T, &u1)).Err; err == nil {
t.Fatal("should be the limit", err)
}
}
@@ -66,21 +66,21 @@ func TestUserStoreUpdate(t *testing.T) {
u1 := model.User{}
u1.TeamId = model.NewId()
u1.Email = model.NewId()
- Must(store.User().Save(&u1))
+ Must(store.User().Save(utils.T, &u1))
time.Sleep(100 * time.Millisecond)
- if err := (<-store.User().Update(&u1, false)).Err; err != nil {
+ if err := (<-store.User().Update(utils.T, &u1, false)).Err; err != nil {
t.Fatal(err)
}
u1.Id = "missing"
- if err := (<-store.User().Update(&u1, false)).Err; err == nil {
+ if err := (<-store.User().Update(utils.T, &u1, false)).Err; err == nil {
t.Fatal("Update should have failed because of missing key")
}
u1.Id = model.NewId()
- if err := (<-store.User().Update(&u1, false)).Err; err == nil {
+ if err := (<-store.User().Update(utils.T, &u1, false)).Err; err == nil {
t.Fatal("Update should have faile because id change")
}
}
@@ -91,13 +91,13 @@ func TestUserStoreUpdateLastPingAt(t *testing.T) {
u1 := model.User{}
u1.TeamId = model.NewId()
u1.Email = model.NewId()
- Must(store.User().Save(&u1))
+ Must(store.User().Save(utils.T, &u1))
- if err := (<-store.User().UpdateLastPingAt(u1.Id, 1234567890)).Err; err != nil {
+ if err := (<-store.User().UpdateLastPingAt(utils.T, u1.Id, 1234567890)).Err; err != nil {
t.Fatal(err)
}
- if r1 := <-store.User().Get(u1.Id); r1.Err != nil {
+ if r1 := <-store.User().Get(utils.T, u1.Id); r1.Err != nil {
t.Fatal(r1.Err)
} else {
if r1.Data.(*model.User).LastPingAt != 1234567890 {
@@ -113,13 +113,13 @@ func TestUserStoreUpdateLastActivityAt(t *testing.T) {
u1 := model.User{}
u1.TeamId = model.NewId()
u1.Email = model.NewId()
- Must(store.User().Save(&u1))
+ Must(store.User().Save(utils.T, &u1))
- if err := (<-store.User().UpdateLastActivityAt(u1.Id, 1234567890)).Err; err != nil {
+ if err := (<-store.User().UpdateLastActivityAt(utils.T, u1.Id, 1234567890)).Err; err != nil {
t.Fatal(err)
}
- if r1 := <-store.User().Get(u1.Id); r1.Err != nil {
+ if r1 := <-store.User().Get(utils.T, u1.Id); r1.Err != nil {
t.Fatal(r1.Err)
} else {
if r1.Data.(*model.User).LastActivityAt != 1234567890 {
@@ -135,13 +135,13 @@ func TestUserStoreUpdateFailedPasswordAttempts(t *testing.T) {
u1 := model.User{}
u1.TeamId = model.NewId()
u1.Email = model.NewId()
- Must(store.User().Save(&u1))
+ Must(store.User().Save(utils.T, &u1))
- if err := (<-store.User().UpdateFailedPasswordAttempts(u1.Id, 3)).Err; err != nil {
+ if err := (<-store.User().UpdateFailedPasswordAttempts(utils.T, u1.Id, 3)).Err; err != nil {
t.Fatal(err)
}
- if r1 := <-store.User().Get(u1.Id); r1.Err != nil {
+ if r1 := <-store.User().Get(utils.T, u1.Id); r1.Err != nil {
t.Fatal(r1.Err)
} else {
if r1.Data.(*model.User).FailedAttempts != 3 {
@@ -157,18 +157,18 @@ func TestUserStoreUpdateUserAndSessionActivity(t *testing.T) {
u1 := model.User{}
u1.TeamId = model.NewId()
u1.Email = model.NewId()
- Must(store.User().Save(&u1))
+ Must(store.User().Save(utils.T, &u1))
s1 := model.Session{}
s1.UserId = u1.Id
s1.TeamId = u1.TeamId
Must(store.Session().Save(utils.T, &s1))
- if err := (<-store.User().UpdateUserAndSessionActivity(u1.Id, s1.Id, 1234567890)).Err; err != nil {
+ if err := (<-store.User().UpdateUserAndSessionActivity(utils.T, u1.Id, s1.Id, 1234567890)).Err; err != nil {
t.Fatal(err)
}
- if r1 := <-store.User().Get(u1.Id); r1.Err != nil {
+ if r1 := <-store.User().Get(utils.T, u1.Id); r1.Err != nil {
t.Fatal(r1.Err)
} else {
if r1.Data.(*model.User).LastActivityAt != 1234567890 {
@@ -192,9 +192,9 @@ func TestUserStoreGet(t *testing.T) {
u1 := model.User{}
u1.TeamId = model.NewId()
u1.Email = model.NewId()
- Must(store.User().Save(&u1))
+ Must(store.User().Save(utils.T, &u1))
- if r1 := <-store.User().Get(u1.Id); r1.Err != nil {
+ if r1 := <-store.User().Get(utils.T, u1.Id); r1.Err != nil {
t.Fatal(r1.Err)
} else {
if r1.Data.(*model.User).ToJson() != u1.ToJson() {
@@ -202,7 +202,7 @@ func TestUserStoreGet(t *testing.T) {
}
}
- if err := (<-store.User().Get("")).Err; err == nil {
+ if err := (<-store.User().Get(utils.T, "")).Err; err == nil {
t.Fatal("Missing id should have failed")
}
}
@@ -213,9 +213,9 @@ func TestUserCount(t *testing.T) {
u1 := model.User{}
u1.TeamId = model.NewId()
u1.Email = model.NewId()
- Must(store.User().Save(&u1))
+ Must(store.User().Save(utils.T, &u1))
- if result := <-store.User().GetTotalUsersCount(); result.Err != nil {
+ if result := <-store.User().GetTotalUsersCount(utils.T); result.Err != nil {
t.Fatal(result.Err)
} else {
count := result.Data.(int64)
@@ -231,9 +231,9 @@ func TestActiveUserCount(t *testing.T) {
u1 := model.User{}
u1.TeamId = model.NewId()
u1.Email = model.NewId()
- Must(store.User().Save(&u1))
+ Must(store.User().Save(utils.T, &u1))
- if result := <-store.User().GetTotalActiveUsersCount(); result.Err != nil {
+ if result := <-store.User().GetTotalActiveUsersCount(utils.T); result.Err != nil {
t.Fatal(result.Err)
} else {
count := result.Data.(int64)
@@ -249,14 +249,14 @@ func TestUserStoreGetProfiles(t *testing.T) {
u1 := model.User{}
u1.TeamId = model.NewId()
u1.Email = model.NewId()
- Must(store.User().Save(&u1))
+ Must(store.User().Save(utils.T, &u1))
u2 := model.User{}
u2.TeamId = u1.TeamId
u2.Email = model.NewId()
- Must(store.User().Save(&u2))
+ Must(store.User().Save(utils.T, &u2))
- if r1 := <-store.User().GetProfiles(u1.TeamId); r1.Err != nil {
+ if r1 := <-store.User().GetProfiles(utils.T, u1.TeamId); r1.Err != nil {
t.Fatal(r1.Err)
} else {
users := r1.Data.(map[string]*model.User)
@@ -269,7 +269,7 @@ func TestUserStoreGetProfiles(t *testing.T) {
}
}
- if r2 := <-store.User().GetProfiles("123"); r2.Err != nil {
+ if r2 := <-store.User().GetProfiles(utils.T, "123"); r2.Err != nil {
t.Fatal(r2.Err)
} else {
if len(r2.Data.(map[string]*model.User)) != 0 {
@@ -284,14 +284,14 @@ func TestUserStoreGetSystemAdminProfiles(t *testing.T) {
u1 := model.User{}
u1.TeamId = model.NewId()
u1.Email = model.NewId()
- Must(store.User().Save(&u1))
+ Must(store.User().Save(utils.T, &u1))
u2 := model.User{}
u2.TeamId = u1.TeamId
u2.Email = model.NewId()
- Must(store.User().Save(&u2))
+ Must(store.User().Save(utils.T, &u2))
- if r1 := <-store.User().GetSystemAdminProfiles(); r1.Err != nil {
+ if r1 := <-store.User().GetSystemAdminProfiles(utils.T); r1.Err != nil {
t.Fatal(r1.Err)
} else {
users := r1.Data.(map[string]*model.User)
@@ -307,13 +307,13 @@ func TestUserStoreGetByEmail(t *testing.T) {
u1 := model.User{}
u1.TeamId = model.NewId()
u1.Email = model.NewId()
- Must(store.User().Save(&u1))
+ Must(store.User().Save(utils.T, &u1))
- if err := (<-store.User().GetByEmail(u1.TeamId, u1.Email)).Err; err != nil {
+ if err := (<-store.User().GetByEmail(utils.T, u1.TeamId, u1.Email)).Err; err != nil {
t.Fatal(err)
}
- if err := (<-store.User().GetByEmail("", "")).Err; err == nil {
+ if err := (<-store.User().GetByEmail(utils.T, "", "")).Err; err == nil {
t.Fatal("Should have failed because of missing email")
}
}
@@ -326,13 +326,13 @@ func TestUserStoreGetByAuthData(t *testing.T) {
u1.Email = model.NewId()
u1.AuthData = "123"
u1.AuthService = "service"
- Must(store.User().Save(&u1))
+ Must(store.User().Save(utils.T, &u1))
- if err := (<-store.User().GetByAuth(u1.TeamId, u1.AuthData, u1.AuthService)).Err; err != nil {
+ if err := (<-store.User().GetByAuth(utils.T, u1.TeamId, u1.AuthData, u1.AuthService)).Err; err != nil {
t.Fatal(err)
}
- if err := (<-store.User().GetByAuth("", "", "")).Err; err == nil {
+ if err := (<-store.User().GetByAuth(utils.T, "", "", "")).Err; err == nil {
t.Fatal("Should have failed because of missing auth data")
}
}
@@ -344,13 +344,13 @@ func TestUserStoreGetByUsername(t *testing.T) {
u1.TeamId = model.NewId()
u1.Email = model.NewId()
u1.Username = model.NewId()
- Must(store.User().Save(&u1))
+ Must(store.User().Save(utils.T, &u1))
- if err := (<-store.User().GetByUsername(u1.TeamId, u1.Username)).Err; err != nil {
+ if err := (<-store.User().GetByUsername(utils.T, u1.TeamId, u1.Username)).Err; err != nil {
t.Fatal(err)
}
- if err := (<-store.User().GetByUsername("", "")).Err; err == nil {
+ if err := (<-store.User().GetByUsername(utils.T, "", "")).Err; err == nil {
t.Fatal("Should have failed because of missing username")
}
}
@@ -361,15 +361,15 @@ func TestUserStoreUpdatePassword(t *testing.T) {
u1 := model.User{}
u1.TeamId = model.NewId()
u1.Email = model.NewId()
- Must(store.User().Save(&u1))
+ Must(store.User().Save(utils.T, &u1))
hashedPassword := model.HashPassword("newpwd")
- if err := (<-store.User().UpdatePassword(u1.Id, hashedPassword)).Err; err != nil {
+ if err := (<-store.User().UpdatePassword(utils.T, u1.Id, hashedPassword)).Err; err != nil {
t.Fatal(err)
}
- if r1 := <-store.User().GetByEmail(u1.TeamId, u1.Email); r1.Err != nil {
+ if r1 := <-store.User().GetByEmail(utils.T, u1.TeamId, u1.Email); r1.Err != nil {
t.Fatal(r1.Err)
} else {
user := r1.Data.(*model.User)
@@ -385,9 +385,9 @@ func TestUserStoreDelete(t *testing.T) {
u1 := model.User{}
u1.TeamId = model.NewId()
u1.Email = model.NewId()
- Must(store.User().Save(&u1))
+ Must(store.User().Save(utils.T, &u1))
- if err := (<-store.User().PermanentDelete(u1.Id)).Err; err != nil {
+ if err := (<-store.User().PermanentDelete(utils.T, u1.Id)).Err; err != nil {
t.Fatal(err)
}
}
@@ -398,16 +398,16 @@ func TestUserStoreUpdateAuthData(t *testing.T) {
u1 := model.User{}
u1.TeamId = model.NewId()
u1.Email = model.NewId()
- Must(store.User().Save(&u1))
+ Must(store.User().Save(utils.T, &u1))
service := "someservice"
authData := "1"
- if err := (<-store.User().UpdateAuthData(u1.Id, service, authData)).Err; err != nil {
+ if err := (<-store.User().UpdateAuthData(utils.T, u1.Id, service, authData)).Err; err != nil {
t.Fatal(err)
}
- if r1 := <-store.User().GetByEmail(u1.TeamId, u1.Email); r1.Err != nil {
+ if r1 := <-store.User().GetByEmail(utils.T, u1.TeamId, u1.Email); r1.Err != nil {
t.Fatal(r1.Err)
} else {
user := r1.Data.(*model.User)
diff --git a/store/store.go b/store/store.go
index bd840a87d..e50fc23bc 100644
--- a/store/store.go
+++ b/store/store.go
@@ -106,27 +106,27 @@ type PostStore interface {
}
type UserStore interface {
- Save(user *model.User) StoreChannel
- Update(user *model.User, allowRoleUpdate bool) StoreChannel
- UpdateLastPictureUpdate(userId string) StoreChannel
- UpdateLastPingAt(userId string, time int64) StoreChannel
- UpdateLastActivityAt(userId string, time int64) StoreChannel
- UpdateUserAndSessionActivity(userId string, sessionId string, time int64) StoreChannel
- UpdatePassword(userId, newPassword string) StoreChannel
- UpdateAuthData(userId, service, authData string) StoreChannel
- Get(id string) StoreChannel
- GetProfiles(teamId string) StoreChannel
- GetByEmail(teamId string, email string) StoreChannel
- GetByAuth(teamId string, authData string, authService string) StoreChannel
- GetByUsername(teamId string, username string) StoreChannel
- VerifyEmail(userId string) StoreChannel
- GetEtagForProfiles(teamId string) StoreChannel
- UpdateFailedPasswordAttempts(userId string, attempts int) StoreChannel
- GetForExport(teamId string) StoreChannel
- GetTotalUsersCount() StoreChannel
- GetTotalActiveUsersCount() StoreChannel
- GetSystemAdminProfiles() StoreChannel
- PermanentDelete(userId string) StoreChannel
+ Save(T goi18n.TranslateFunc, user *model.User) StoreChannel
+ Update(T goi18n.TranslateFunc, user *model.User, allowRoleUpdate bool) StoreChannel
+ UpdateLastPictureUpdate(T goi18n.TranslateFunc, userId string) StoreChannel
+ UpdateLastPingAt(T goi18n.TranslateFunc, userId string, time int64) StoreChannel
+ UpdateLastActivityAt(T goi18n.TranslateFunc, userId string, time int64) StoreChannel
+ UpdateUserAndSessionActivity(T goi18n.TranslateFunc, userId string, sessionId string, time int64) StoreChannel
+ UpdatePassword(T goi18n.TranslateFunc, userId, newPassword string) StoreChannel
+ UpdateAuthData(T goi18n.TranslateFunc, userId, service, authData string) StoreChannel
+ Get(T goi18n.TranslateFunc, id string) StoreChannel
+ GetProfiles(T goi18n.TranslateFunc, teamId string) StoreChannel
+ GetByEmail(T goi18n.TranslateFunc, teamId string, email string) StoreChannel
+ GetByAuth(T goi18n.TranslateFunc, teamId string, authData string, authService string) StoreChannel
+ GetByUsername(T goi18n.TranslateFunc, teamId string, username string) StoreChannel
+ VerifyEmail(T goi18n.TranslateFunc, userId string) StoreChannel
+ GetEtagForProfiles(T goi18n.TranslateFunc, teamId string) StoreChannel
+ UpdateFailedPasswordAttempts(T goi18n.TranslateFunc, userId string, attempts int) StoreChannel
+ GetForExport(T goi18n.TranslateFunc, teamId string) StoreChannel
+ GetTotalUsersCount(T goi18n.TranslateFunc) StoreChannel
+ GetTotalActiveUsersCount(T goi18n.TranslateFunc) StoreChannel
+ GetSystemAdminProfiles(T goi18n.TranslateFunc) StoreChannel
+ PermanentDelete(T goi18n.TranslateFunc, userId string) StoreChannel
}
type SessionStore interface {