Run gofmt -s against codebase (#12943)
Этот коммит содержится в:
@@ -69,7 +69,7 @@ func TestDoAdvancedPermissionsMigration(t *testing.T) {
|
||||
assert.Equal(t, len(roles1), len(roleNames))
|
||||
|
||||
expected1 := map[string][]string{
|
||||
"channel_user": []string{
|
||||
"channel_user": {
|
||||
model.PERMISSION_READ_CHANNEL.Id,
|
||||
model.PERMISSION_ADD_REACTION.Id,
|
||||
model.PERMISSION_REMOVE_REACTION.Id,
|
||||
@@ -86,10 +86,10 @@ func TestDoAdvancedPermissionsMigration(t *testing.T) {
|
||||
model.PERMISSION_DELETE_POST.Id,
|
||||
model.PERMISSION_EDIT_POST.Id,
|
||||
},
|
||||
"channel_admin": []string{
|
||||
"channel_admin": {
|
||||
model.PERMISSION_MANAGE_CHANNEL_ROLES.Id,
|
||||
},
|
||||
"team_user": []string{
|
||||
"team_user": {
|
||||
model.PERMISSION_LIST_TEAM_CHANNELS.Id,
|
||||
model.PERMISSION_JOIN_PUBLIC_CHANNELS.Id,
|
||||
model.PERMISSION_READ_PUBLIC_CHANNEL.Id,
|
||||
@@ -99,13 +99,13 @@ func TestDoAdvancedPermissionsMigration(t *testing.T) {
|
||||
model.PERMISSION_INVITE_USER.Id,
|
||||
model.PERMISSION_ADD_USER_TO_TEAM.Id,
|
||||
},
|
||||
"team_post_all": []string{
|
||||
"team_post_all": {
|
||||
model.PERMISSION_CREATE_POST.Id,
|
||||
},
|
||||
"team_post_all_public": []string{
|
||||
"team_post_all_public": {
|
||||
model.PERMISSION_CREATE_POST_PUBLIC.Id,
|
||||
},
|
||||
"team_admin": []string{
|
||||
"team_admin": {
|
||||
model.PERMISSION_REMOVE_USER_FROM_TEAM.Id,
|
||||
model.PERMISSION_MANAGE_TEAM.Id,
|
||||
model.PERMISSION_IMPORT_TEAM.Id,
|
||||
@@ -120,7 +120,7 @@ func TestDoAdvancedPermissionsMigration(t *testing.T) {
|
||||
model.PERMISSION_DELETE_POST.Id,
|
||||
model.PERMISSION_DELETE_OTHERS_POSTS.Id,
|
||||
},
|
||||
"system_user": []string{
|
||||
"system_user": {
|
||||
model.PERMISSION_LIST_PUBLIC_TEAMS.Id,
|
||||
model.PERMISSION_JOIN_PUBLIC_TEAMS.Id,
|
||||
model.PERMISSION_CREATE_DIRECT_CHANNEL.Id,
|
||||
@@ -128,18 +128,18 @@ func TestDoAdvancedPermissionsMigration(t *testing.T) {
|
||||
model.PERMISSION_VIEW_MEMBERS.Id,
|
||||
model.PERMISSION_CREATE_TEAM.Id,
|
||||
},
|
||||
"system_post_all": []string{
|
||||
"system_post_all": {
|
||||
model.PERMISSION_CREATE_POST.Id,
|
||||
},
|
||||
"system_post_all_public": []string{
|
||||
"system_post_all_public": {
|
||||
model.PERMISSION_CREATE_POST_PUBLIC.Id,
|
||||
},
|
||||
"system_user_access_token": []string{
|
||||
"system_user_access_token": {
|
||||
model.PERMISSION_CREATE_USER_ACCESS_TOKEN.Id,
|
||||
model.PERMISSION_READ_USER_ACCESS_TOKEN.Id,
|
||||
model.PERMISSION_REVOKE_USER_ACCESS_TOKEN.Id,
|
||||
},
|
||||
"system_admin": []string{
|
||||
"system_admin": {
|
||||
model.PERMISSION_ASSIGN_SYSTEM_ADMIN_ROLE.Id,
|
||||
model.PERMISSION_MANAGE_SYSTEM.Id,
|
||||
model.PERMISSION_MANAGE_ROLES.Id,
|
||||
@@ -254,7 +254,7 @@ func TestDoAdvancedPermissionsMigration(t *testing.T) {
|
||||
|
||||
// Check the role permissions.
|
||||
expected2 := map[string][]string{
|
||||
"channel_user": []string{
|
||||
"channel_user": {
|
||||
model.PERMISSION_READ_CHANNEL.Id,
|
||||
model.PERMISSION_ADD_REACTION.Id,
|
||||
model.PERMISSION_REMOVE_REACTION.Id,
|
||||
@@ -269,10 +269,10 @@ func TestDoAdvancedPermissionsMigration(t *testing.T) {
|
||||
model.PERMISSION_DELETE_POST.Id,
|
||||
model.PERMISSION_EDIT_POST.Id,
|
||||
},
|
||||
"channel_admin": []string{
|
||||
"channel_admin": {
|
||||
model.PERMISSION_MANAGE_CHANNEL_ROLES.Id,
|
||||
},
|
||||
"team_user": []string{
|
||||
"team_user": {
|
||||
model.PERMISSION_LIST_TEAM_CHANNELS.Id,
|
||||
model.PERMISSION_JOIN_PUBLIC_CHANNELS.Id,
|
||||
model.PERMISSION_READ_PUBLIC_CHANNEL.Id,
|
||||
@@ -282,13 +282,13 @@ func TestDoAdvancedPermissionsMigration(t *testing.T) {
|
||||
model.PERMISSION_INVITE_USER.Id,
|
||||
model.PERMISSION_ADD_USER_TO_TEAM.Id,
|
||||
},
|
||||
"team_post_all": []string{
|
||||
"team_post_all": {
|
||||
model.PERMISSION_CREATE_POST.Id,
|
||||
},
|
||||
"team_post_all_public": []string{
|
||||
"team_post_all_public": {
|
||||
model.PERMISSION_CREATE_POST_PUBLIC.Id,
|
||||
},
|
||||
"team_admin": []string{
|
||||
"team_admin": {
|
||||
model.PERMISSION_REMOVE_USER_FROM_TEAM.Id,
|
||||
model.PERMISSION_MANAGE_TEAM.Id,
|
||||
model.PERMISSION_IMPORT_TEAM.Id,
|
||||
@@ -305,7 +305,7 @@ func TestDoAdvancedPermissionsMigration(t *testing.T) {
|
||||
model.PERMISSION_DELETE_POST.Id,
|
||||
model.PERMISSION_DELETE_OTHERS_POSTS.Id,
|
||||
},
|
||||
"system_user": []string{
|
||||
"system_user": {
|
||||
model.PERMISSION_LIST_PUBLIC_TEAMS.Id,
|
||||
model.PERMISSION_JOIN_PUBLIC_TEAMS.Id,
|
||||
model.PERMISSION_CREATE_DIRECT_CHANNEL.Id,
|
||||
@@ -313,18 +313,18 @@ func TestDoAdvancedPermissionsMigration(t *testing.T) {
|
||||
model.PERMISSION_VIEW_MEMBERS.Id,
|
||||
model.PERMISSION_CREATE_TEAM.Id,
|
||||
},
|
||||
"system_post_all": []string{
|
||||
"system_post_all": {
|
||||
model.PERMISSION_CREATE_POST.Id,
|
||||
},
|
||||
"system_post_all_public": []string{
|
||||
"system_post_all_public": {
|
||||
model.PERMISSION_CREATE_POST_PUBLIC.Id,
|
||||
},
|
||||
"system_user_access_token": []string{
|
||||
"system_user_access_token": {
|
||||
model.PERMISSION_CREATE_USER_ACCESS_TOKEN.Id,
|
||||
model.PERMISSION_READ_USER_ACCESS_TOKEN.Id,
|
||||
model.PERMISSION_REVOKE_USER_ACCESS_TOKEN.Id,
|
||||
},
|
||||
"system_admin": []string{
|
||||
"system_admin": {
|
||||
model.PERMISSION_ASSIGN_SYSTEM_ADMIN_ROLE.Id,
|
||||
model.PERMISSION_MANAGE_SYSTEM.Id,
|
||||
model.PERMISSION_MANAGE_ROLES.Id,
|
||||
|
||||
@@ -189,7 +189,7 @@ func TestHandleCommandResponsePost(t *testing.T) {
|
||||
|
||||
// Test Slack attachments text conversion.
|
||||
resp.Attachments = []*model.SlackAttachment{
|
||||
&model.SlackAttachment{
|
||||
{
|
||||
Text: "<!here>",
|
||||
},
|
||||
}
|
||||
@@ -212,7 +212,7 @@ func TestHandleCommandResponsePost(t *testing.T) {
|
||||
resp.ChannelId = ""
|
||||
resp.Text = "<test.com|test website>"
|
||||
resp.Attachments = []*model.SlackAttachment{
|
||||
&model.SlackAttachment{
|
||||
{
|
||||
Text: "<!here>",
|
||||
},
|
||||
}
|
||||
@@ -257,10 +257,10 @@ func TestHandleCommandResponse(t *testing.T) {
|
||||
resp = &model.CommandResponse{
|
||||
Text: "message 1",
|
||||
ExtraResponses: []*model.CommandResponse{
|
||||
&model.CommandResponse{
|
||||
{
|
||||
Text: "message 2",
|
||||
},
|
||||
&model.CommandResponse{
|
||||
{
|
||||
Type: model.POST_SYSTEM_GENERIC,
|
||||
Text: "message 3",
|
||||
},
|
||||
@@ -274,8 +274,8 @@ func TestHandleCommandResponse(t *testing.T) {
|
||||
|
||||
resp = &model.CommandResponse{
|
||||
ExtraResponses: []*model.CommandResponse{
|
||||
&model.CommandResponse{},
|
||||
&model.CommandResponse{},
|
||||
{},
|
||||
{},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ import (
|
||||
func TestPluginSetting(t *testing.T) {
|
||||
settings := &model.PluginSettings{
|
||||
Plugins: map[string]map[string]interface{}{
|
||||
"test": map[string]interface{}{
|
||||
"test": {
|
||||
"foo": "bar",
|
||||
},
|
||||
},
|
||||
@@ -31,10 +31,10 @@ func TestPluginSetting(t *testing.T) {
|
||||
|
||||
func TestPluginActivated(t *testing.T) {
|
||||
states := map[string]*model.PluginState{
|
||||
"foo": &model.PluginState{
|
||||
"foo": {
|
||||
Enable: true,
|
||||
},
|
||||
"bar": &model.PluginState{
|
||||
"bar": {
|
||||
Enable: false,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -64,11 +64,11 @@ func TestHandleNewNotifications(t *testing.T) {
|
||||
job.Add(&model.User{Id: id1}, &model.Post{UserId: id1, Message: "test4"}, &model.Team{Name: "team"})
|
||||
job.Add(&model.User{Id: id2}, &model.Post{UserId: id1, Message: "test5"}, &model.Team{Name: "team"})
|
||||
job.handleNewNotifications()
|
||||
assert.Equal(t, job.pendingNotifications[id1][0].post.Message, "test1", "incorrect order of received posts for user1");
|
||||
assert.Equal(t, job.pendingNotifications[id1][1].post.Message, "test2", "incorrect order of received posts for user1");
|
||||
assert.Equal(t, job.pendingNotifications[id1][2].post.Message, "test4", "incorrect order of received posts for user1");
|
||||
assert.Equal(t, job.pendingNotifications[id2][0].post.Message, "test3", "incorrect order of received posts for user2");
|
||||
assert.Equal(t, job.pendingNotifications[id2][1].post.Message, "test5", "incorrect order of received posts for user2");
|
||||
assert.Equal(t, job.pendingNotifications[id1][0].post.Message, "test1", "incorrect order of received posts for user1")
|
||||
assert.Equal(t, job.pendingNotifications[id1][1].post.Message, "test2", "incorrect order of received posts for user1")
|
||||
assert.Equal(t, job.pendingNotifications[id1][2].post.Message, "test4", "incorrect order of received posts for user1")
|
||||
assert.Equal(t, job.pendingNotifications[id2][0].post.Message, "test3", "incorrect order of received posts for user2")
|
||||
assert.Equal(t, job.pendingNotifications[id2][1].post.Message, "test5", "incorrect order of received posts for user2")
|
||||
}
|
||||
|
||||
func TestCheckPendingNotifications(t *testing.T) {
|
||||
|
||||
@@ -487,7 +487,7 @@ func TestImportValidateUserImportData(t *testing.T) {
|
||||
|
||||
data.Username = ptrStr("i am a username with spaces and !!!")
|
||||
err = validateUserImportData(&data)
|
||||
require.NotNil(t, err, "Validation should have failed due to invalid characters in Username.");
|
||||
require.NotNil(t, err, "Validation should have failed due to invalid characters in Username.")
|
||||
|
||||
data.Username = ptrStr("bob")
|
||||
|
||||
@@ -759,7 +759,6 @@ func TestImportValidateReactionImportData(t *testing.T) {
|
||||
err = validateReactionImportData(&data, parentCreateAt)
|
||||
require.NotNil(t, err, "Should have failed due to missing required property.")
|
||||
|
||||
|
||||
data = ReactionImportData{
|
||||
User: ptrStr("username"),
|
||||
EmojiName: ptrStr("emoji"),
|
||||
@@ -938,13 +937,13 @@ func TestImportValidatePostImportData(t *testing.T) {
|
||||
require.NotNil(t, err, "Should have failed due to 0 create-at value.")
|
||||
|
||||
// Test with valid all optional parameters.
|
||||
reactions := []ReactionImportData{ReactionImportData{
|
||||
reactions := []ReactionImportData{{
|
||||
User: ptrStr("username"),
|
||||
EmojiName: ptrStr("emoji"),
|
||||
CreateAt: ptrInt64(model.GetMillis()),
|
||||
}}
|
||||
|
||||
replies := []ReplyImportData{ReplyImportData{
|
||||
replies := []ReplyImportData{{
|
||||
User: ptrStr("username"),
|
||||
Message: ptrStr("message"),
|
||||
CreateAt: ptrInt64(model.GetMillis()),
|
||||
@@ -1240,13 +1239,13 @@ func TestImportValidateDirectPostImportData(t *testing.T) {
|
||||
require.Nil(t, err, "Validation should succeed with post flagged by members")
|
||||
|
||||
// Test with valid all optional parameters.
|
||||
reactions := []ReactionImportData{ReactionImportData{
|
||||
reactions := []ReactionImportData{{
|
||||
User: ptrStr("username"),
|
||||
EmojiName: ptrStr("emoji"),
|
||||
CreateAt: ptrInt64(model.GetMillis()),
|
||||
}}
|
||||
|
||||
replies := []ReplyImportData{ReplyImportData{
|
||||
replies := []ReplyImportData{{
|
||||
User: ptrStr("username"),
|
||||
Message: ptrStr("message"),
|
||||
CreateAt: ptrInt64(model.GetMillis()),
|
||||
|
||||
@@ -430,7 +430,7 @@ func TestSubmitInteractiveDialog(t *testing.T) {
|
||||
assert.Equal(t, "value1", val)
|
||||
|
||||
resp := model.SubmitDialogResponse{
|
||||
Error: "some generic error",
|
||||
Error: "some generic error",
|
||||
Errors: map[string]string{"name1": "some error"},
|
||||
}
|
||||
|
||||
|
||||
@@ -571,7 +571,7 @@ func TestHookFileWillBeUploaded(t *testing.T) {
|
||||
assert.Nil(t, err)
|
||||
assert.NotNil(t, response)
|
||||
assert.Equal(t, 1, len(response.FileInfos))
|
||||
|
||||
|
||||
fileId := response.FileInfos[0].Id
|
||||
fileInfo, err := th.App.GetFileInfo(fileId)
|
||||
assert.Nil(t, err)
|
||||
|
||||
@@ -389,13 +389,13 @@ func TestSplitWebhookPost(t *testing.T) {
|
||||
Message: strings.Repeat("本", maxPostSize*3/2),
|
||||
Props: map[string]interface{}{
|
||||
"attachments": []*model.SlackAttachment{
|
||||
&model.SlackAttachment{
|
||||
{
|
||||
Text: strings.Repeat("本", 1000),
|
||||
},
|
||||
&model.SlackAttachment{
|
||||
{
|
||||
Text: strings.Repeat("本", 2000),
|
||||
},
|
||||
&model.SlackAttachment{
|
||||
{
|
||||
Text: strings.Repeat("本", model.POST_PROPS_MAX_USER_RUNES-1000),
|
||||
},
|
||||
},
|
||||
@@ -409,10 +409,10 @@ func TestSplitWebhookPost(t *testing.T) {
|
||||
Message: strings.Repeat("本", maxPostSize/2),
|
||||
Props: map[string]interface{}{
|
||||
"attachments": []*model.SlackAttachment{
|
||||
&model.SlackAttachment{
|
||||
{
|
||||
Text: strings.Repeat("本", 1000),
|
||||
},
|
||||
&model.SlackAttachment{
|
||||
{
|
||||
Text: strings.Repeat("本", 2000),
|
||||
},
|
||||
},
|
||||
@@ -421,7 +421,7 @@ func TestSplitWebhookPost(t *testing.T) {
|
||||
{
|
||||
Props: map[string]interface{}{
|
||||
"attachments": []*model.SlackAttachment{
|
||||
&model.SlackAttachment{
|
||||
{
|
||||
Text: strings.Repeat("本", model.POST_PROPS_MAX_USER_RUNES-1000),
|
||||
},
|
||||
},
|
||||
|
||||
Ссылка в новой задаче
Block a user