[MM-16512] Migrate Token.Save to Sync by default (#11353)

* [MM-16512] Migrate Token.Save to Sync by default

* refactor: formatting

* test: add checks for errors while saving tokens

* test: fixup
Этот коммит содержится в:
krjn
2019-06-26 10:36:41 +00:00
коммит произвёл Sudheer
родитель 2327ab8854
Коммит 72d482de0e
11 изменённых файлов: 42 добавлений и 44 удалений

Просмотреть файл

@@ -571,7 +571,7 @@ func TestCreateUserWithToken(t *testing.T) {
TOKEN_TYPE_VERIFY_EMAIL,
model.MapToJson(map[string]string{"teamId": th.BasicTeam.Id, "email": user.Email}),
)
<-th.App.Srv.Store.Token().Save(token)
require.Nil(t, th.App.Srv.Store.Token().Save(token))
defer th.App.DeleteToken(token)
if _, err := th.App.CreateUserWithToken(&user, token.Token); err == nil {
t.Fatal("Should fail on bad token type")
@@ -584,7 +584,7 @@ func TestCreateUserWithToken(t *testing.T) {
model.MapToJson(map[string]string{"teamId": th.BasicTeam.Id, "email": user.Email}),
)
token.CreateAt = model.GetMillis() - TEAM_INVITATION_EXPIRY_TIME - 1
<-th.App.Srv.Store.Token().Save(token)
require.Nil(t, th.App.Srv.Store.Token().Save(token))
defer th.App.DeleteToken(token)
if _, err := th.App.CreateUserWithToken(&user, token.Token); err == nil {
t.Fatal("Should fail on expired token")
@@ -596,7 +596,7 @@ func TestCreateUserWithToken(t *testing.T) {
TOKEN_TYPE_TEAM_INVITATION,
model.MapToJson(map[string]string{"teamId": model.NewId(), "email": user.Email}),
)
<-th.App.Srv.Store.Token().Save(token)
require.Nil(t, th.App.Srv.Store.Token().Save(token))
defer th.App.DeleteToken(token)
if _, err := th.App.CreateUserWithToken(&user, token.Token); err == nil {
t.Fatal("Should fail on bad team id")
@@ -609,7 +609,7 @@ func TestCreateUserWithToken(t *testing.T) {
TOKEN_TYPE_TEAM_INVITATION,
model.MapToJson(map[string]string{"teamId": th.BasicTeam.Id, "email": invitationEmail}),
)
<-th.App.Srv.Store.Token().Save(token)
require.Nil(t, th.App.Srv.Store.Token().Save(token))
newUser, err := th.App.CreateUserWithToken(&user, token.Token)
if err != nil {
t.Log(err)