Commit 5b2ec623 authored by =Corey Hulen's avatar =Corey Hulen

PLT-7 adding loc db calls for team table

parent ca33812c
......@@ -387,7 +387,7 @@ func (c *Context) setTeamURL(url string, valid bool) {
}
func (c *Context) SetTeamURLFromSession() {
if result := <-Srv.Store.Team().Get(c.Session.TeamId); result.Err == nil {
if result := <-Srv.Store.Team().Get(c.T, c.Session.TeamId); result.Err == nil {
c.setTeamURL(c.GetSiteURL()+"/"+result.Data.(*model.Team).Name, true)
}
}
......
......@@ -6,10 +6,12 @@ package api
import (
"archive/zip"
"encoding/json"
"github.com/mattermost/platform/model"
"github.com/mattermost/platform/utils"
"io"
"os"
"github.com/mattermost/platform/model"
"github.com/mattermost/platform/utils"
goi18n "github.com/nicksnyder/go-i18n/i18n"
)
const (
......@@ -51,19 +53,19 @@ func ExportOptionsFromJson(data io.Reader) *ExportOptions {
return &o
}
func ExportToFile(options *ExportOptions) (link string, err *model.AppError) {
func ExportToFile(T goi18n.TranslateFunc, options *ExportOptions) (link string, err *model.AppError) {
// Open file for export
if file, err := openFileWriteStream(EXPORT_PATH + EXPORT_FILENAME); err != nil {
return "", err
} else {
defer closeFileWriteStream(file)
ExportToWriter(file, options)
ExportToWriter(T, file, options)
}
return "/api/v1/files/get_export", nil
}
func ExportToWriter(w io.Writer, options *ExportOptions) *model.AppError {
func ExportToWriter(T goi18n.TranslateFunc, w io.Writer, options *ExportOptions) *model.AppError {
// Open a writer to write to zip file
zipWriter := zip.NewWriter(w)
defer zipWriter.Close()
......@@ -78,23 +80,23 @@ func ExportToWriter(w io.Writer, options *ExportOptions) *model.AppError {
}
// Export Teams
ExportTeams(zipWriter, options)
ExportTeams(T, zipWriter, options)
return nil
}
func ExportTeams(writer ExportWriter, options *ExportOptions) *model.AppError {
func ExportTeams(T goi18n.TranslateFunc, writer ExportWriter, options *ExportOptions) *model.AppError {
// Get the teams
var teams []*model.Team
if len(options.TeamsToExport) == 0 {
if result := <-Srv.Store.Team().GetAll(); result.Err != nil {
if result := <-Srv.Store.Team().GetAll(T); result.Err != nil {
return result.Err
} else {
teams = result.Data.([]*model.Team)
}
} else {
for _, teamId := range options.TeamsToExport {
if result := <-Srv.Store.Team().Get(teamId); result.Err != nil {
if result := <-Srv.Store.Team().Get(T, teamId); result.Err != nil {
return result.Err
} else {
team := result.Data.(*model.Team)
......
......@@ -205,7 +205,7 @@ func CreateWebhookPost(c *Context, channelId, text, overrideUsername, overrideIc
func handlePostEventsAndForget(c *Context, post *model.Post, triggerWebhooks bool) {
go func() {
tchan := Srv.Store.Team().Get(c.Session.TeamId)
tchan := Srv.Store.Team().Get(c.T, c.Session.TeamId)
cchan := Srv.Store.Channel().Get(post.ChannelId)
uchan := Srv.Store.User().Get(post.UserId)
......
......@@ -128,7 +128,7 @@ func createTeamFromSSO(c *Context, w http.ResponseWriter, r *http.Request) {
}
}
if result := <-Srv.Store.Team().Save(team); result.Err != nil {
if result := <-Srv.Store.Team().Save(c.T, team); result.Err != nil {
c.Err = result.Err
return
} else {
......@@ -209,7 +209,7 @@ func createTeamFromSignup(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
if result := <-Srv.Store.Team().Save(&teamSignup.Team); result.Err != nil {
if result := <-Srv.Store.Team().Save(c.T, &teamSignup.Team); result.Err != nil {
c.Err = result.Err
return
} else {
......@@ -264,7 +264,7 @@ func CreateTeam(c *Context, team *model.Team) *model.Team {
return nil
}
if result := <-Srv.Store.Team().Save(team); result.Err != nil {
if result := <-Srv.Store.Team().Save(c.T, team); result.Err != nil {
c.Err = result.Err
return nil
} else {
......@@ -313,7 +313,7 @@ func getAll(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
if result := <-Srv.Store.Team().GetAll(); result.Err != nil {
if result := <-Srv.Store.Team().GetAll(c.T); result.Err != nil {
c.Err = result.Err
return
} else {
......@@ -382,7 +382,7 @@ func FindTeamByName(c *Context, name string, all string) bool {
return false
}
if result := <-Srv.Store.Team().GetByName(name); result.Err != nil {
if result := <-Srv.Store.Team().GetByName(c.T, name); result.Err != nil {
return false
} else {
return true
......@@ -402,7 +402,7 @@ func findTeams(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
if result := <-Srv.Store.Team().GetTeamsForEmail(email); result.Err != nil {
if result := <-Srv.Store.Team().GetTeamsForEmail(c.T, email); result.Err != nil {
c.Err = result.Err
return
} else {
......@@ -433,7 +433,7 @@ func emailTeams(c *Context, w http.ResponseWriter, r *http.Request) {
bodyPage := NewServerTemplatePage("find_teams_body")
bodyPage.ClientCfg["SiteURL"] = c.GetSiteURL()
if result := <-Srv.Store.Team().GetTeamsForEmail(email); result.Err != nil {
if result := <-Srv.Store.Team().GetTeamsForEmail(c.T, email); result.Err != nil {
c.Err = result.Err
} else {
teams := result.Data.([]*model.Team)
......@@ -461,7 +461,7 @@ func inviteMembers(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
tchan := Srv.Store.Team().Get(c.Session.TeamId)
tchan := Srv.Store.Team().Get(c.T, c.Session.TeamId)
uchan := Srv.Store.User().Get(c.Session.UserId)
var team *model.Team
......@@ -561,7 +561,7 @@ func updateTeam(c *Context, w http.ResponseWriter, r *http.Request) {
}
var oldTeam *model.Team
if result := <-Srv.Store.Team().Get(team.Id); result.Err != nil {
if result := <-Srv.Store.Team().Get(c.T, team.Id); result.Err != nil {
c.Err = result.Err
return
} else {
......@@ -576,7 +576,7 @@ func updateTeam(c *Context, w http.ResponseWriter, r *http.Request) {
oldTeam.AllowedDomains = team.AllowedDomains
//oldTeam.Type = team.Type
if result := <-Srv.Store.Team().Update(oldTeam); result.Err != nil {
if result := <-Srv.Store.Team().Update(c.T, oldTeam); result.Err != nil {
c.Err = result.Err
return
}
......@@ -592,7 +592,7 @@ func PermanentDeleteTeam(c *Context, team *model.Team) *model.AppError {
c.LogAuditWithUserId("", fmt.Sprintf("attempt teamId=%v", team.Id))
team.DeleteAt = model.GetMillis()
if result := <-Srv.Store.Team().Update(team); result.Err != nil {
if result := <-Srv.Store.Team().Update(c.T, team); result.Err != nil {
return result.Err
}
......@@ -609,7 +609,7 @@ func PermanentDeleteTeam(c *Context, team *model.Team) *model.AppError {
return result.Err
}
if result := <-Srv.Store.Team().PermanentDelete(team.Id); result.Err != nil {
if result := <-Srv.Store.Team().PermanentDelete(c.T, team.Id); result.Err != nil {
return result.Err
}
......@@ -625,7 +625,7 @@ func getMyTeam(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
if result := <-Srv.Store.Team().Get(c.Session.TeamId); result.Err != nil {
if result := <-Srv.Store.Team().Get(c.T, c.Session.TeamId); result.Err != nil {
c.Err = result.Err
return
} else if HandleEtag(result.Data.(*model.Team).Etag(), w, r) {
......@@ -714,7 +714,7 @@ func exportTeam(c *Context, w http.ResponseWriter, r *http.Request) {
options := ExportOptionsFromJson(r.Body)
if link, err := ExportToFile(options); err != nil {
if link, err := ExportToFile(c.T, options); err != nil {
c.Err = err
return
} else {
......
......@@ -84,7 +84,7 @@ func createUser(c *Context, w http.ResponseWriter, r *http.Request) {
var team *model.Team
if result := <-Srv.Store.Team().Get(user.TeamId); result.Err != nil {
if result := <-Srv.Store.Team().Get(c.T, user.TeamId); result.Err != nil {
c.Err = result.Err
return
} else {
......@@ -264,7 +264,7 @@ func CreateOAuthUser(c *Context, w http.ResponseWriter, r *http.Request, service
if team.Email == "" {
team.Email = user.Email
if result := <-Srv.Store.Team().Update(team); result.Err != nil {
if result := <-Srv.Store.Team().Update(c.T, team); result.Err != nil {
c.Err = result.Err
return nil
}
......@@ -404,7 +404,7 @@ func LoginById(c *Context, w http.ResponseWriter, r *http.Request, userId, passw
func LoginByEmail(c *Context, w http.ResponseWriter, r *http.Request, email, name, password, deviceId string) *model.User {
var team *model.Team
if result := <-Srv.Store.Team().GetByName(name); result.Err != nil {
if result := <-Srv.Store.Team().GetByName(c.T, name); result.Err != nil {
c.Err = result.Err
return nil
} else {
......@@ -659,7 +659,7 @@ func loginLdap(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
teamc := Srv.Store.Team().GetByName(teamName)
teamc := Srv.Store.Team().GetByName(c.T, teamName)
ldapInterface := einterfaces.GetLdapInterface()
if ldapInterface == nil {
......@@ -1134,7 +1134,7 @@ func updateUser(c *Context, w http.ResponseWriter, r *http.Request) {
rusers := result.Data.([2]*model.User)
if rusers[0].Email != rusers[1].Email {
if tresult := <-Srv.Store.Team().Get(rusers[1].TeamId); tresult.Err != nil {
if tresult := <-Srv.Store.Team().Get(c.T, rusers[1].TeamId); tresult.Err != nil {
l4g.Error(tresult.Err.Message)
} else {
team := tresult.Data.(*model.Team)
......@@ -1195,7 +1195,7 @@ func updatePassword(c *Context, w http.ResponseWriter, r *http.Request) {
user := result.Data.(*model.User)
tchan := Srv.Store.Team().Get(user.TeamId)
tchan := Srv.Store.Team().Get(c.T, user.TeamId)
if user.AuthData != "" {
c.LogAudit("failed - tried to update user password who was logged in through oauth")
......@@ -1494,7 +1494,7 @@ func sendPasswordReset(c *Context, w http.ResponseWriter, r *http.Request) {
}
var team *model.Team
if result := <-Srv.Store.Team().GetByName(name); result.Err != nil {
if result := <-Srv.Store.Team().GetByName(c.T, name); result.Err != nil {
c.Err = result.Err
return
} else {
......@@ -1583,7 +1583,7 @@ func resetPassword(c *Context, w http.ResponseWriter, r *http.Request) {
c.LogAuditWithUserId(userId, "attempt")
var team *model.Team
if result := <-Srv.Store.Team().GetByName(name); result.Err != nil {
if result := <-Srv.Store.Team().GetByName(c.T, name); result.Err != nil {
c.Err = result.Err
return
} else {
......@@ -1822,7 +1822,7 @@ func GetAuthorizationCode(c *Context, service, teamName string, props map[string
return authUrl, nil
}
func AuthorizeOAuthUser(service, code, state, redirectUri string) (io.ReadCloser, *model.Team, map[string]string, *model.AppError) {
func AuthorizeOAuthUser(T goi18n.TranslateFunc, service, code, state, redirectUri string) (io.ReadCloser, *model.Team, map[string]string, *model.AppError) {
sso := utils.Cfg.GetSSOService(service)
if sso == nil || !sso.Enable {
return nil, nil, nil, model.NewAppError("AuthorizeOAuthUser", "Unsupported OAuth service provider", "service="+service)
......@@ -1847,7 +1847,7 @@ func AuthorizeOAuthUser(service, code, state, redirectUri string) (io.ReadCloser
return nil, nil, nil, model.NewAppError("AuthorizeOAuthUser", "Invalid state; missing team name", "")
}
tchan := Srv.Store.Team().GetByName(teamName)
tchan := Srv.Store.Team().GetByName(T, teamName)
p := url.Values{}
p.Set("client_id", sso.Id)
......@@ -1945,7 +1945,7 @@ func switchToSSO(c *Context, w http.ResponseWriter, r *http.Request) {
c.LogAudit("attempt")
var team *model.Team
if result := <-Srv.Store.Team().GetByName(teamName); result.Err != nil {
if result := <-Srv.Store.Team().GetByName(c.T, teamName); result.Err != nil {
c.LogAudit("fail - couldn't get team")
c.Err = result.Err
return
......@@ -2049,7 +2049,7 @@ func switchToEmail(c *Context, w http.ResponseWriter, r *http.Request) {
c.LogAudit("attempt")
var team *model.Team
if result := <-Srv.Store.Team().GetByName(teamName); result.Err != nil {
if result := <-Srv.Store.Team().GetByName(c.T, teamName); result.Err != nil {
c.LogAudit("fail - couldn't get team")
c.Err = result.Err
return
......
......@@ -70,7 +70,7 @@ func manualTest(c *api.Context, w http.ResponseWriter, r *http.Request) {
Type: model.TEAM_OPEN,
}
if result := <-api.Srv.Store.Team().Save(team); result.Err != nil {
if result := <-api.Srv.Store.Team().Save(c.T, team); result.Err != nil {
c.Err = result.Err
return
} else {
......
......@@ -301,7 +301,7 @@ func cmdCreateUser() {
splits := strings.Split(strings.Replace(flagEmail, "@", " ", -1), " ")
user.Username = splits[0]
if result := <-api.Srv.Store.Team().GetByName(flagTeamName); result.Err != nil {
if result := <-api.Srv.Store.Team().GetByName(utils.T, flagTeamName); result.Err != nil {
l4g.Error("%v", result.Err)
flushLogAndExit(1)
} else {
......@@ -358,7 +358,7 @@ func cmdAssignRole() {
c.IpAddress = "cmd_line"
var team *model.Team
if result := <-api.Srv.Store.Team().GetByName(flagTeamName); result.Err != nil {
if result := <-api.Srv.Store.Team().GetByName(utils.T, flagTeamName); result.Err != nil {
l4g.Error("%v", result.Err)
flushLogAndExit(1)
} else {
......@@ -412,7 +412,7 @@ func cmdResetPassword() {
c.IpAddress = "cmd_line"
var team *model.Team
if result := <-api.Srv.Store.Team().GetByName(flagTeamName); result.Err != nil {
if result := <-api.Srv.Store.Team().GetByName(utils.T, flagTeamName); result.Err != nil {
l4g.Error("%v", result.Err)
flushLogAndExit(1)
} else {
......@@ -455,7 +455,7 @@ func cmdPermDeleteUser() {
c.IpAddress = "cmd_line"
var team *model.Team
if result := <-api.Srv.Store.Team().GetByName(flagTeamName); result.Err != nil {
if result := <-api.Srv.Store.Team().GetByName(utils.T, flagTeamName); result.Err != nil {
l4g.Error("%v", result.Err)
flushLogAndExit(1)
} else {
......@@ -506,7 +506,7 @@ func cmdPermDeleteTeam() {
c.IpAddress = "cmd_line"
var team *model.Team
if result := <-api.Srv.Store.Team().GetByName(flagTeamName); result.Err != nil {
if result := <-api.Srv.Store.Team().GetByName(utils.T, flagTeamName); result.Err != nil {
l4g.Error("%v", result.Err)
flushLogAndExit(1)
} else {
......
......@@ -765,7 +765,7 @@ func TestUserCountsWithPostsByDay(t *testing.T) {
t1.Name = "a" + model.NewId() + "b"
t1.Email = model.NewId() + "@nowhere.com"
t1.Type = model.TEAM_OPEN
t1 = Must(store.Team().Save(t1)).(*model.Team)
t1 = Must(store.Team().Save(utils.T, t1)).(*model.Team)
c1 := &model.Channel{}
c1.TeamId = t1.Id
......@@ -825,7 +825,7 @@ func TestPostCountsByDay(t *testing.T) {
t1.Name = "a" + model.NewId() + "b"
t1.Email = model.NewId() + "@nowhere.com"
t1.Type = model.TEAM_OPEN
t1 = Must(store.Team().Save(t1)).(*model.Team)
t1 = Must(store.Team().Save(utils.T, t1)).(*model.Team)
c1 := &model.Channel{}
c1.TeamId = t1.Id
......
......@@ -6,6 +6,7 @@ package store
import (
"github.com/mattermost/platform/model"
"github.com/mattermost/platform/utils"
goi18n "github.com/nicksnyder/go-i18n/i18n"
)
type SqlTeamStore struct {
......@@ -37,7 +38,7 @@ func (s SqlTeamStore) CreateIndexesIfNotExists() {
s.CreateIndexIfNotExists("idx_teams_invite_id", "Teams", "InviteId")
}
func (s SqlTeamStore) Save(team *model.Team) StoreChannel {
func (s SqlTeamStore) Save(T goi18n.TranslateFunc, team *model.Team) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
......@@ -76,7 +77,7 @@ func (s SqlTeamStore) Save(team *model.Team) StoreChannel {
return storeChannel
}
func (s SqlTeamStore) Update(team *model.Team) StoreChannel {
func (s SqlTeamStore) Update(T goi18n.TranslateFunc, team *model.Team) StoreChannel {
storeChannel := make(StoreChannel)
......@@ -117,7 +118,7 @@ func (s SqlTeamStore) Update(team *model.Team) StoreChannel {
return storeChannel
}
func (s SqlTeamStore) UpdateDisplayName(name string, teamId string) StoreChannel {
func (s SqlTeamStore) UpdateDisplayName(T goi18n.TranslateFunc, name string, teamId string) StoreChannel {
storeChannel := make(StoreChannel)
......@@ -137,7 +138,7 @@ func (s SqlTeamStore) UpdateDisplayName(name string, teamId string) StoreChannel
return storeChannel
}
func (s SqlTeamStore) Get(id string) StoreChannel {
func (s SqlTeamStore) Get(T goi18n.TranslateFunc, id string) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
......@@ -163,7 +164,7 @@ func (s SqlTeamStore) Get(id string) StoreChannel {
return storeChannel
}
func (s SqlTeamStore) GetByInviteId(inviteId string) StoreChannel {
func (s SqlTeamStore) GetByInviteId(T goi18n.TranslateFunc, inviteId string) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
......@@ -192,7 +193,7 @@ func (s SqlTeamStore) GetByInviteId(inviteId string) StoreChannel {
return storeChannel
}
func (s SqlTeamStore) GetByName(name string) StoreChannel {
func (s SqlTeamStore) GetByName(T goi18n.TranslateFunc, name string) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
......@@ -217,7 +218,7 @@ func (s SqlTeamStore) GetByName(name string) StoreChannel {
return storeChannel
}
func (s SqlTeamStore) GetTeamsForEmail(email string) StoreChannel {
func (s SqlTeamStore) GetTeamsForEmail(T goi18n.TranslateFunc, email string) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
......@@ -243,7 +244,7 @@ func (s SqlTeamStore) GetTeamsForEmail(email string) StoreChannel {
return storeChannel
}
func (s SqlTeamStore) GetAll() StoreChannel {
func (s SqlTeamStore) GetAll(T goi18n.TranslateFunc) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
......@@ -269,7 +270,7 @@ func (s SqlTeamStore) GetAll() StoreChannel {
return storeChannel
}
func (s SqlTeamStore) GetAllTeamListing() StoreChannel {
func (s SqlTeamStore) GetAllTeamListing(T goi18n.TranslateFunc) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
......@@ -301,7 +302,7 @@ func (s SqlTeamStore) GetAllTeamListing() StoreChannel {
return storeChannel
}
func (s SqlTeamStore) PermanentDelete(teamId string) StoreChannel {
func (s SqlTeamStore) PermanentDelete(T goi18n.TranslateFunc, teamId string) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
......
......@@ -5,6 +5,7 @@ package store
import (
"github.com/mattermost/platform/model"
"github.com/mattermost/platform/utils"
"testing"
"time"
)
......@@ -18,16 +19,16 @@ func TestTeamStoreSave(t *testing.T) {
o1.Email = model.NewId() + "@nowhere.com"
o1.Type = model.TEAM_OPEN
if err := (<-store.Team().Save(&o1)).Err; err != nil {
if err := (<-store.Team().Save(utils.T, &o1)).Err; err != nil {
t.Fatal("couldn't save item", err)
}
if err := (<-store.Team().Save(&o1)).Err; err == nil {
if err := (<-store.Team().Save(utils.T, &o1)).Err; err == nil {
t.Fatal("shouldn't be able to update from save")
}
o1.Id = ""
if err := (<-store.Team().Save(&o1)).Err; err == nil {
if err := (<-store.Team().Save(utils.T, &o1)).Err; err == nil {
t.Fatal("should be unique domain")
}
}
......@@ -40,23 +41,23 @@ func TestTeamStoreUpdate(t *testing.T) {
o1.Name = "a" + model.NewId() + "b"
o1.Email = model.NewId() + "@nowhere.com"
o1.Type = model.TEAM_OPEN
if err := (<-store.Team().Save(&o1)).Err; err != nil {
if err := (<-store.Team().Save(utils.T, &o1)).Err; err != nil {
t.Fatal(err)
}
time.Sleep(100 * time.Millisecond)
if err := (<-store.Team().Update(&o1)).Err; err != nil {
if err := (<-store.Team().Update(utils.T, &o1)).Err; err != nil {
t.Fatal(err)
}
o1.Id = "missing"
if err := (<-store.Team().Update(&o1)).Err; err == nil {
if err := (<-store.Team().Update(utils.T, &o1)).Err; err == nil {
t.Fatal("Update should have failed because of missing key")
}
o1.Id = model.NewId()
if err := (<-store.Team().Update(&o1)).Err; err == nil {
if err := (<-store.Team().Update(utils.T, &o1)).Err; err == nil {
t.Fatal("Update should have faile because id change")
}
}
......@@ -69,15 +70,15 @@ func TestTeamStoreUpdateDisplayName(t *testing.T) {
o1.Name = "a" + model.NewId() + "b"
o1.Email = model.NewId() + "@nowhere.com"
o1.Type = model.TEAM_OPEN
o1 = (<-store.Team().Save(o1)).Data.(*model.Team)
o1 = (<-store.Team().Save(utils.T, o1)).Data.(*model.Team)
newDisplayName := "NewDisplayName"
if err := (<-store.Team().UpdateDisplayName(newDisplayName, o1.Id)).Err; err != nil {
if err := (<-store.Team().UpdateDisplayName(utils.T, newDisplayName, o1.Id)).Err; err != nil {
t.Fatal(err)
}
ro1 := (<-store.Team().Get(o1.Id)).Data.(*model.Team)
ro1 := (<-store.Team().Get(utils.T, o1.Id)).Data.(*model.Team)
if ro1.DisplayName != newDisplayName {
t.Fatal("DisplayName not updated")
}
......@@ -91,9 +92,9 @@ func TestTeamStoreGet(t *testing.T) {
o1.Name = "a" + model.NewId() + "b"
o1.Email = model.NewId() + "@nowhere.com"
o1.Type = model.TEAM_OPEN
Must(store.Team().Save(&o1))
Must(store.Team().Save(utils.T, &o1))
if r1 := <-store.Team().Get(o1.Id); r1.Err != nil {
if r1 := <-store.Team().Get(utils.T, o1.Id); r1.Err != nil {
t.Fatal(r1.Err)
} else {
if r1.Data.(*model.Team).ToJson() != o1.ToJson() {
......@@ -101,7 +102,7 @@ func TestTeamStoreGet(t *testing.T) {
}
}
if err := (<-store.Team().Get("")).Err; err == nil {
if err := (<-store.Team().Get(utils.T, "")).Err; err == nil {
t.Fatal("Missing id should have failed")
}
}
......@@ -115,11 +116,11 @@ func TestTeamStoreGetByName(t *testing.T) {
o1.Email = model.NewId() + "@nowhere.com"
o1.Type = model.TEAM_OPEN
if err := (<-store.Team().Save(&o1)).Err; err != nil {
if err := (<-store.Team().Save(utils.T, &o1)).Err; err != nil {
t.Fatal(err)
}
if r1 := <-store.Team().GetByName(o1.Name); r1.Err != nil {
if r1 := <-store.Team().GetByName(utils.T, o1.Name); r1.Err != nil {
t.Fatal(r1.Err)
} else {
if r1.Data.(*model.Team).ToJson() != o1.ToJson() {
......@@ -127,7 +128,7 @@ func TestTeamStoreGetByName(t *testing.T) {
}
}
if err := (<-store.Team().GetByName("")).Err; err == nil {
if err := (<-store.Team().GetByName(utils.T, "")).Err; err == nil {
t.Fatal("Missing id should have failed")
}
}
......@@ -142,7 +143,7 @@ func TestTeamStoreGetByIniviteId(t *testing.T) {
o1.Type = model.TEAM_OPEN
o1.InviteId = model.NewId()
if err := (<-store.Team().Save(&o1)).Err; err != nil {
if err := (<-store.Team().Save(utils.T, &o1)).Err; err != nil {
t.Fatal(err)
}
......@@ -152,11 +153,11 @@ func TestTeamStoreGetByIniviteId(t *testing.T) {
o2.Email = model.NewId() + "@nowhere.com"
o2.Type = model.TEAM_OPEN
if err := (<-store.Team().Save(&o2)).Err; err != nil {
if err := (<-store.Team().Save(utils.T, &o2)).Err; err != nil {
t.Fatal(err)
}
if r1 := <-store.Team().GetByInviteId(o1.InviteId); r1.Err != nil {
if r1 := <-store.Team().GetByInviteId(utils.T, o1.InviteId); r1.Err != nil {
t.Fatal(r1.Err)
} else {
if r1.Data.(*model.Team).ToJson() != o1.ToJson() {
......@@ -165,9 +166,9 @@ func TestTeamStoreGetByIniviteId(t *testing.T) {
}
o2.InviteId = ""
<-store.Team().Update(&o2)
<-store.Team().Update(utils.T, &o2)
if r1 := <-store.Team().GetByInviteId(o2.Id); r1.Err != nil {
if r1 := <-store.Team().GetByInviteId(utils.T, o2.Id); r1.Err != nil {
t.Fatal(r1.Err)
} else {
if r1.Data.(*model.Team).Id != o2.Id {
......@@ -175,7 +176,7 @@ func TestTeamStoreGetByIniviteId(t *testing.T) {
}
}
if err := (<-store.Team().GetByInviteId("")).Err; err == nil {
if err := (<-store.Team().GetByInviteId(utils.T, "")).Err; err == nil {
t.Fatal("Missing id should have failed")
}
}
......@@ -188,14 +189,14 @@ func TestTeamStoreGetForEmail(t *testing.T) {
o1.Name = "a" + model.NewId() + "b"
o1.Email = model.NewId() + "@nowhere.com"
o1.Type = model.TEAM_OPEN
Must(store.Team().Save(&o1))
Must(store.Team().Save(utils.T, &o1))
u1 := model.User{}
u1.TeamId = o1.Id
u1.Email = model.NewId()
Must(store.User().Save(&u1))
if r1 := <-store.Team().GetTeamsForEmail(u1.Email); r1.Err != nil {
if r1 := <-store.Team().GetTeamsForEmail(utils.T, u1.Email); r1.Err != nil {
t.Fatal(r1.Err)
} else {
teams := r1.Data.([]*model.Team)
......@@ -205,7 +206,7 @@ func TestTeamStoreGetForEmail(t *testing.T) {
}
}
if r1 := <-store.Team().GetTeamsForEmail("missing"); r1.Err != nil {
if r1 := <-store.Team().GetTeamsForEmail(utils.T, "missing"); r1.Err != nil {
t.Fatal(r1.Err)
}
}
......@@ -219,16 +220,16 @@ func TestAllTeamListing(t *testing.T) {
o1.Email = model.NewId() + "@nowhere.com"
o1.Type = model.TEAM_OPEN
o1.AllowTeamListing = true
Must(store.Team().Save(&o1))
Must(store.Team().Save(utils.T, &o1))
o2 := model.Team{}
o2.DisplayName = "DisplayName"