Этот коммит содержится в:
Ben Schumacher
2019-10-28 14:08:08 +01:00
коммит произвёл Lev
родитель 8a72ed2833
Коммит e61340c54e
23 изменённых файлов: 141 добавлений и 141 удалений

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

@@ -5,6 +5,8 @@ run:
linters-settings: linters-settings:
govet: govet:
check-shadowing: true check-shadowing: true
gofmt:
simplify: true
linters: linters:
disable-all: true disable-all: true

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

@@ -112,7 +112,7 @@ func TestOpenDialog(t *testing.T) {
CallbackId: "callbackid", CallbackId: "callbackid",
Title: "Some Title", Title: "Some Title",
Elements: []model.DialogElement{ Elements: []model.DialogElement{
model.DialogElement{ {
DisplayName: "Element Name", DisplayName: "Element Name",
Name: "element_name", Name: "element_name",
Type: "text", Type: "text",

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

@@ -387,7 +387,7 @@ func TestDisableOnRemove(t *testing.T) {
pluginsResp, resp := th.SystemAdminClient.GetPlugins() pluginsResp, resp := th.SystemAdminClient.GetPlugins()
CheckNoError(t, resp) CheckNoError(t, resp)
require.Len(t, pluginsResp.Active, 0) require.Len(t, pluginsResp.Active, 0)
require.Equal(t, pluginsResp.Inactive, []*model.PluginInfo{&model.PluginInfo{ require.Equal(t, pluginsResp.Inactive, []*model.PluginInfo{{
Manifest: *manifest, Manifest: *manifest,
}}) }})
@@ -400,7 +400,7 @@ func TestDisableOnRemove(t *testing.T) {
pluginsResp, resp = th.SystemAdminClient.GetPlugins() pluginsResp, resp = th.SystemAdminClient.GetPlugins()
CheckNoError(t, resp) CheckNoError(t, resp)
require.Len(t, pluginsResp.Inactive, 0) require.Len(t, pluginsResp.Inactive, 0)
require.Equal(t, pluginsResp.Active, []*model.PluginInfo{&model.PluginInfo{ require.Equal(t, pluginsResp.Active, []*model.PluginInfo{{
Manifest: *manifest, Manifest: *manifest,
}}) }})
@@ -414,7 +414,7 @@ func TestDisableOnRemove(t *testing.T) {
pluginsResp, resp = th.SystemAdminClient.GetPlugins() pluginsResp, resp = th.SystemAdminClient.GetPlugins()
CheckNoError(t, resp) CheckNoError(t, resp)
require.Len(t, pluginsResp.Inactive, 0) require.Len(t, pluginsResp.Inactive, 0)
require.Equal(t, pluginsResp.Active, []*model.PluginInfo{&model.PluginInfo{ require.Equal(t, pluginsResp.Active, []*model.PluginInfo{{
Manifest: *manifest, Manifest: *manifest,
}}) }})
} }
@@ -439,7 +439,7 @@ func TestDisableOnRemove(t *testing.T) {
pluginsResp, resp = th.SystemAdminClient.GetPlugins() pluginsResp, resp = th.SystemAdminClient.GetPlugins()
CheckNoError(t, resp) CheckNoError(t, resp)
require.Len(t, pluginsResp.Active, 0) require.Len(t, pluginsResp.Active, 0)
require.Equal(t, pluginsResp.Inactive, []*model.PluginInfo{&model.PluginInfo{ require.Equal(t, pluginsResp.Inactive, []*model.PluginInfo{{
Manifest: *manifest, Manifest: *manifest,
}}) }})

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

@@ -69,7 +69,7 @@ func TestDoAdvancedPermissionsMigration(t *testing.T) {
assert.Equal(t, len(roles1), len(roleNames)) assert.Equal(t, len(roles1), len(roleNames))
expected1 := map[string][]string{ expected1 := map[string][]string{
"channel_user": []string{ "channel_user": {
model.PERMISSION_READ_CHANNEL.Id, model.PERMISSION_READ_CHANNEL.Id,
model.PERMISSION_ADD_REACTION.Id, model.PERMISSION_ADD_REACTION.Id,
model.PERMISSION_REMOVE_REACTION.Id, model.PERMISSION_REMOVE_REACTION.Id,
@@ -86,10 +86,10 @@ func TestDoAdvancedPermissionsMigration(t *testing.T) {
model.PERMISSION_DELETE_POST.Id, model.PERMISSION_DELETE_POST.Id,
model.PERMISSION_EDIT_POST.Id, model.PERMISSION_EDIT_POST.Id,
}, },
"channel_admin": []string{ "channel_admin": {
model.PERMISSION_MANAGE_CHANNEL_ROLES.Id, model.PERMISSION_MANAGE_CHANNEL_ROLES.Id,
}, },
"team_user": []string{ "team_user": {
model.PERMISSION_LIST_TEAM_CHANNELS.Id, model.PERMISSION_LIST_TEAM_CHANNELS.Id,
model.PERMISSION_JOIN_PUBLIC_CHANNELS.Id, model.PERMISSION_JOIN_PUBLIC_CHANNELS.Id,
model.PERMISSION_READ_PUBLIC_CHANNEL.Id, model.PERMISSION_READ_PUBLIC_CHANNEL.Id,
@@ -99,13 +99,13 @@ func TestDoAdvancedPermissionsMigration(t *testing.T) {
model.PERMISSION_INVITE_USER.Id, model.PERMISSION_INVITE_USER.Id,
model.PERMISSION_ADD_USER_TO_TEAM.Id, model.PERMISSION_ADD_USER_TO_TEAM.Id,
}, },
"team_post_all": []string{ "team_post_all": {
model.PERMISSION_CREATE_POST.Id, model.PERMISSION_CREATE_POST.Id,
}, },
"team_post_all_public": []string{ "team_post_all_public": {
model.PERMISSION_CREATE_POST_PUBLIC.Id, model.PERMISSION_CREATE_POST_PUBLIC.Id,
}, },
"team_admin": []string{ "team_admin": {
model.PERMISSION_REMOVE_USER_FROM_TEAM.Id, model.PERMISSION_REMOVE_USER_FROM_TEAM.Id,
model.PERMISSION_MANAGE_TEAM.Id, model.PERMISSION_MANAGE_TEAM.Id,
model.PERMISSION_IMPORT_TEAM.Id, model.PERMISSION_IMPORT_TEAM.Id,
@@ -120,7 +120,7 @@ func TestDoAdvancedPermissionsMigration(t *testing.T) {
model.PERMISSION_DELETE_POST.Id, model.PERMISSION_DELETE_POST.Id,
model.PERMISSION_DELETE_OTHERS_POSTS.Id, model.PERMISSION_DELETE_OTHERS_POSTS.Id,
}, },
"system_user": []string{ "system_user": {
model.PERMISSION_LIST_PUBLIC_TEAMS.Id, model.PERMISSION_LIST_PUBLIC_TEAMS.Id,
model.PERMISSION_JOIN_PUBLIC_TEAMS.Id, model.PERMISSION_JOIN_PUBLIC_TEAMS.Id,
model.PERMISSION_CREATE_DIRECT_CHANNEL.Id, model.PERMISSION_CREATE_DIRECT_CHANNEL.Id,
@@ -128,18 +128,18 @@ func TestDoAdvancedPermissionsMigration(t *testing.T) {
model.PERMISSION_VIEW_MEMBERS.Id, model.PERMISSION_VIEW_MEMBERS.Id,
model.PERMISSION_CREATE_TEAM.Id, model.PERMISSION_CREATE_TEAM.Id,
}, },
"system_post_all": []string{ "system_post_all": {
model.PERMISSION_CREATE_POST.Id, model.PERMISSION_CREATE_POST.Id,
}, },
"system_post_all_public": []string{ "system_post_all_public": {
model.PERMISSION_CREATE_POST_PUBLIC.Id, model.PERMISSION_CREATE_POST_PUBLIC.Id,
}, },
"system_user_access_token": []string{ "system_user_access_token": {
model.PERMISSION_CREATE_USER_ACCESS_TOKEN.Id, model.PERMISSION_CREATE_USER_ACCESS_TOKEN.Id,
model.PERMISSION_READ_USER_ACCESS_TOKEN.Id, model.PERMISSION_READ_USER_ACCESS_TOKEN.Id,
model.PERMISSION_REVOKE_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_ASSIGN_SYSTEM_ADMIN_ROLE.Id,
model.PERMISSION_MANAGE_SYSTEM.Id, model.PERMISSION_MANAGE_SYSTEM.Id,
model.PERMISSION_MANAGE_ROLES.Id, model.PERMISSION_MANAGE_ROLES.Id,
@@ -254,7 +254,7 @@ func TestDoAdvancedPermissionsMigration(t *testing.T) {
// Check the role permissions. // Check the role permissions.
expected2 := map[string][]string{ expected2 := map[string][]string{
"channel_user": []string{ "channel_user": {
model.PERMISSION_READ_CHANNEL.Id, model.PERMISSION_READ_CHANNEL.Id,
model.PERMISSION_ADD_REACTION.Id, model.PERMISSION_ADD_REACTION.Id,
model.PERMISSION_REMOVE_REACTION.Id, model.PERMISSION_REMOVE_REACTION.Id,
@@ -269,10 +269,10 @@ func TestDoAdvancedPermissionsMigration(t *testing.T) {
model.PERMISSION_DELETE_POST.Id, model.PERMISSION_DELETE_POST.Id,
model.PERMISSION_EDIT_POST.Id, model.PERMISSION_EDIT_POST.Id,
}, },
"channel_admin": []string{ "channel_admin": {
model.PERMISSION_MANAGE_CHANNEL_ROLES.Id, model.PERMISSION_MANAGE_CHANNEL_ROLES.Id,
}, },
"team_user": []string{ "team_user": {
model.PERMISSION_LIST_TEAM_CHANNELS.Id, model.PERMISSION_LIST_TEAM_CHANNELS.Id,
model.PERMISSION_JOIN_PUBLIC_CHANNELS.Id, model.PERMISSION_JOIN_PUBLIC_CHANNELS.Id,
model.PERMISSION_READ_PUBLIC_CHANNEL.Id, model.PERMISSION_READ_PUBLIC_CHANNEL.Id,
@@ -282,13 +282,13 @@ func TestDoAdvancedPermissionsMigration(t *testing.T) {
model.PERMISSION_INVITE_USER.Id, model.PERMISSION_INVITE_USER.Id,
model.PERMISSION_ADD_USER_TO_TEAM.Id, model.PERMISSION_ADD_USER_TO_TEAM.Id,
}, },
"team_post_all": []string{ "team_post_all": {
model.PERMISSION_CREATE_POST.Id, model.PERMISSION_CREATE_POST.Id,
}, },
"team_post_all_public": []string{ "team_post_all_public": {
model.PERMISSION_CREATE_POST_PUBLIC.Id, model.PERMISSION_CREATE_POST_PUBLIC.Id,
}, },
"team_admin": []string{ "team_admin": {
model.PERMISSION_REMOVE_USER_FROM_TEAM.Id, model.PERMISSION_REMOVE_USER_FROM_TEAM.Id,
model.PERMISSION_MANAGE_TEAM.Id, model.PERMISSION_MANAGE_TEAM.Id,
model.PERMISSION_IMPORT_TEAM.Id, model.PERMISSION_IMPORT_TEAM.Id,
@@ -305,7 +305,7 @@ func TestDoAdvancedPermissionsMigration(t *testing.T) {
model.PERMISSION_DELETE_POST.Id, model.PERMISSION_DELETE_POST.Id,
model.PERMISSION_DELETE_OTHERS_POSTS.Id, model.PERMISSION_DELETE_OTHERS_POSTS.Id,
}, },
"system_user": []string{ "system_user": {
model.PERMISSION_LIST_PUBLIC_TEAMS.Id, model.PERMISSION_LIST_PUBLIC_TEAMS.Id,
model.PERMISSION_JOIN_PUBLIC_TEAMS.Id, model.PERMISSION_JOIN_PUBLIC_TEAMS.Id,
model.PERMISSION_CREATE_DIRECT_CHANNEL.Id, model.PERMISSION_CREATE_DIRECT_CHANNEL.Id,
@@ -313,18 +313,18 @@ func TestDoAdvancedPermissionsMigration(t *testing.T) {
model.PERMISSION_VIEW_MEMBERS.Id, model.PERMISSION_VIEW_MEMBERS.Id,
model.PERMISSION_CREATE_TEAM.Id, model.PERMISSION_CREATE_TEAM.Id,
}, },
"system_post_all": []string{ "system_post_all": {
model.PERMISSION_CREATE_POST.Id, model.PERMISSION_CREATE_POST.Id,
}, },
"system_post_all_public": []string{ "system_post_all_public": {
model.PERMISSION_CREATE_POST_PUBLIC.Id, model.PERMISSION_CREATE_POST_PUBLIC.Id,
}, },
"system_user_access_token": []string{ "system_user_access_token": {
model.PERMISSION_CREATE_USER_ACCESS_TOKEN.Id, model.PERMISSION_CREATE_USER_ACCESS_TOKEN.Id,
model.PERMISSION_READ_USER_ACCESS_TOKEN.Id, model.PERMISSION_READ_USER_ACCESS_TOKEN.Id,
model.PERMISSION_REVOKE_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_ASSIGN_SYSTEM_ADMIN_ROLE.Id,
model.PERMISSION_MANAGE_SYSTEM.Id, model.PERMISSION_MANAGE_SYSTEM.Id,
model.PERMISSION_MANAGE_ROLES.Id, model.PERMISSION_MANAGE_ROLES.Id,

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

@@ -189,7 +189,7 @@ func TestHandleCommandResponsePost(t *testing.T) {
// Test Slack attachments text conversion. // Test Slack attachments text conversion.
resp.Attachments = []*model.SlackAttachment{ resp.Attachments = []*model.SlackAttachment{
&model.SlackAttachment{ {
Text: "<!here>", Text: "<!here>",
}, },
} }
@@ -212,7 +212,7 @@ func TestHandleCommandResponsePost(t *testing.T) {
resp.ChannelId = "" resp.ChannelId = ""
resp.Text = "<test.com|test website>" resp.Text = "<test.com|test website>"
resp.Attachments = []*model.SlackAttachment{ resp.Attachments = []*model.SlackAttachment{
&model.SlackAttachment{ {
Text: "<!here>", Text: "<!here>",
}, },
} }
@@ -257,10 +257,10 @@ func TestHandleCommandResponse(t *testing.T) {
resp = &model.CommandResponse{ resp = &model.CommandResponse{
Text: "message 1", Text: "message 1",
ExtraResponses: []*model.CommandResponse{ ExtraResponses: []*model.CommandResponse{
&model.CommandResponse{ {
Text: "message 2", Text: "message 2",
}, },
&model.CommandResponse{ {
Type: model.POST_SYSTEM_GENERIC, Type: model.POST_SYSTEM_GENERIC,
Text: "message 3", Text: "message 3",
}, },
@@ -274,8 +274,8 @@ func TestHandleCommandResponse(t *testing.T) {
resp = &model.CommandResponse{ resp = &model.CommandResponse{
ExtraResponses: []*model.CommandResponse{ ExtraResponses: []*model.CommandResponse{
&model.CommandResponse{}, {},
&model.CommandResponse{}, {},
}, },
} }

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

@@ -20,7 +20,7 @@ import (
func TestPluginSetting(t *testing.T) { func TestPluginSetting(t *testing.T) {
settings := &model.PluginSettings{ settings := &model.PluginSettings{
Plugins: map[string]map[string]interface{}{ Plugins: map[string]map[string]interface{}{
"test": map[string]interface{}{ "test": {
"foo": "bar", "foo": "bar",
}, },
}, },
@@ -31,10 +31,10 @@ func TestPluginSetting(t *testing.T) {
func TestPluginActivated(t *testing.T) { func TestPluginActivated(t *testing.T) {
states := map[string]*model.PluginState{ states := map[string]*model.PluginState{
"foo": &model.PluginState{ "foo": {
Enable: true, Enable: true,
}, },
"bar": &model.PluginState{ "bar": {
Enable: false, 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: 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.Add(&model.User{Id: id2}, &model.Post{UserId: id1, Message: "test5"}, &model.Team{Name: "team"})
job.handleNewNotifications() 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][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][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[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][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[id2][1].post.Message, "test5", "incorrect order of received posts for user2")
} }
func TestCheckPendingNotifications(t *testing.T) { func TestCheckPendingNotifications(t *testing.T) {

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

@@ -487,7 +487,7 @@ func TestImportValidateUserImportData(t *testing.T) {
data.Username = ptrStr("i am a username with spaces and !!!") data.Username = ptrStr("i am a username with spaces and !!!")
err = validateUserImportData(&data) 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") data.Username = ptrStr("bob")
@@ -759,7 +759,6 @@ func TestImportValidateReactionImportData(t *testing.T) {
err = validateReactionImportData(&data, parentCreateAt) err = validateReactionImportData(&data, parentCreateAt)
require.NotNil(t, err, "Should have failed due to missing required property.") require.NotNil(t, err, "Should have failed due to missing required property.")
data = ReactionImportData{ data = ReactionImportData{
User: ptrStr("username"), User: ptrStr("username"),
EmojiName: ptrStr("emoji"), 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.") require.NotNil(t, err, "Should have failed due to 0 create-at value.")
// Test with valid all optional parameters. // Test with valid all optional parameters.
reactions := []ReactionImportData{ReactionImportData{ reactions := []ReactionImportData{{
User: ptrStr("username"), User: ptrStr("username"),
EmojiName: ptrStr("emoji"), EmojiName: ptrStr("emoji"),
CreateAt: ptrInt64(model.GetMillis()), CreateAt: ptrInt64(model.GetMillis()),
}} }}
replies := []ReplyImportData{ReplyImportData{ replies := []ReplyImportData{{
User: ptrStr("username"), User: ptrStr("username"),
Message: ptrStr("message"), Message: ptrStr("message"),
CreateAt: ptrInt64(model.GetMillis()), 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") require.Nil(t, err, "Validation should succeed with post flagged by members")
// Test with valid all optional parameters. // Test with valid all optional parameters.
reactions := []ReactionImportData{ReactionImportData{ reactions := []ReactionImportData{{
User: ptrStr("username"), User: ptrStr("username"),
EmojiName: ptrStr("emoji"), EmojiName: ptrStr("emoji"),
CreateAt: ptrInt64(model.GetMillis()), CreateAt: ptrInt64(model.GetMillis()),
}} }}
replies := []ReplyImportData{ReplyImportData{ replies := []ReplyImportData{{
User: ptrStr("username"), User: ptrStr("username"),
Message: ptrStr("message"), Message: ptrStr("message"),
CreateAt: ptrInt64(model.GetMillis()), CreateAt: ptrInt64(model.GetMillis()),

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

@@ -389,13 +389,13 @@ func TestSplitWebhookPost(t *testing.T) {
Message: strings.Repeat("本", maxPostSize*3/2), Message: strings.Repeat("本", maxPostSize*3/2),
Props: map[string]interface{}{ Props: map[string]interface{}{
"attachments": []*model.SlackAttachment{ "attachments": []*model.SlackAttachment{
&model.SlackAttachment{ {
Text: strings.Repeat("本", 1000), Text: strings.Repeat("本", 1000),
}, },
&model.SlackAttachment{ {
Text: strings.Repeat("本", 2000), Text: strings.Repeat("本", 2000),
}, },
&model.SlackAttachment{ {
Text: strings.Repeat("本", model.POST_PROPS_MAX_USER_RUNES-1000), Text: strings.Repeat("本", model.POST_PROPS_MAX_USER_RUNES-1000),
}, },
}, },
@@ -409,10 +409,10 @@ func TestSplitWebhookPost(t *testing.T) {
Message: strings.Repeat("本", maxPostSize/2), Message: strings.Repeat("本", maxPostSize/2),
Props: map[string]interface{}{ Props: map[string]interface{}{
"attachments": []*model.SlackAttachment{ "attachments": []*model.SlackAttachment{
&model.SlackAttachment{ {
Text: strings.Repeat("本", 1000), Text: strings.Repeat("本", 1000),
}, },
&model.SlackAttachment{ {
Text: strings.Repeat("本", 2000), Text: strings.Repeat("本", 2000),
}, },
}, },
@@ -421,7 +421,7 @@ func TestSplitWebhookPost(t *testing.T) {
{ {
Props: map[string]interface{}{ Props: map[string]interface{}{
"attachments": []*model.SlackAttachment{ "attachments": []*model.SlackAttachment{
&model.SlackAttachment{ {
Text: strings.Repeat("本", model.POST_PROPS_MAX_USER_RUNES-1000), Text: strings.Repeat("本", model.POST_PROPS_MAX_USER_RUNES-1000),
}, },
}, },

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

@@ -89,7 +89,6 @@ func TestChangeUserEmail(t *testing.T) {
require.Equal(t, user.Email, newEmail, "should've updated to the new email") require.Equal(t, user.Email, newEmail, "should've updated to the new email")
// should fail because using an invalid email // should fail because using an invalid email
require.Error(t, th.RunCommand(t, "user", "email", th.BasicUser.Username, "wrong$email.com")) require.Error(t, th.RunCommand(t, "user", "email", th.BasicUser.Username, "wrong$email.com"))

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

@@ -764,7 +764,7 @@ func TestDatabaseStoreLoad(t *testing.T) {
func TestDatabaseGetFile(t *testing.T) { func TestDatabaseGetFile(t *testing.T) {
_, tearDown := setupConfigDatabase(t, minimalConfig, map[string][]byte{ _, tearDown := setupConfigDatabase(t, minimalConfig, map[string][]byte{
"empty-file": []byte{}, "empty-file": {},
"test-file": []byte("test"), "test-file": []byte("test"),
}) })
defer tearDown() defer tearDown()

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

@@ -282,7 +282,7 @@ func TestMemoryGetFile(t *testing.T) {
ms, err := config.NewMemoryStoreWithOptions(&config.MemoryStoreOptions{ ms, err := config.NewMemoryStoreWithOptions(&config.MemoryStoreOptions{
InitialConfig: minimalConfig, InitialConfig: minimalConfig,
InitialFiles: map[string][]byte{ InitialFiles: map[string][]byte{
"empty-file": []byte{}, "empty-file": {},
"test-file": []byte("test"), "test-file": []byte("test"),
}, },
}) })

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

@@ -17,9 +17,9 @@ func TestClient4CreatePost(t *testing.T) {
post := &Post{ post := &Post{
Props: map[string]interface{}{ Props: map[string]interface{}{
"attachments": []*SlackAttachment{ "attachments": []*SlackAttachment{
&SlackAttachment{ {
Actions: []*PostAction{ Actions: []*PostAction{
&PostAction{ {
Integration: &PostActionIntegration{ Integration: &PostActionIntegration{
Context: map[string]interface{}{ Context: map[string]interface{}{
"foo": "bar", "foo": "bar",
@@ -37,9 +37,9 @@ func TestClient4CreatePost(t *testing.T) {
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
attachments := PostFromJson(r.Body).Attachments() attachments := PostFromJson(r.Body).Attachments()
assert.Equal(t, []*SlackAttachment{ assert.Equal(t, []*SlackAttachment{
&SlackAttachment{ {
Actions: []*PostAction{ Actions: []*PostAction{
&PostAction{ {
Integration: &PostActionIntegration{ Integration: &PostActionIntegration{
Context: map[string]interface{}{ Context: map[string]interface{}{
"foo": "bar", "foo": "bar",

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

@@ -146,7 +146,7 @@ func TestCommandResponseFromJson(t *testing.T) {
&CommandResponse{ &CommandResponse{
Text: "message 1", Text: "message 1",
ExtraResponses: []*CommandResponse{ ExtraResponses: []*CommandResponse{
&CommandResponse{ {
Text: "message 2", Text: "message 2",
}, },
}, },
@@ -180,7 +180,7 @@ func TestCommandResponseFromJson(t *testing.T) {
}, },
}, },
ExtraResponses: []*CommandResponse{ ExtraResponses: []*CommandResponse{
&CommandResponse{ {
Text: "message 2", Text: "message 2",
Attachments: []*SlackAttachment{ Attachments: []*SlackAttachment{
{ {

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

@@ -305,8 +305,8 @@ func TestTruncateOpenGraph(t *testing.T) {
sampleImage("metoo.gif"), sampleImage("metoo.gif"),
sampleImage("fifth.ico"), sampleImage("fifth.ico"),
sampleImage("notme.tiff")}, sampleImage("notme.tiff")},
Audios: []*opengraph.Audio{&opengraph.Audio{}}, Audios: []*opengraph.Audio{{}},
Videos: []*opengraph.Video{&opengraph.Video{}}, Videos: []*opengraph.Video{{}},
Article: &opengraph.Article{}, Article: &opengraph.Article{},
Book: &opengraph.Book{}, Book: &opengraph.Book{},
Profile: &opengraph.Profile{}, Profile: &opengraph.Profile{},

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

@@ -83,7 +83,7 @@ func TestManifestUnmarshal(t *testing.T) {
Header: "theheadertext", Header: "theheadertext",
Footer: "thefootertext", Footer: "thefootertext",
Settings: []*PluginSetting{ Settings: []*PluginSetting{
&PluginSetting{ {
Key: "thesetting", Key: "thesetting",
DisplayName: "thedisplayname", DisplayName: "thedisplayname",
Type: "dropdown", Type: "dropdown",
@@ -91,7 +91,7 @@ func TestManifestUnmarshal(t *testing.T) {
RegenerateHelpText: "theregeneratehelptext", RegenerateHelpText: "theregeneratehelptext",
Placeholder: "theplaceholder", Placeholder: "theplaceholder",
Options: []*PluginOption{ Options: []*PluginOption{
&PluginOption{ {
DisplayName: "theoptiondisplayname", DisplayName: "theoptiondisplayname",
Value: "thevalue", Value: "thevalue",
}, },
@@ -232,7 +232,7 @@ func TestManifestJson(t *testing.T) {
Header: "theheadertext", Header: "theheadertext",
Footer: "thefootertext", Footer: "thefootertext",
Settings: []*PluginSetting{ Settings: []*PluginSetting{
&PluginSetting{ {
Key: "thesetting", Key: "thesetting",
DisplayName: "thedisplayname", DisplayName: "thedisplayname",
Type: "dropdown", Type: "dropdown",
@@ -240,7 +240,7 @@ func TestManifestJson(t *testing.T) {
RegenerateHelpText: "theregeneratehelptext", RegenerateHelpText: "theregeneratehelptext",
Placeholder: "theplaceholder", Placeholder: "theplaceholder",
Options: []*PluginOption{ Options: []*PluginOption{
&PluginOption{ {
DisplayName: "theoptiondisplayname", DisplayName: "theoptiondisplayname",
Value: "thevalue", Value: "thevalue",
}, },
@@ -299,7 +299,7 @@ func TestManifestClientManifest(t *testing.T) {
Header: "theheadertext", Header: "theheadertext",
Footer: "thefootertext", Footer: "thefootertext",
Settings: []*PluginSetting{ Settings: []*PluginSetting{
&PluginSetting{ {
Key: "thesetting", Key: "thesetting",
DisplayName: "thedisplayname", DisplayName: "thedisplayname",
Type: "dropdown", Type: "dropdown",
@@ -307,7 +307,7 @@ func TestManifestClientManifest(t *testing.T) {
RegenerateHelpText: "theregeneratehelptext", RegenerateHelpText: "theregeneratehelptext",
Placeholder: "theplaceholder", Placeholder: "theplaceholder",
Options: []*PluginOption{ Options: []*PluginOption{
&PluginOption{ {
DisplayName: "theoptiondisplayname", DisplayName: "theoptiondisplayname",
Value: "thevalue", Value: "thevalue",
}, },

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

@@ -8,8 +8,8 @@ import (
"testing" "testing"
"time" "time"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
) )
func TestSessionDeepCopy(t *testing.T) { func TestSessionDeepCopy(t *testing.T) {
@@ -18,7 +18,7 @@ func TestSessionDeepCopy(t *testing.T) {
mapKey := "key" mapKey := "key"
mapValue := "val" 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 := session.DeepCopy()
copySession.Id = "changed" copySession.Id = "changed"

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

@@ -63,7 +63,7 @@ func TestUserPreSave(t *testing.T) {
user.PreSave() user.PreSave()
user.Etag(true, true) user.Etag(true, true)
assert.NotNil(t, user.Timezone, "Timezone is nil") 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) { func TestUserPreUpdate(t *testing.T) {

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

@@ -75,19 +75,19 @@ func createChannelMemberHistory(ss store.Store, channelId, userId string) *model
} }
func createChannelWithTeamId(ss store.Store, id string) *model.Channel { 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 { 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 { 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 { 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 { func createCommandWebhook(ss store.Store, commandId, userId, channelId string) *model.CommandWebhook {
@@ -192,11 +192,11 @@ func createPost(ss store.Store, channelId, userId, rootId, parentId string) *mod
} }
func createPostWithChannelId(ss store.Store, id string) *model.Post { 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 { 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 { func createPreferences(ss store.Store, userId string) *model.Preferences {