MM-31063: Change constants to use CamelCase (#16608)
* MM-31063: Change constants to use CamelCase * store package * change allcaps to camel case (#16615) * New tools.mod Co-authored-by: Ibrahim Serdar Acikgoz <serdaracikgoz86@gmail.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
8b6ac5f5d2
Коммит
c1dd23a3c8
@@ -72,7 +72,7 @@ func TestEnsureBot(t *testing.T) {
|
||||
|
||||
api := setupAPI()
|
||||
api.On("GetServerVersion").Return("5.10.0")
|
||||
api.On("KVGet", plugin.BOT_USER_KEY).Return([]byte(expectedBotID), nil)
|
||||
api.On("KVGet", plugin.BotUserKey).Return([]byte(expectedBotID), nil)
|
||||
api.On("PatchBot", expectedBotID, &model.BotPatch{
|
||||
Username: &testbot.Username,
|
||||
DisplayName: &testbot.DisplayName,
|
||||
@@ -92,7 +92,7 @@ func TestEnsureBot(t *testing.T) {
|
||||
t.Run("should return an error if unable to get bot", func(t *testing.T) {
|
||||
api := setupAPI()
|
||||
api.On("GetServerVersion").Return("5.10.0")
|
||||
api.On("KVGet", plugin.BOT_USER_KEY).Return(nil, &model.AppError{})
|
||||
api.On("KVGet", plugin.BotUserKey).Return(nil, &model.AppError{})
|
||||
defer api.AssertExpectations(t)
|
||||
|
||||
p := &plugin.HelpersImpl{}
|
||||
@@ -112,7 +112,7 @@ func TestEnsureBot(t *testing.T) {
|
||||
testImage := filepath.Join(testsDir, "test.png")
|
||||
imageBytes, err := ioutil.ReadFile(testImage)
|
||||
|
||||
api.On("KVGet", plugin.BOT_USER_KEY).Return([]byte(expectedBotID), nil)
|
||||
api.On("KVGet", plugin.BotUserKey).Return([]byte(expectedBotID), nil)
|
||||
api.On("GetBundlePath").Return("", nil)
|
||||
api.On("SetProfileImage", expectedBotID, imageBytes).Return(nil)
|
||||
api.On("GetServerVersion").Return("5.10.0")
|
||||
@@ -142,7 +142,7 @@ func TestEnsureBot(t *testing.T) {
|
||||
imageBytes, err := ioutil.ReadFile(testImage)
|
||||
assert.Nil(t, err)
|
||||
|
||||
api.On("KVGet", plugin.BOT_USER_KEY).Return([]byte(expectedBotID), nil)
|
||||
api.On("KVGet", plugin.BotUserKey).Return([]byte(expectedBotID), nil)
|
||||
api.On("GetBundlePath").Return("", nil)
|
||||
api.On("SetBotIconImage", expectedBotID, imageBytes).Return(nil)
|
||||
api.On("GetServerVersion").Return("5.10.0")
|
||||
@@ -170,7 +170,7 @@ func TestEnsureBot(t *testing.T) {
|
||||
imageBytes, err := ioutil.ReadFile(testImage)
|
||||
assert.Nil(t, err)
|
||||
|
||||
api.On("KVGet", plugin.BOT_USER_KEY).Return([]byte(expectedBotID), nil)
|
||||
api.On("KVGet", plugin.BotUserKey).Return([]byte(expectedBotID), nil)
|
||||
api.On("GetBundlePath").Return("", nil)
|
||||
api.On("SetProfileImage", expectedBotID, imageBytes).Return(nil)
|
||||
api.On("SetBotIconImage", expectedBotID, imageBytes).Return(nil)
|
||||
@@ -204,7 +204,7 @@ func TestEnsureBot(t *testing.T) {
|
||||
|
||||
api := setupAPI()
|
||||
api.On("GetServerVersion").Return("5.10.0")
|
||||
api.On("KVGet", plugin.BOT_USER_KEY).Return([]byte(expectedBotID), nil)
|
||||
api.On("KVGet", plugin.BotUserKey).Return([]byte(expectedBotID), nil)
|
||||
api.On("GetBundlePath").Return("", nil)
|
||||
api.On("SetProfileImage", expectedBotID, imageBytes).Return(nil)
|
||||
api.On("SetBotIconImage", expectedBotID, imageBytes).Return(nil)
|
||||
@@ -236,12 +236,12 @@ func TestEnsureBot(t *testing.T) {
|
||||
|
||||
api := setupAPI()
|
||||
api.On("GetServerVersion").Return("5.10.0")
|
||||
api.On("KVGet", plugin.BOT_USER_KEY).Return(nil, nil)
|
||||
api.On("KVGet", plugin.BotUserKey).Return(nil, nil)
|
||||
api.On("GetUserByUsername", testbot.Username).Return(nil, nil)
|
||||
api.On("CreateBot", testbot).Return(&model.Bot{
|
||||
UserId: expectedBotID,
|
||||
}, nil)
|
||||
api.On("KVSet", plugin.BOT_USER_KEY, []byte(expectedBotID)).Return(nil)
|
||||
api.On("KVSet", plugin.BotUserKey, []byte(expectedBotID)).Return(nil)
|
||||
defer api.AssertExpectations(t)
|
||||
|
||||
p := &plugin.HelpersImpl{}
|
||||
@@ -258,12 +258,12 @@ func TestEnsureBot(t *testing.T) {
|
||||
|
||||
api := setupAPI()
|
||||
api.On("GetServerVersion").Return("5.10.0")
|
||||
api.On("KVGet", plugin.BOT_USER_KEY).Return(nil, nil)
|
||||
api.On("KVGet", plugin.BotUserKey).Return(nil, nil)
|
||||
api.On("GetUserByUsername", testbot.Username).Return(&model.User{
|
||||
Id: expectedBotID,
|
||||
IsBot: true,
|
||||
}, nil)
|
||||
api.On("KVSet", plugin.BOT_USER_KEY, []byte(expectedBotID)).Return(nil)
|
||||
api.On("KVSet", plugin.BotUserKey, []byte(expectedBotID)).Return(nil)
|
||||
defer api.AssertExpectations(t)
|
||||
|
||||
p := &plugin.HelpersImpl{}
|
||||
@@ -279,7 +279,7 @@ func TestEnsureBot(t *testing.T) {
|
||||
expectedBotID := model.NewId()
|
||||
api := setupAPI()
|
||||
api.On("GetServerVersion").Return("5.10.0")
|
||||
api.On("KVGet", plugin.BOT_USER_KEY).Return(nil, nil)
|
||||
api.On("KVGet", plugin.BotUserKey).Return(nil, nil)
|
||||
api.On("GetUserByUsername", testbot.Username).Return(&model.User{
|
||||
Id: expectedBotID,
|
||||
IsBot: false,
|
||||
@@ -299,7 +299,7 @@ func TestEnsureBot(t *testing.T) {
|
||||
t.Run("should fail if create bot fails", func(t *testing.T) {
|
||||
api := setupAPI()
|
||||
api.On("GetServerVersion").Return("5.10.0")
|
||||
api.On("KVGet", plugin.BOT_USER_KEY).Return(nil, nil)
|
||||
api.On("KVGet", plugin.BotUserKey).Return(nil, nil)
|
||||
api.On("GetUserByUsername", testbot.Username).Return(nil, nil)
|
||||
api.On("CreateBot", testbot).Return(nil, &model.AppError{})
|
||||
defer api.AssertExpectations(t)
|
||||
@@ -322,12 +322,12 @@ func TestEnsureBot(t *testing.T) {
|
||||
imageBytes, err := ioutil.ReadFile(testImage)
|
||||
assert.Nil(t, err)
|
||||
|
||||
api.On("KVGet", plugin.BOT_USER_KEY).Return(nil, nil)
|
||||
api.On("KVGet", plugin.BotUserKey).Return(nil, nil)
|
||||
api.On("GetUserByUsername", testbot.Username).Return(nil, nil)
|
||||
api.On("CreateBot", testbot).Return(&model.Bot{
|
||||
UserId: expectedBotID,
|
||||
}, nil)
|
||||
api.On("KVSet", plugin.BOT_USER_KEY, []byte(expectedBotID)).Return(nil)
|
||||
api.On("KVSet", plugin.BotUserKey, []byte(expectedBotID)).Return(nil)
|
||||
api.On("GetBundlePath").Return("", nil)
|
||||
api.On("SetProfileImage", expectedBotID, imageBytes).Return(nil)
|
||||
api.On("GetServerVersion").Return("5.10.0")
|
||||
@@ -350,12 +350,12 @@ func TestEnsureBot(t *testing.T) {
|
||||
imageBytes, err := ioutil.ReadFile(testImage)
|
||||
assert.Nil(t, err)
|
||||
|
||||
api.On("KVGet", plugin.BOT_USER_KEY).Return(nil, nil)
|
||||
api.On("KVGet", plugin.BotUserKey).Return(nil, nil)
|
||||
api.On("GetUserByUsername", testbot.Username).Return(nil, nil)
|
||||
api.On("CreateBot", testbot).Return(&model.Bot{
|
||||
UserId: expectedBotID,
|
||||
}, nil)
|
||||
api.On("KVSet", plugin.BOT_USER_KEY, []byte(expectedBotID)).Return(nil)
|
||||
api.On("KVSet", plugin.BotUserKey, []byte(expectedBotID)).Return(nil)
|
||||
api.On("GetBundlePath").Return("", nil)
|
||||
api.On("SetBotIconImage", expectedBotID, imageBytes).Return(nil)
|
||||
api.On("GetServerVersion").Return("5.10.0")
|
||||
@@ -378,12 +378,12 @@ func TestEnsureBot(t *testing.T) {
|
||||
imageBytes, err := ioutil.ReadFile(testImage)
|
||||
assert.Nil(t, err)
|
||||
|
||||
api.On("KVGet", plugin.BOT_USER_KEY).Return(nil, nil)
|
||||
api.On("KVGet", plugin.BotUserKey).Return(nil, nil)
|
||||
api.On("GetUserByUsername", testbot.Username).Return(nil, nil)
|
||||
api.On("CreateBot", testbot).Return(&model.Bot{
|
||||
UserId: expectedBotID,
|
||||
}, nil)
|
||||
api.On("KVSet", plugin.BOT_USER_KEY, []byte(expectedBotID)).Return(nil)
|
||||
api.On("KVSet", plugin.BotUserKey, []byte(expectedBotID)).Return(nil)
|
||||
api.On("GetBundlePath").Return("", nil)
|
||||
api.On("SetProfileImage", expectedBotID, imageBytes).Return(nil)
|
||||
api.On("SetBotIconImage", expectedBotID, imageBytes).Return(nil)
|
||||
@@ -410,7 +410,7 @@ func TestShouldProcessMessage(t *testing.T) {
|
||||
|
||||
t.Run("should not respond to itself", func(t *testing.T) {
|
||||
api := setupAPI()
|
||||
api.On("KVGet", plugin.BOT_USER_KEY).Return([]byte(expectedBotID), nil)
|
||||
api.On("KVGet", plugin.BotUserKey).Return([]byte(expectedBotID), nil)
|
||||
p.API = api
|
||||
shouldProcessMessage, _ := p.ShouldProcessMessage(&model.Post{Type: model.POST_HEADER_CHANGE, UserId: expectedBotID}, plugin.AllowSystemMessages(), plugin.AllowBots())
|
||||
|
||||
@@ -428,7 +428,7 @@ func TestShouldProcessMessage(t *testing.T) {
|
||||
api := setupAPI()
|
||||
api.On("GetChannel", channelID).Return(&model.Channel{Id: channelID, Type: model.CHANNEL_GROUP}, nil)
|
||||
p.API = api
|
||||
api.On("KVGet", plugin.BOT_USER_KEY).Return([]byte(expectedBotID), nil)
|
||||
api.On("KVGet", plugin.BotUserKey).Return([]byte(expectedBotID), nil)
|
||||
|
||||
shouldProcessMessage, _ := p.ShouldProcessMessage(&model.Post{ChannelId: channelID}, plugin.AllowSystemMessages(), plugin.AllowBots(), plugin.FilterChannelIDs([]string{"another-channel-id"}))
|
||||
|
||||
@@ -441,7 +441,7 @@ func TestShouldProcessMessage(t *testing.T) {
|
||||
api := setupAPI()
|
||||
p.API = api
|
||||
api.On("GetUser", userID).Return(&model.User{IsBot: true}, nil)
|
||||
api.On("KVGet", plugin.BOT_USER_KEY).Return([]byte(expectedBotID), nil)
|
||||
api.On("KVGet", plugin.BotUserKey).Return([]byte(expectedBotID), nil)
|
||||
|
||||
shouldProcessMessage, _ := p.ShouldProcessMessage(&model.Post{UserId: userID, ChannelId: channelID},
|
||||
plugin.AllowSystemMessages(), plugin.FilterUserIDs([]string{"another-user-id"}))
|
||||
@@ -458,7 +458,7 @@ func TestShouldProcessMessage(t *testing.T) {
|
||||
}
|
||||
api := setupAPI()
|
||||
api.On("GetChannel", channelID).Return(&channel, nil)
|
||||
api.On("KVGet", plugin.BOT_USER_KEY).Return([]byte(expectedBotID), nil)
|
||||
api.On("KVGet", plugin.BotUserKey).Return([]byte(expectedBotID), nil)
|
||||
p.API = api
|
||||
|
||||
shouldProcessMessage, _ := p.ShouldProcessMessage(&model.Post{UserId: userID, ChannelId: channelID}, plugin.AllowSystemMessages(), plugin.AllowBots(), plugin.OnlyBotDMs())
|
||||
@@ -469,7 +469,7 @@ func TestShouldProcessMessage(t *testing.T) {
|
||||
t.Run("should process the message", func(t *testing.T) {
|
||||
channelID := "1"
|
||||
api := setupAPI()
|
||||
api.On("KVGet", plugin.BOT_USER_KEY).Return([]byte(expectedBotID), nil)
|
||||
api.On("KVGet", plugin.BotUserKey).Return([]byte(expectedBotID), nil)
|
||||
p.API = api
|
||||
|
||||
shouldProcessMessage, _ := p.ShouldProcessMessage(&model.Post{UserId: "1", Type: model.POST_HEADER_CHANGE, ChannelId: channelID},
|
||||
@@ -481,7 +481,7 @@ func TestShouldProcessMessage(t *testing.T) {
|
||||
t.Run("should process the message for plugin without a bot", func(t *testing.T) {
|
||||
channelID := "1"
|
||||
api := setupAPI()
|
||||
api.On("KVGet", plugin.BOT_USER_KEY).Return(nil, nil)
|
||||
api.On("KVGet", plugin.BotUserKey).Return(nil, nil)
|
||||
p.API = api
|
||||
|
||||
shouldProcessMessage, _ := p.ShouldProcessMessage(&model.Post{UserId: "1", Type: model.POST_HEADER_CHANGE, ChannelId: channelID},
|
||||
@@ -498,7 +498,7 @@ func TestShouldProcessMessage(t *testing.T) {
|
||||
Type: model.CHANNEL_DIRECT,
|
||||
}
|
||||
api.On("GetChannel", channelID).Return(&channel, nil)
|
||||
api.On("KVGet", plugin.BOT_USER_KEY).Return([]byte(expectedBotID), nil)
|
||||
api.On("KVGet", plugin.BotUserKey).Return([]byte(expectedBotID), nil)
|
||||
p.API = api
|
||||
|
||||
shouldProcessMessage, _ := p.ShouldProcessMessage(&model.Post{UserId: "1", Type: model.POST_HEADER_CHANGE, ChannelId: channelID},
|
||||
@@ -512,7 +512,7 @@ func TestShouldProcessMessage(t *testing.T) {
|
||||
api := setupAPI()
|
||||
api.On("GetChannel", channelID).Return(&model.Channel{Id: channelID, Type: model.CHANNEL_GROUP}, nil)
|
||||
p.API = api
|
||||
api.On("KVGet", plugin.BOT_USER_KEY).Return([]byte(expectedBotID), nil)
|
||||
api.On("KVGet", plugin.BotUserKey).Return([]byte(expectedBotID), nil)
|
||||
|
||||
shouldProcessMessage, err := p.ShouldProcessMessage(&model.Post{ChannelId: channelID, Props: model.StringInterface{"from_webhook": "true"}}, plugin.AllowBots())
|
||||
|
||||
@@ -525,7 +525,7 @@ func TestShouldProcessMessage(t *testing.T) {
|
||||
api := setupAPI()
|
||||
api.On("GetChannel", channelID).Return(&model.Channel{Id: channelID, Type: model.CHANNEL_GROUP}, nil)
|
||||
p.API = api
|
||||
api.On("KVGet", plugin.BOT_USER_KEY).Return([]byte(expectedBotID), nil)
|
||||
api.On("KVGet", plugin.BotUserKey).Return([]byte(expectedBotID), nil)
|
||||
|
||||
shouldProcessMessage, err := p.ShouldProcessMessage(&model.Post{ChannelId: channelID, Props: model.StringInterface{"from_webhook": "true"}}, plugin.AllowBots(), plugin.AllowWebhook())
|
||||
assert.Nil(t, err)
|
||||
@@ -538,7 +538,7 @@ func TestShouldProcessMessage(t *testing.T) {
|
||||
api := setupAPI()
|
||||
api.On("GetChannel", channelID).Return(&model.Channel{Id: channelID, Type: model.CHANNEL_GROUP}, nil)
|
||||
p.API = api
|
||||
api.On("KVGet", plugin.BOT_USER_KEY).Return([]byte(expectedBotID), nil)
|
||||
api.On("KVGet", plugin.BotUserKey).Return([]byte(expectedBotID), nil)
|
||||
|
||||
shouldProcessMessage, err := p.ShouldProcessMessage(&model.Post{ChannelId: channelID}, plugin.AllowBots())
|
||||
assert.Nil(t, err)
|
||||
@@ -551,7 +551,7 @@ func TestShouldProcessMessage(t *testing.T) {
|
||||
api := setupAPI()
|
||||
api.On("GetChannel", channelID).Return(&model.Channel{Id: channelID, Type: model.CHANNEL_GROUP}, nil)
|
||||
p.API = api
|
||||
api.On("KVGet", plugin.BOT_USER_KEY).Return([]byte(expectedBotID), nil)
|
||||
api.On("KVGet", plugin.BotUserKey).Return([]byte(expectedBotID), nil)
|
||||
|
||||
shouldProcessMessage, err := p.ShouldProcessMessage(&model.Post{ChannelId: channelID, Props: model.StringInterface{"from_webhook": "false"}}, plugin.AllowBots())
|
||||
assert.Nil(t, err)
|
||||
|
||||
Ссылка в новой задаче
Block a user