[MM-19892] Fix failing test TestImportBulkImport (#13003)

Automatic Merge
This commit is contained in:
Christopher Poile
2019-12-04 11:31:52 -05:00
committed by mattermod
parent 72f3bb10c7
commit 6e6a44764c
6 changed files with 20 additions and 12 deletions

View File

@@ -4,6 +4,7 @@
package api4
import (
"encoding/base64"
"encoding/binary"
"fmt"
"net/http"
@@ -11,8 +12,6 @@ import (
"strings"
"testing"
"encoding/base64"
"github.com/mattermost/mattermost-server/v5/app"
"github.com/mattermost/mattermost-server/v5/model"
"github.com/mattermost/mattermost-server/v5/services/mailservice"
@@ -258,7 +257,7 @@ func TestUpdateTeam(t *testing.T) {
defer th.TearDown()
Client := th.Client
team := &model.Team{DisplayName: "Name", Description: "Some description", AllowOpenInvite: false, InviteId: "inviteid0", Name: "z-z-" + model.NewId() + "a", Email: "success+" + model.NewId() + "@simulator.amazonses.com", Type: model.TEAM_OPEN}
team := &model.Team{DisplayName: "Name", Description: "Some description", AllowOpenInvite: false, InviteId: "inviteid0", Name: "z-z-" + model.NewRandomTeamName() + "a", Email: "success+" + model.NewId() + "@simulator.amazonses.com", Type: model.TEAM_OPEN}
team, _ = Client.CreateTeam(team)
team.Description = "updated description"
@@ -377,7 +376,7 @@ func TestPatchTeam(t *testing.T) {
defer th.TearDown()
Client := th.Client
team := &model.Team{DisplayName: "Name", Description: "Some description", CompanyName: "Some company name", AllowOpenInvite: false, InviteId: "inviteid0", Name: "z-z-" + model.NewId() + "a", Email: "success+" + model.NewId() + "@simulator.amazonses.com", Type: model.TEAM_OPEN}
team := &model.Team{DisplayName: "Name", Description: "Some description", CompanyName: "Some company name", AllowOpenInvite: false, InviteId: "inviteid0", Name: "z-z-" + model.NewRandomTeamName() + "a", Email: "success+" + model.NewId() + "@simulator.amazonses.com", Type: model.TEAM_OPEN}
team, _ = Client.CreateTeam(team)
patch := &model.TeamPatch{}
@@ -465,7 +464,7 @@ func TestRegenerateTeamInviteId(t *testing.T) {
defer th.TearDown()
Client := th.Client
team := &model.Team{DisplayName: "Name", Description: "Some description", CompanyName: "Some company name", AllowOpenInvite: false, InviteId: "inviteid0", Name: "z-z-" + model.NewId() + "a", Email: "success+" + model.NewId() + "@simulator.amazonses.com", Type: model.TEAM_OPEN}
team := &model.Team{DisplayName: "Name", Description: "Some description", CompanyName: "Some company name", AllowOpenInvite: false, InviteId: "inviteid0", Name: "z-z-" + model.NewRandomTeamName() + "a", Email: "success+" + model.NewId() + "@simulator.amazonses.com", Type: model.TEAM_OPEN}
team, _ = Client.CreateTeam(team)
assert.NotEqual(t, team.InviteId, "")

View File

@@ -265,7 +265,7 @@ func TestWebSocketStatuses(t *testing.T) {
resp := <-WebSocketClient.ResponseChannel
require.Equal(t, resp.Status, model.STATUS_OK, "should have responded OK to authentication challenge")
team := model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN}
team := model.Team{DisplayName: "Name", Name: "z-z-" + model.NewRandomTeamName() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN}
rteam, _ := Client.CreateTeam(&team)
user := model.User{Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "passwd1"}

View File

@@ -595,7 +595,7 @@ func TestImportImportChannel(t *testing.T) {
scheme2 := th.SetupChannelScheme()
// Import a Team.
teamName := model.NewId()
teamName := model.NewRandomTeamName()
th.App.ImportTeam(&TeamImportData{
Name: &teamName,
DisplayName: ptrStr("Display Name"),
@@ -862,7 +862,7 @@ func TestImportImportUser(t *testing.T) {
data.Password = ptrStr("TestPassword")
// Test team and channel memberships
teamName := model.NewId()
teamName := model.NewRandomTeamName()
th.App.ImportTeam(&TeamImportData{
Name: &teamName,
DisplayName: ptrStr("Display Name"),
@@ -1570,7 +1570,7 @@ func TestImportImportPost(t *testing.T) {
defer th.TearDown()
// Create a Team.
teamName := model.NewId()
teamName := model.NewRandomTeamName()
th.App.ImportTeam(&TeamImportData{
Name: &teamName,
DisplayName: ptrStr("Display Name"),
@@ -2510,7 +2510,7 @@ func TestImportPostAndRepliesWithAttachments(t *testing.T) {
defer th.TearDown()
// Create a Team.
teamName := model.NewId()
teamName := model.NewRandomTeamName()
th.App.ImportTeam(&TeamImportData{
Name: &teamName,
DisplayName: ptrStr("Display Name"),

View File

@@ -143,7 +143,7 @@ func TestImportBulkImport(t *testing.T) {
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableCustomEmoji = true })
teamName := model.NewId()
teamName := model.NewRandomTeamName()
channelName := model.NewId()
username := model.NewId()
username2 := model.NewId()

View File

@@ -146,6 +146,15 @@ func NewId() string {
return b.String()
}
// NewRandomTeamName is a NewId that will be a valid team name.
func NewRandomTeamName() string {
teamName := NewId()
for IsReservedTeamName(teamName) {
teamName = NewId()
}
return teamName
}
func NewRandomString(length int) string {
var b bytes.Buffer
str := make([]byte, length+8)

View File

@@ -302,7 +302,7 @@ func createTeam(ss store.Store, userId string) *model.Team {
m.DisplayName = "DisplayName"
m.Type = model.TEAM_OPEN
m.Email = "test@example.com"
m.Name = "z-z-z" + model.NewId() + "b"
m.Name = "z-z-z" + model.NewRandomTeamName() + "b"
t, _ := ss.Team().Save(&m)
return t
}