Various unit test related improvements (#9865)

* api4: improved error handling

* system_store: more logs

* integrate go-junit-report into test-te/test-ee

* add CI_MINIO_HOST and CI_INBUCKET_HOST instead of CI_HOST

* comment re: minio configuration issue

* fix TestStartServerPortUnavailable to pass even when root can bind to :21

* skip TestFindManifest_FolderPermission while running as root
Этот коммит содержится в:
Jesse Hallam
2018-11-28 09:05:39 -05:00
коммит произвёл GitHub
родитель c24c518a14
Коммит 136d8ca5c4
9 изменённых файлов: 63 добавлений и 27 удалений

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

@@ -218,6 +218,7 @@ func (me *TestHelper) InitBasic() *TestHelper {
me.TeamAdminUser = me.CreateUser()
me.App.UpdateUserRoles(me.TeamAdminUser.Id, model.SYSTEM_USER_ROLE_ID, false)
me.LoginTeamAdmin()
me.BasicTeam = me.CreateTeam()
me.BasicChannel = me.CreatePublicChannel()
me.BasicPrivateChannel = me.CreatePrivateChannel()
@@ -285,7 +286,10 @@ func (me *TestHelper) CreateTeamWithClient(client *model.Client4) *model.Team {
}
utils.DisableDebugLogForTest()
rteam, _ := client.CreateTeam(team)
rteam, resp := client.CreateTeam(team)
if resp.Error != nil {
panic(resp.Error)
}
utils.EnableDebugLogForTest()
return rteam
}
@@ -337,7 +341,10 @@ func (me *TestHelper) CreateChannelWithClientAndTeam(client *model.Client4, chan
}
utils.DisableDebugLogForTest()
rchannel, _ := client.CreateChannel(channel)
rchannel, resp := client.CreateChannel(channel)
if resp.Error != nil {
panic(resp.Error)
}
utils.EnableDebugLogForTest()
return rchannel
}
@@ -447,25 +454,37 @@ func (me *TestHelper) LoginSystemAdmin() {
func (me *TestHelper) LoginBasicWithClient(client *model.Client4) {
utils.DisableDebugLogForTest()
client.Login(me.BasicUser.Email, me.BasicUser.Password)
_, resp := client.Login(me.BasicUser.Email, me.BasicUser.Password)
if resp.Error != nil {
panic(resp.Error)
}
utils.EnableDebugLogForTest()
}
func (me *TestHelper) LoginBasic2WithClient(client *model.Client4) {
utils.DisableDebugLogForTest()
client.Login(me.BasicUser2.Email, me.BasicUser2.Password)
_, resp := client.Login(me.BasicUser2.Email, me.BasicUser2.Password)
if resp.Error != nil {
panic(resp.Error)
}
utils.EnableDebugLogForTest()
}
func (me *TestHelper) LoginTeamAdminWithClient(client *model.Client4) {
utils.DisableDebugLogForTest()
client.Login(me.TeamAdminUser.Email, me.TeamAdminUser.Password)
_, resp := client.Login(me.TeamAdminUser.Email, me.TeamAdminUser.Password)
if resp.Error != nil {
panic(resp.Error)
}
utils.EnableDebugLogForTest()
}
func (me *TestHelper) LoginSystemAdminWithClient(client *model.Client4) {
utils.DisableDebugLogForTest()
client.Login(me.SystemAdminUser.Email, me.SystemAdminUser.Password)
_, resp := client.Login(me.SystemAdminUser.Email, me.SystemAdminUser.Password)
if resp.Error != nil {
panic(resp.Error)
}
utils.EnableDebugLogForTest()
}

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

@@ -430,7 +430,7 @@ func TestEmailTest(t *testing.T) {
CheckErrorMessage(t, resp, "api.admin.test_email.missing_server")
CheckBadRequestStatus(t, resp)
inbucket_host := os.Getenv("CI_HOST")
inbucket_host := os.Getenv("CI_INBUCKET_HOST")
if inbucket_host == "" {
inbucket_host = "dockerhost"
}
@@ -665,7 +665,7 @@ func TestS3TestConnection(t *testing.T) {
defer th.TearDown()
Client := th.Client
s3Host := os.Getenv("CI_HOST")
s3Host := os.Getenv("CI_MINIO_HOST")
if s3Host == "" {
s3Host = "dockerhost"
}
@@ -696,6 +696,8 @@ func TestS3TestConnection(t *testing.T) {
t.Fatal("should return error - missing s3 bucket")
}
// If this fails, check the test configuration to ensure minio is setup with the
// `mattermost-test` bucket defined by model.MINIO_BUCKET.
config.FileSettings.AmazonS3Bucket = model.MINIO_BUCKET
config.FileSettings.AmazonS3Region = "us-east-1"
_, resp = th.SystemAdminClient.TestS3Connection(&config)