From e522a1c2e49f5d21e45dd66f83d06e10fc3cdb67 Mon Sep 17 00:00:00 2001 From: Harrison Healey Date: Mon, 9 Oct 2017 13:30:59 -0400 Subject: PLT-7811 Standardized team sanitization flow (#7586) * post-4.3 commit (#7581) * reduce store boiler plate (#7585) * fix GetPostsByIds error (#7591) * PLT-7811 Standardized team sanitization flow * Fixed TestGetAllTeamListings * Stopped sanitizing teams for team admins * Removed debug logging * Added TearDown to sanitization tests that needed it --- api/apitestlib.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'api/apitestlib.go') diff --git a/api/apitestlib.go b/api/apitestlib.go index c0fd79ae9..3c64d2430 100644 --- a/api/apitestlib.go +++ b/api/apitestlib.go @@ -4,6 +4,7 @@ package api import ( + "strings" "time" "github.com/mattermost/mattermost-server/api4" @@ -130,8 +131,8 @@ func (me *TestHelper) CreateTeam(client *model.Client) *model.Team { id := model.NewId() team := &model.Team{ DisplayName: "dn_" + id, - Name: "name" + id, - Email: "success+" + id + "@simulator.amazonses.com", + Name: GenerateTestTeamName(), + Email: GenerateTestEmail(), Type: model.TEAM_OPEN, } @@ -308,6 +309,14 @@ func (me *TestHelper) LoginSystemAdmin() { utils.EnableDebugLogForTest() } +func GenerateTestEmail() string { + return strings.ToLower("success+" + model.NewId() + "@simulator.amazonses.com") +} + +func GenerateTestTeamName() string { + return "faketeam" + model.NewRandomString(6) +} + func (me *TestHelper) TearDown() { me.App.Shutdown() } -- cgit v1.2.3-1-g7c22 From aa2b82727f0f1b3edb79f6d31c04b8fd0d718455 Mon Sep 17 00:00:00 2001 From: Chris Date: Wed, 11 Oct 2017 12:16:04 -0700 Subject: fix race condition in tests (#7609) --- api/apitestlib.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'api/apitestlib.go') diff --git a/api/apitestlib.go b/api/apitestlib.go index 3c64d2430..a38c20813 100644 --- a/api/apitestlib.go +++ b/api/apitestlib.go @@ -4,6 +4,7 @@ package api import ( + "net" "strings" "time" @@ -86,7 +87,20 @@ func ReloadConfigForSetup() { *utils.Cfg.TeamSettings.EnableOpenServer = true } +func (me *TestHelper) waitForConnectivity() { + for i := 0; i < 1000; i++ { + _, err := net.Dial("tcp", "localhost"+*utils.Cfg.ServiceSettings.ListenAddress) + if err == nil { + return + } + time.Sleep(time.Millisecond * 20) + } + panic("unable to connect") +} + func (me *TestHelper) InitBasic() *TestHelper { + me.waitForConnectivity() + me.BasicClient = me.CreateClient() me.BasicUser = me.CreateUser(me.BasicClient) me.LoginBasic() @@ -106,6 +120,8 @@ func (me *TestHelper) InitBasic() *TestHelper { } func (me *TestHelper) InitSystemAdmin() *TestHelper { + me.waitForConnectivity() + me.SystemAdminClient = me.CreateClient() me.SystemAdminUser = me.CreateUser(me.SystemAdminClient) me.SystemAdminUser.Password = "Password1" -- cgit v1.2.3-1-g7c22