diff --git a/.golangci.yml b/.golangci.yml index 0f14da58b6..6788712517 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -5,6 +5,8 @@ run: linters-settings: govet: check-shadowing: true + gofmt: + simplify: true linters: disable-all: true diff --git a/api4/integration_action_test.go b/api4/integration_action_test.go index 3838d321fb..7b629f4a04 100644 --- a/api4/integration_action_test.go +++ b/api4/integration_action_test.go @@ -112,7 +112,7 @@ func TestOpenDialog(t *testing.T) { CallbackId: "callbackid", Title: "Some Title", Elements: []model.DialogElement{ - model.DialogElement{ + { DisplayName: "Element Name", Name: "element_name", Type: "text", diff --git a/api4/plugin_test.go b/api4/plugin_test.go index 210ec1b722..a1732b4db1 100644 --- a/api4/plugin_test.go +++ b/api4/plugin_test.go @@ -387,7 +387,7 @@ func TestDisableOnRemove(t *testing.T) { pluginsResp, resp := th.SystemAdminClient.GetPlugins() CheckNoError(t, resp) require.Len(t, pluginsResp.Active, 0) - require.Equal(t, pluginsResp.Inactive, []*model.PluginInfo{&model.PluginInfo{ + require.Equal(t, pluginsResp.Inactive, []*model.PluginInfo{{ Manifest: *manifest, }}) @@ -400,7 +400,7 @@ func TestDisableOnRemove(t *testing.T) { pluginsResp, resp = th.SystemAdminClient.GetPlugins() CheckNoError(t, resp) require.Len(t, pluginsResp.Inactive, 0) - require.Equal(t, pluginsResp.Active, []*model.PluginInfo{&model.PluginInfo{ + require.Equal(t, pluginsResp.Active, []*model.PluginInfo{{ Manifest: *manifest, }}) @@ -414,7 +414,7 @@ func TestDisableOnRemove(t *testing.T) { pluginsResp, resp = th.SystemAdminClient.GetPlugins() CheckNoError(t, resp) require.Len(t, pluginsResp.Inactive, 0) - require.Equal(t, pluginsResp.Active, []*model.PluginInfo{&model.PluginInfo{ + require.Equal(t, pluginsResp.Active, []*model.PluginInfo{{ Manifest: *manifest, }}) } @@ -439,7 +439,7 @@ func TestDisableOnRemove(t *testing.T) { pluginsResp, resp = th.SystemAdminClient.GetPlugins() CheckNoError(t, resp) require.Len(t, pluginsResp.Active, 0) - require.Equal(t, pluginsResp.Inactive, []*model.PluginInfo{&model.PluginInfo{ + require.Equal(t, pluginsResp.Inactive, []*model.PluginInfo{{ Manifest: *manifest, }}) diff --git a/api4/websocket_test.go b/api4/websocket_test.go index e4e1517000..504a7095a3 100644 --- a/api4/websocket_test.go +++ b/api4/websocket_test.go @@ -39,7 +39,7 @@ func TestWebSocket(t *testing.T) { WebSocketClient.SendMessage("ping", nil) time.Sleep(300 * time.Millisecond) resp = <-WebSocketClient.ResponseChannel - require.Equal(t, resp.Data["text"].(string),"pong","wrong response") + require.Equal(t, resp.Data["text"].(string), "pong", "wrong response") WebSocketClient.SendMessage("", nil) time.Sleep(300 * time.Millisecond) diff --git a/app/app_test.go b/app/app_test.go index 647d2dc4b3..2701829a34 100644 --- a/app/app_test.go +++ b/app/app_test.go @@ -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, diff --git a/app/command_test.go b/app/command_test.go index 5f34935298..03e0bda7f3 100644 --- a/app/command_test.go +++ b/app/command_test.go @@ -189,7 +189,7 @@ func TestHandleCommandResponsePost(t *testing.T) { // Test Slack attachments text conversion. resp.Attachments = []*model.SlackAttachment{ - &model.SlackAttachment{ + { Text: "", }, } @@ -212,7 +212,7 @@ func TestHandleCommandResponsePost(t *testing.T) { resp.ChannelId = "" resp.Text = "" resp.Attachments = []*model.SlackAttachment{ - &model.SlackAttachment{ + { Text: "", }, } @@ -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{}, + {}, + {}, }, } diff --git a/app/diagnostics_test.go b/app/diagnostics_test.go index 8d9b51da1c..50d8b85a18 100644 --- a/app/diagnostics_test.go +++ b/app/diagnostics_test.go @@ -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, }, } diff --git a/app/email_batching_test.go b/app/email_batching_test.go index 09c2511ccf..aed286f0d9 100644 --- a/app/email_batching_test.go +++ b/app/email_batching_test.go @@ -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) { diff --git a/app/import_validators_test.go b/app/import_validators_test.go index 48de801350..59d8188cc5 100644 --- a/app/import_validators_test.go +++ b/app/import_validators_test.go @@ -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()), diff --git a/app/integration_action_test.go b/app/integration_action_test.go index d204efcd23..6474a16b29 100644 --- a/app/integration_action_test.go +++ b/app/integration_action_test.go @@ -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"}, } diff --git a/app/plugin_hooks_test.go b/app/plugin_hooks_test.go index df88b99b9b..2feabc26de 100644 --- a/app/plugin_hooks_test.go +++ b/app/plugin_hooks_test.go @@ -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) diff --git a/app/webhook_test.go b/app/webhook_test.go index d56f45f14a..3822d16c79 100644 --- a/app/webhook_test.go +++ b/app/webhook_test.go @@ -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), }, }, diff --git a/cmd/mattermost/commands/user_test.go b/cmd/mattermost/commands/user_test.go index 1c5e3d8acc..e7a5de50af 100644 --- a/cmd/mattermost/commands/user_test.go +++ b/cmd/mattermost/commands/user_test.go @@ -89,7 +89,6 @@ func TestChangeUserEmail(t *testing.T) { require.Equal(t, user.Email, newEmail, "should've updated to the new email") - // should fail because using an invalid email require.Error(t, th.RunCommand(t, "user", "email", th.BasicUser.Username, "wrong$email.com")) diff --git a/config/database_test.go b/config/database_test.go index ead6be3571..0ce33316aa 100644 --- a/config/database_test.go +++ b/config/database_test.go @@ -764,7 +764,7 @@ func TestDatabaseStoreLoad(t *testing.T) { func TestDatabaseGetFile(t *testing.T) { _, tearDown := setupConfigDatabase(t, minimalConfig, map[string][]byte{ - "empty-file": []byte{}, + "empty-file": {}, "test-file": []byte("test"), }) defer tearDown() diff --git a/config/memory_test.go b/config/memory_test.go index ede50fe549..bc1df36f97 100644 --- a/config/memory_test.go +++ b/config/memory_test.go @@ -282,7 +282,7 @@ func TestMemoryGetFile(t *testing.T) { ms, err := config.NewMemoryStoreWithOptions(&config.MemoryStoreOptions{ InitialConfig: minimalConfig, InitialFiles: map[string][]byte{ - "empty-file": []byte{}, + "empty-file": {}, "test-file": []byte("test"), }, }) diff --git a/model/client4_test.go b/model/client4_test.go index b165e6b610..87f2c285da 100644 --- a/model/client4_test.go +++ b/model/client4_test.go @@ -17,9 +17,9 @@ func TestClient4CreatePost(t *testing.T) { post := &Post{ Props: map[string]interface{}{ "attachments": []*SlackAttachment{ - &SlackAttachment{ + { Actions: []*PostAction{ - &PostAction{ + { Integration: &PostActionIntegration{ Context: map[string]interface{}{ "foo": "bar", @@ -37,9 +37,9 @@ func TestClient4CreatePost(t *testing.T) { server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { attachments := PostFromJson(r.Body).Attachments() assert.Equal(t, []*SlackAttachment{ - &SlackAttachment{ + { Actions: []*PostAction{ - &PostAction{ + { Integration: &PostActionIntegration{ Context: map[string]interface{}{ "foo": "bar", diff --git a/model/command_response_test.go b/model/command_response_test.go index 071cd4129a..76d46da0c3 100644 --- a/model/command_response_test.go +++ b/model/command_response_test.go @@ -146,7 +146,7 @@ func TestCommandResponseFromJson(t *testing.T) { &CommandResponse{ Text: "message 1", ExtraResponses: []*CommandResponse{ - &CommandResponse{ + { Text: "message 2", }, }, @@ -180,7 +180,7 @@ func TestCommandResponseFromJson(t *testing.T) { }, }, ExtraResponses: []*CommandResponse{ - &CommandResponse{ + { Text: "message 2", Attachments: []*SlackAttachment{ { diff --git a/model/link_metadata_test.go b/model/link_metadata_test.go index a3f63c506e..61c8acb09a 100644 --- a/model/link_metadata_test.go +++ b/model/link_metadata_test.go @@ -305,8 +305,8 @@ func TestTruncateOpenGraph(t *testing.T) { sampleImage("metoo.gif"), sampleImage("fifth.ico"), sampleImage("notme.tiff")}, - Audios: []*opengraph.Audio{&opengraph.Audio{}}, - Videos: []*opengraph.Video{&opengraph.Video{}}, + Audios: []*opengraph.Audio{{}}, + Videos: []*opengraph.Video{{}}, Article: &opengraph.Article{}, Book: &opengraph.Book{}, Profile: &opengraph.Profile{}, diff --git a/model/manifest_test.go b/model/manifest_test.go index 2a36fbe19c..f93b642acc 100644 --- a/model/manifest_test.go +++ b/model/manifest_test.go @@ -83,7 +83,7 @@ func TestManifestUnmarshal(t *testing.T) { Header: "theheadertext", Footer: "thefootertext", Settings: []*PluginSetting{ - &PluginSetting{ + { Key: "thesetting", DisplayName: "thedisplayname", Type: "dropdown", @@ -91,7 +91,7 @@ func TestManifestUnmarshal(t *testing.T) { RegenerateHelpText: "theregeneratehelptext", Placeholder: "theplaceholder", Options: []*PluginOption{ - &PluginOption{ + { DisplayName: "theoptiondisplayname", Value: "thevalue", }, @@ -232,7 +232,7 @@ func TestManifestJson(t *testing.T) { Header: "theheadertext", Footer: "thefootertext", Settings: []*PluginSetting{ - &PluginSetting{ + { Key: "thesetting", DisplayName: "thedisplayname", Type: "dropdown", @@ -240,7 +240,7 @@ func TestManifestJson(t *testing.T) { RegenerateHelpText: "theregeneratehelptext", Placeholder: "theplaceholder", Options: []*PluginOption{ - &PluginOption{ + { DisplayName: "theoptiondisplayname", Value: "thevalue", }, @@ -299,7 +299,7 @@ func TestManifestClientManifest(t *testing.T) { Header: "theheadertext", Footer: "thefootertext", Settings: []*PluginSetting{ - &PluginSetting{ + { Key: "thesetting", DisplayName: "thedisplayname", Type: "dropdown", @@ -307,7 +307,7 @@ func TestManifestClientManifest(t *testing.T) { RegenerateHelpText: "theregeneratehelptext", Placeholder: "theplaceholder", Options: []*PluginOption{ - &PluginOption{ + { DisplayName: "theoptiondisplayname", Value: "thevalue", }, diff --git a/model/session_test.go b/model/session_test.go index c232db8d66..0171f9e0a9 100644 --- a/model/session_test.go +++ b/model/session_test.go @@ -8,8 +8,8 @@ import ( "testing" "time" - "github.com/stretchr/testify/require" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) func TestSessionDeepCopy(t *testing.T) { @@ -18,7 +18,7 @@ func TestSessionDeepCopy(t *testing.T) { mapKey := "key" mapValue := "val" - session := &Session{Id: sessionId, Props: map[string]string{mapKey: mapValue}, TeamMembers: []*TeamMember{&TeamMember{UserId: userId, TeamId: "someteamId"}}} + session := &Session{Id: sessionId, Props: map[string]string{mapKey: mapValue}, TeamMembers: []*TeamMember{{UserId: userId, TeamId: "someteamId"}}} copySession := session.DeepCopy() copySession.Id = "changed" diff --git a/model/user_test.go b/model/user_test.go index d3d64da78b..5fe39917c6 100644 --- a/model/user_test.go +++ b/model/user_test.go @@ -63,7 +63,7 @@ func TestUserPreSave(t *testing.T) { user.PreSave() user.Etag(true, true) assert.NotNil(t, user.Timezone, "Timezone is nil") - assert.Equal(t, user.Timezone["useAutomaticTimezone"], "true", "Timezone is not set to default"); + assert.Equal(t, user.Timezone["useAutomaticTimezone"], "true", "Timezone is not set to default") } func TestUserPreUpdate(t *testing.T) { diff --git a/store/sqlstore/integrity_test.go b/store/sqlstore/integrity_test.go index 02125a4cee..2f01ed3613 100644 --- a/store/sqlstore/integrity_test.go +++ b/store/sqlstore/integrity_test.go @@ -14,10 +14,10 @@ import ( func createAudit(ss store.Store, userId, sessionId string) *model.Audit { audit := model.Audit{ - UserId: userId, + UserId: userId, SessionId: sessionId, IpAddress: "ipaddress", - Action: "Action", + Action: "Action", } ss.Audit().Save(&audit) return &audit @@ -46,7 +46,7 @@ func createChannelWithSchemeId(ss store.Store, schemeId *string) *model.Channel return c } -func createCommand(ss store.Store, userId, teamId string) * model.Command { +func createCommand(ss store.Store, userId, teamId string) *model.Command { m := model.Command{} m.CreatorId = userId m.Method = model.COMMAND_METHOD_POST @@ -75,19 +75,19 @@ func createChannelMemberHistory(ss store.Store, channelId, userId string) *model } func createChannelWithTeamId(ss store.Store, id string) *model.Channel { - return createChannel(ss, id, model.NewId()); + return createChannel(ss, id, model.NewId()) } func createChannelWithCreatorId(ss store.Store, id string) *model.Channel { - return createChannel(ss, model.NewId(), id); + return createChannel(ss, model.NewId(), id) } func createChannelMemberWithChannelId(ss store.Store, id string) *model.ChannelMember { - return createChannelMember(ss, id, model.NewId()); + return createChannelMember(ss, id, model.NewId()) } func createChannelMemberWithUserId(ss store.Store, id string) *model.ChannelMember { - return createChannelMember(ss, model.NewId(), id); + return createChannelMember(ss, model.NewId(), id) } func createCommandWebhook(ss store.Store, commandId, userId, channelId string) *model.CommandWebhook { @@ -192,20 +192,20 @@ func createPost(ss store.Store, channelId, userId, rootId, parentId string) *mod } func createPostWithChannelId(ss store.Store, id string) *model.Post { - return createPost(ss, id, model.NewId(), "", ""); + return createPost(ss, id, model.NewId(), "", "") } func createPostWithUserId(ss store.Store, id string) *model.Post { - return createPost(ss, model.NewId(), id, "", ""); + return createPost(ss, model.NewId(), id, "", "") } func createPreferences(ss store.Store, userId string) *model.Preferences { preferences := model.Preferences{ { - UserId: userId, - Name: model.NewId(), + UserId: userId, + Name: model.NewId(), Category: model.PREFERENCE_CATEGORY_DIRECT_CHANNEL_SHOW, - Value: "somevalue", + Value: "somevalue", }, } ss.Preference().Save(&preferences) @@ -369,10 +369,10 @@ func TestCheckParentChildIntegrity(t *testing.T) { supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier) t.Run("should receive an error", func(t *testing.T) { config := relationalCheckConfig{ - parentName: "NotValid", + parentName: "NotValid", parentIdAttr: "NotValid", - childName: "NotValid", - childIdAttr: "NotValid", + childName: "NotValid", + childIdAttr: "NotValid", } result := checkParentChildIntegrity(supplier, config) require.NotNil(t, result.Err) @@ -402,7 +402,7 @@ func TestCheckChannelsCommandWebhooksIntegrity(t *testing.T) { require.Len(t, data.Records, 1) require.Equal(t, store.OrphanedRecord{ ParentId: channelId, - ChildId: cwh.Id, + ChildId: cwh.Id, }, data.Records[0]) dbmap.Delete(cwh) }) @@ -488,7 +488,7 @@ func TestCheckChannelsIncomingWebhooksIntegrity(t *testing.T) { require.Len(t, data.Records, 1) require.Equal(t, store.OrphanedRecord{ ParentId: channelId, - ChildId: wh.Id, + ChildId: wh.Id, }, data.Records[0]) dbmap.Delete(wh) }) @@ -518,7 +518,7 @@ func TestCheckChannelsOutgoingWebhooksIntegrity(t *testing.T) { require.Len(t, data.Records, 1) require.Equal(t, store.OrphanedRecord{ ParentId: channelId, - ChildId: wh.Id, + ChildId: wh.Id, }, data.Records[0]) dbmap.Delete(wh) }) @@ -545,7 +545,7 @@ func TestCheckChannelsPostsIntegrity(t *testing.T) { require.Len(t, data.Records, 1) require.Equal(t, store.OrphanedRecord{ ParentId: post.ChannelId, - ChildId: post.Id, + ChildId: post.Id, }, data.Records[0]) dbmap.Delete(post) }) @@ -573,7 +573,7 @@ func TestCheckCommandsCommandWebhooksIntegrity(t *testing.T) { require.Len(t, data.Records, 1) require.Equal(t, store.OrphanedRecord{ ParentId: commandId, - ChildId: cwh.Id, + ChildId: cwh.Id, }, data.Records[0]) dbmap.Delete(cwh) }) @@ -631,7 +631,7 @@ func TestCheckPostsPostsParentIdIntegrity(t *testing.T) { require.Len(t, data.Records, 1) require.Equal(t, store.OrphanedRecord{ ParentId: parentId, - ChildId: post.Id, + ChildId: post.Id, }, data.Records[0]) dbmap.Delete(root) dbmap.Delete(post) @@ -662,7 +662,7 @@ func TestCheckPostsPostsRootIdIntegrity(t *testing.T) { require.Len(t, data.Records, 1) require.Equal(t, store.OrphanedRecord{ ParentId: rootId, - ChildId: post.Id, + ChildId: post.Id, }, data.Records[0]) dbmap.Delete(post) }) @@ -720,7 +720,7 @@ func TestCheckSchemesChannelsIntegrity(t *testing.T) { require.Len(t, data.Records, 1) require.Equal(t, store.OrphanedRecord{ ParentId: schemeId, - ChildId: channel.Id, + ChildId: channel.Id, }, data.Records[0]) dbmap.Delete(channel) }) @@ -751,7 +751,7 @@ func TestCheckSchemesTeamsIntegrity(t *testing.T) { require.Len(t, data.Records, 1) require.Equal(t, store.OrphanedRecord{ ParentId: schemeId, - ChildId: team.Id, + ChildId: team.Id, }, data.Records[0]) dbmap.Delete(team) }) @@ -782,7 +782,7 @@ func TestCheckSessionsAuditsIntegrity(t *testing.T) { require.Len(t, data.Records, 1) require.Equal(t, store.OrphanedRecord{ ParentId: sessionId, - ChildId: audit.Id, + ChildId: audit.Id, }, data.Records[0]) ss.Audit().PermanentDeleteByUser(userId) }) @@ -809,7 +809,7 @@ func TestCheckTeamsChannelsIntegrity(t *testing.T) { require.Len(t, data.Records, 1) require.Equal(t, store.OrphanedRecord{ ParentId: channel.TeamId, - ChildId: channel.Id, + ChildId: channel.Id, }, data.Records[0]) dbmap.Delete(channel) }) @@ -837,7 +837,7 @@ func TestCheckTeamsCommandsIntegrity(t *testing.T) { require.Len(t, data.Records, 1) require.Equal(t, store.OrphanedRecord{ ParentId: teamId, - ChildId: cmd.Id, + ChildId: cmd.Id, }, data.Records[0]) dbmap.Delete(cmd) }) @@ -865,7 +865,7 @@ func TestCheckTeamsIncomingWebhooksIntegrity(t *testing.T) { require.Len(t, data.Records, 1) require.Equal(t, store.OrphanedRecord{ ParentId: teamId, - ChildId: wh.Id, + ChildId: wh.Id, }, data.Records[0]) dbmap.Delete(wh) }) @@ -893,7 +893,7 @@ func TestCheckTeamsOutgoingWebhooksIntegrity(t *testing.T) { require.Len(t, data.Records, 1) require.Equal(t, store.OrphanedRecord{ ParentId: teamId, - ChildId: wh.Id, + ChildId: wh.Id, }, data.Records[0]) dbmap.Delete(wh) }) @@ -951,7 +951,7 @@ func TestCheckUsersAuditsIntegrity(t *testing.T) { require.Len(t, data.Records, 1) require.Equal(t, store.OrphanedRecord{ ParentId: userId, - ChildId: audit.Id, + ChildId: audit.Id, }, data.Records[0]) ss.Audit().PermanentDeleteByUser(userId) }) @@ -979,7 +979,7 @@ func TestCheckUsersCommandWebhooksIntegrity(t *testing.T) { require.Len(t, data.Records, 1) require.Equal(t, store.OrphanedRecord{ ParentId: userId, - ChildId: cwh.Id, + ChildId: cwh.Id, }, data.Records[0]) dbmap.Delete(cwh) }) @@ -1006,7 +1006,7 @@ func TestCheckUsersChannelsIntegrity(t *testing.T) { require.Len(t, data.Records, 1) require.Equal(t, store.OrphanedRecord{ ParentId: channel.CreatorId, - ChildId: channel.Id, + ChildId: channel.Id, }, data.Records[0]) dbmap.Delete(channel) }) @@ -1094,7 +1094,7 @@ func TestCheckUsersCommandsIntegrity(t *testing.T) { require.Len(t, data.Records, 1) require.Equal(t, store.OrphanedRecord{ ParentId: userId, - ChildId: cmd.Id, + ChildId: cmd.Id, }, data.Records[0]) dbmap.Delete(cmd) }) @@ -1124,7 +1124,7 @@ func TestCheckUsersCompliancesIntegrity(t *testing.T) { require.Len(t, data.Records, 1) require.Equal(t, store.OrphanedRecord{ ParentId: userId, - ChildId: compliance.Id, + ChildId: compliance.Id, }, data.Records[0]) dbmap.Delete(compliance) }) @@ -1154,7 +1154,7 @@ func TestCheckUsersEmojiIntegrity(t *testing.T) { require.Len(t, data.Records, 1) require.Equal(t, store.OrphanedRecord{ ParentId: userId, - ChildId: emoji.Id, + ChildId: emoji.Id, }, data.Records[0]) dbmap.Delete(emoji) }) @@ -1211,7 +1211,7 @@ func TestCheckUsersIncomingWebhooksIntegrity(t *testing.T) { require.Len(t, data.Records, 1) require.Equal(t, store.OrphanedRecord{ ParentId: userId, - ChildId: wh.Id, + ChildId: wh.Id, }, data.Records[0]) dbmap.Delete(wh) }) @@ -1241,7 +1241,7 @@ func TestCheckUsersOAuthAccessDataIntegrity(t *testing.T) { require.Len(t, data.Records, 1) require.Equal(t, store.OrphanedRecord{ ParentId: userId, - ChildId: ad.Token, + ChildId: ad.Token, }, data.Records[0]) ss.OAuth().RemoveAccessData(ad.Token) }) @@ -1271,7 +1271,7 @@ func TestCheckUsersOAuthAppsIntegrity(t *testing.T) { require.Len(t, data.Records, 1) require.Equal(t, store.OrphanedRecord{ ParentId: userId, - ChildId: app.Id, + ChildId: app.Id, }, data.Records[0]) ss.OAuth().DeleteApp(app.Id) }) @@ -1301,7 +1301,7 @@ func TestCheckUsersOAuthAuthDataIntegrity(t *testing.T) { require.Len(t, data.Records, 1) require.Equal(t, store.OrphanedRecord{ ParentId: userId, - ChildId: ad.Code, + ChildId: ad.Code, }, data.Records[0]) ss.OAuth().RemoveAuthData(ad.Code) }) @@ -1329,7 +1329,7 @@ func TestCheckUsersOutgoingWebhooksIntegrity(t *testing.T) { require.Len(t, data.Records, 1) require.Equal(t, store.OrphanedRecord{ ParentId: userId, - ChildId: wh.Id, + ChildId: wh.Id, }, data.Records[0]) dbmap.Delete(wh) }) @@ -1356,7 +1356,7 @@ func TestCheckUsersPostsIntegrity(t *testing.T) { require.Len(t, data.Records, 1) require.Equal(t, store.OrphanedRecord{ ParentId: post.UserId, - ChildId: post.Id, + ChildId: post.Id, }, data.Records[0]) dbmap.Delete(post) }) @@ -1442,7 +1442,7 @@ func TestCheckUsersSessionsIntegrity(t *testing.T) { require.Len(t, data.Records, 1) require.Equal(t, store.OrphanedRecord{ ParentId: userId, - ChildId: session.Id, + ChildId: session.Id, }, data.Records[0]) dbmap.Delete(session) }) @@ -1531,7 +1531,7 @@ func TestCheckUsersUserAccessTokensIntegrity(t *testing.T) { require.Len(t, data.Records, 1) require.Equal(t, store.OrphanedRecord{ ParentId: userId, - ChildId: uat.Id, + ChildId: uat.Id, }, data.Records[0]) ss.UserAccessToken().Delete(uat.Id) }) diff --git a/utils/password_test.go b/utils/password_test.go index e0d120eed4..f5ef44f81d 100644 --- a/utils/password_test.go +++ b/utils/password_test.go @@ -19,10 +19,10 @@ func TestIsPasswordValidWithSettings(t *testing.T) { Password: strings.Repeat("x", 3), Settings: &model.PasswordSettings{ MinimumLength: model.NewInt(3), - Lowercase: model.NewBool(false), - Uppercase: model.NewBool(false), - Number: model.NewBool(false), - Symbol: model.NewBool(false), + Lowercase: model.NewBool(false), + Uppercase: model.NewBool(false), + Number: model.NewBool(false), + Symbol: model.NewBool(false), }, }, "Long": { @@ -30,28 +30,28 @@ func TestIsPasswordValidWithSettings(t *testing.T) { Settings: &model.PasswordSettings{ Lowercase: model.NewBool(false), Uppercase: model.NewBool(false), - Number: model.NewBool(false), - Symbol: model.NewBool(false), + Number: model.NewBool(false), + Symbol: model.NewBool(false), }, }, "TooShort": { Password: strings.Repeat("x", 2), Settings: &model.PasswordSettings{ MinimumLength: model.NewInt(3), - Lowercase: model.NewBool(false), - Uppercase: model.NewBool(false), - Number: model.NewBool(false), - Symbol: model.NewBool(false), + Lowercase: model.NewBool(false), + Uppercase: model.NewBool(false), + Number: model.NewBool(false), + Symbol: model.NewBool(false), }, ExpectedError: "model.user.is_valid.pwd.app_error", }, "TooLong": { - Password: strings.Repeat("x", model.PASSWORD_MAXIMUM_LENGTH+1), - Settings: &model.PasswordSettings{ + Password: strings.Repeat("x", model.PASSWORD_MAXIMUM_LENGTH+1), + Settings: &model.PasswordSettings{ Lowercase: model.NewBool(false), Uppercase: model.NewBool(false), - Number: model.NewBool(false), - Symbol: model.NewBool(false), + Number: model.NewBool(false), + Symbol: model.NewBool(false), }, ExpectedError: "model.user.is_valid.pwd.app_error", }, @@ -60,8 +60,8 @@ func TestIsPasswordValidWithSettings(t *testing.T) { Settings: &model.PasswordSettings{ Lowercase: model.NewBool(true), Uppercase: model.NewBool(false), - Number: model.NewBool(false), - Symbol: model.NewBool(false), + Number: model.NewBool(false), + Symbol: model.NewBool(false), }, ExpectedError: "model.user.is_valid.pwd_lowercase.app_error", }, @@ -70,28 +70,28 @@ func TestIsPasswordValidWithSettings(t *testing.T) { Settings: &model.PasswordSettings{ Uppercase: model.NewBool(true), Lowercase: model.NewBool(false), - Number: model.NewBool(false), - Symbol: model.NewBool(false), + Number: model.NewBool(false), + Symbol: model.NewBool(false), }, ExpectedError: "model.user.is_valid.pwd_uppercase.app_error", }, "MissingNumber": { Password: "asasdasdsadASD!@#", Settings: &model.PasswordSettings{ - Number: model.NewBool(true), + Number: model.NewBool(true), Lowercase: model.NewBool(false), Uppercase: model.NewBool(false), - Symbol: model.NewBool(false), + Symbol: model.NewBool(false), }, ExpectedError: "model.user.is_valid.pwd_number.app_error", }, "MissingSymbol": { Password: "asdasdasdasdasdASD123", Settings: &model.PasswordSettings{ - Symbol: model.NewBool(true), + Symbol: model.NewBool(true), Lowercase: model.NewBool(false), Uppercase: model.NewBool(false), - Number: model.NewBool(false), + Number: model.NewBool(false), }, ExpectedError: "model.user.is_valid.pwd_symbol.app_error", },