[MM-20723] Add golint for plugin package to golangci (#13090)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
d12bf77f53
Коммит
5122b9e292
@@ -17,6 +17,7 @@ linters:
|
|||||||
enable:
|
enable:
|
||||||
- deadcode
|
- deadcode
|
||||||
- gofmt
|
- gofmt
|
||||||
|
- golint
|
||||||
- gosimple
|
- gosimple
|
||||||
- govet
|
- govet
|
||||||
- ineffassign
|
- ineffassign
|
||||||
@@ -34,3 +35,8 @@ issues:
|
|||||||
# add more as required.
|
# add more as required.
|
||||||
- unused
|
- unused
|
||||||
text: "RedisSupplier|LocalCacheSupplier|Enterprise"
|
text: "RedisSupplier|LocalCacheSupplier|Enterprise"
|
||||||
|
|
||||||
|
- linters:
|
||||||
|
# ignore golint error for a lot of packages for now
|
||||||
|
- golint
|
||||||
|
path: "api4|app|cmd|config|einterface|enterprise|imports|jobs|manualtesting|migrations|mlog|model|testlib|services|store|utils|web|wsapi|plugin/api.go|plugin/context.go|plugin/client.go|plugin/client_rpc.go|plugin/environment.go|plugin/health_check.go|plugin/hooks.go|plugin/supervisor.go|plugin/valid.go"
|
||||||
|
|||||||
5
Makefile
5
Makefile
@@ -202,10 +202,7 @@ check-licenses: ## Checks license status.
|
|||||||
check-prereqs: ## Checks prerequisite software status.
|
check-prereqs: ## Checks prerequisite software status.
|
||||||
./scripts/prereq-check.sh
|
./scripts/prereq-check.sh
|
||||||
|
|
||||||
check-style: golangci-lint plugin-checker check-licenses check-plugin-golint ## Runs golangci against all packages and also ensures plugin package golint compliant
|
check-style: golangci-lint plugin-checker check-licenses ## Runs golangci against all packages
|
||||||
|
|
||||||
check-plugin-golint: # Checks if golint returns any uncompliant code for any file that starts with plugin/helpers
|
|
||||||
@! golint ./plugin/ | grep plugin/helpers
|
|
||||||
|
|
||||||
test-te-race: ## Checks for race conditions in the team edition.
|
test-te-race: ## Checks for race conditions in the team edition.
|
||||||
@echo Testing TE race conditions
|
@echo Testing TE race conditions
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ type configuration struct {
|
|||||||
TeamName string
|
TeamName string
|
||||||
ChannelName string
|
ChannelName string
|
||||||
|
|
||||||
// channelId is resolved when the public configuration fields above change
|
// channelID is resolved when the public configuration fields above change
|
||||||
channelId string
|
channelID string
|
||||||
}
|
}
|
||||||
|
|
||||||
type HelpPlugin struct {
|
type HelpPlugin struct {
|
||||||
@@ -78,7 +78,7 @@ func (p *HelpPlugin) OnConfigurationChange() error {
|
|||||||
return errors.Wrapf(err, "failed to find channel %s", configuration.ChannelName)
|
return errors.Wrapf(err, "failed to find channel %s", configuration.ChannelName)
|
||||||
}
|
}
|
||||||
|
|
||||||
configuration.channelId = channel.Id
|
configuration.channelID = channel.Id
|
||||||
|
|
||||||
p.setConfiguration(configuration)
|
p.setConfiguration(configuration)
|
||||||
|
|
||||||
@@ -89,7 +89,7 @@ func (p *HelpPlugin) MessageHasBeenPosted(c *plugin.Context, post *model.Post) {
|
|||||||
configuration := p.getConfiguration()
|
configuration := p.getConfiguration()
|
||||||
|
|
||||||
// Ignore posts not in the configured channel
|
// Ignore posts not in the configured channel
|
||||||
if post.ChannelId != configuration.channelId {
|
if post.ChannelId != configuration.channelID {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,7 +104,7 @@ func (p *HelpPlugin) MessageHasBeenPosted(c *plugin.Context, post *model.Post) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
p.API.SendEphemeralPost(post.UserId, &model.Post{
|
p.API.SendEphemeralPost(post.UserId, &model.Post{
|
||||||
ChannelId: configuration.channelId,
|
ChannelId: configuration.channelID,
|
||||||
Message: "You asked for help? Checkout https://about.mattermost.com/help/",
|
Message: "You asked for help? Checkout https://about.mattermost.com/help/",
|
||||||
Props: map[string]interface{}{
|
Props: map[string]interface{}{
|
||||||
"sent_by_plugin": true,
|
"sent_by_plugin": true,
|
||||||
|
|||||||
@@ -18,14 +18,14 @@ import (
|
|||||||
|
|
||||||
func TestPluginHealthCheck(t *testing.T) {
|
func TestPluginHealthCheck(t *testing.T) {
|
||||||
for name, f := range map[string]func(*testing.T){
|
for name, f := range map[string]func(*testing.T){
|
||||||
"PluginHealthCheck_Success": testPluginHealthCheck_Success,
|
"PluginHealthCheck_Success": testPluginHealthCheckSuccess,
|
||||||
"PluginHealthCheck_Panic": testPluginHealthCheck_Panic,
|
"PluginHealthCheck_Panic": testPluginHealthCheckPanic,
|
||||||
} {
|
} {
|
||||||
t.Run(name, f)
|
t.Run(name, f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func testPluginHealthCheck_Success(t *testing.T) {
|
func testPluginHealthCheckSuccess(t *testing.T) {
|
||||||
dir, err := ioutil.TempDir("", "")
|
dir, err := ioutil.TempDir("", "")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer os.RemoveAll(dir)
|
defer os.RemoveAll(dir)
|
||||||
@@ -66,7 +66,7 @@ func testPluginHealthCheck_Success(t *testing.T) {
|
|||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testPluginHealthCheck_Panic(t *testing.T) {
|
func testPluginHealthCheckPanic(t *testing.T) {
|
||||||
dir, err := ioutil.TempDir("", "")
|
dir, err := ioutil.TempDir("", "")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer os.RemoveAll(dir)
|
defer os.RemoveAll(dir)
|
||||||
|
|||||||
@@ -123,13 +123,13 @@ func (p *HelpersImpl) ShouldProcessMessage(post *model.Post, options ...ShouldPr
|
|||||||
option(messageProcessOptions)
|
option(messageProcessOptions)
|
||||||
}
|
}
|
||||||
|
|
||||||
botIdBytes, kvGetErr := p.API.KVGet(BOT_USER_KEY)
|
botIDBytes, kvGetErr := p.API.KVGet(BOT_USER_KEY)
|
||||||
if kvGetErr != nil {
|
if kvGetErr != nil {
|
||||||
return false, errors.Wrap(kvGetErr, "failed to get bot")
|
return false, errors.Wrap(kvGetErr, "failed to get bot")
|
||||||
}
|
}
|
||||||
|
|
||||||
if botIdBytes != nil {
|
if botIDBytes != nil {
|
||||||
if post.UserId == string(botIdBytes) {
|
if post.UserId == string(botIDBytes) {
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -157,13 +157,13 @@ func (p *HelpersImpl) ShouldProcessMessage(post *model.Post, options ...ShouldPr
|
|||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if botIdBytes != nil && messageProcessOptions.OnlyBotDMs {
|
if botIDBytes != nil && messageProcessOptions.OnlyBotDMs {
|
||||||
channel, appErr := p.API.GetChannel(post.ChannelId)
|
channel, appErr := p.API.GetChannel(post.ChannelId)
|
||||||
if appErr != nil {
|
if appErr != nil {
|
||||||
return false, errors.Wrap(appErr, "unable to get channel")
|
return false, errors.Wrap(appErr, "unable to get channel")
|
||||||
}
|
}
|
||||||
|
|
||||||
if !model.IsBotDMChannel(channel, string(botIdBytes)) {
|
if !model.IsBotDMChannel(channel, string(botIDBytes)) {
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,8 +48,8 @@ func TestEnsureBot(t *testing.T) {
|
|||||||
|
|
||||||
p := &plugin.HelpersImpl{}
|
p := &plugin.HelpersImpl{}
|
||||||
p.API = api
|
p.API = api
|
||||||
botId, err := p.EnsureBot(nil)
|
botID, err := p.EnsureBot(nil)
|
||||||
assert.Equal(t, "", botId)
|
assert.Equal(t, "", botID)
|
||||||
assert.NotNil(t, err)
|
assert.NotNil(t, err)
|
||||||
})
|
})
|
||||||
t.Run("bad username", func(t *testing.T) {
|
t.Run("bad username", func(t *testing.T) {
|
||||||
@@ -58,29 +58,29 @@ func TestEnsureBot(t *testing.T) {
|
|||||||
|
|
||||||
p := &plugin.HelpersImpl{}
|
p := &plugin.HelpersImpl{}
|
||||||
p.API = api
|
p.API = api
|
||||||
botId, err := p.EnsureBot(&model.Bot{
|
botID, err := p.EnsureBot(&model.Bot{
|
||||||
Username: "",
|
Username: "",
|
||||||
})
|
})
|
||||||
assert.Equal(t, "", botId)
|
assert.Equal(t, "", botID)
|
||||||
assert.NotNil(t, err)
|
assert.NotNil(t, err)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("if bot already exists", func(t *testing.T) {
|
t.Run("if bot already exists", func(t *testing.T) {
|
||||||
t.Run("should find and return the existing bot ID", func(t *testing.T) {
|
t.Run("should find and return the existing bot ID", func(t *testing.T) {
|
||||||
expectedBotId := model.NewId()
|
expectedBotID := model.NewId()
|
||||||
|
|
||||||
api := setupAPI()
|
api := setupAPI()
|
||||||
api.On("GetServerVersion").Return("5.10.0")
|
api.On("GetServerVersion").Return("5.10.0")
|
||||||
api.On("KVGet", plugin.BOT_USER_KEY).Return([]byte(expectedBotId), nil)
|
api.On("KVGet", plugin.BOT_USER_KEY).Return([]byte(expectedBotID), nil)
|
||||||
defer api.AssertExpectations(t)
|
defer api.AssertExpectations(t)
|
||||||
|
|
||||||
p := &plugin.HelpersImpl{}
|
p := &plugin.HelpersImpl{}
|
||||||
p.API = api
|
p.API = api
|
||||||
|
|
||||||
botId, err := p.EnsureBot(testbot)
|
botID, err := p.EnsureBot(testbot)
|
||||||
|
|
||||||
assert.Equal(t, expectedBotId, botId)
|
assert.Equal(t, expectedBotID, botID)
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -93,23 +93,23 @@ func TestEnsureBot(t *testing.T) {
|
|||||||
p := &plugin.HelpersImpl{}
|
p := &plugin.HelpersImpl{}
|
||||||
p.API = api
|
p.API = api
|
||||||
|
|
||||||
botId, err := p.EnsureBot(testbot)
|
botID, err := p.EnsureBot(testbot)
|
||||||
|
|
||||||
assert.Equal(t, "", botId)
|
assert.Equal(t, "", botID)
|
||||||
assert.NotNil(t, err)
|
assert.NotNil(t, err)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("should set the bot profile image when specified", func(t *testing.T) {
|
t.Run("should set the bot profile image when specified", func(t *testing.T) {
|
||||||
expectedBotId := model.NewId()
|
expectedBotID := model.NewId()
|
||||||
api := setupAPI()
|
api := setupAPI()
|
||||||
|
|
||||||
testsDir, _ := fileutils.FindDir("tests")
|
testsDir, _ := fileutils.FindDir("tests")
|
||||||
testImage := filepath.Join(testsDir, "test.png")
|
testImage := filepath.Join(testsDir, "test.png")
|
||||||
imageBytes, err := ioutil.ReadFile(testImage)
|
imageBytes, err := ioutil.ReadFile(testImage)
|
||||||
|
|
||||||
api.On("KVGet", plugin.BOT_USER_KEY).Return([]byte(expectedBotId), nil)
|
api.On("KVGet", plugin.BOT_USER_KEY).Return([]byte(expectedBotID), nil)
|
||||||
api.On("GetBundlePath").Return("", nil)
|
api.On("GetBundlePath").Return("", nil)
|
||||||
api.On("SetProfileImage", expectedBotId, imageBytes).Return(nil)
|
api.On("SetProfileImage", expectedBotID, imageBytes).Return(nil)
|
||||||
api.On("GetServerVersion").Return("5.10.0")
|
api.On("GetServerVersion").Return("5.10.0")
|
||||||
defer api.AssertExpectations(t)
|
defer api.AssertExpectations(t)
|
||||||
|
|
||||||
@@ -118,13 +118,13 @@ func TestEnsureBot(t *testing.T) {
|
|||||||
|
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
|
|
||||||
botId, err := p.EnsureBot(testbot, plugin.ProfileImagePath(testImage))
|
botID, err := p.EnsureBot(testbot, plugin.ProfileImagePath(testImage))
|
||||||
assert.Equal(t, expectedBotId, botId)
|
assert.Equal(t, expectedBotID, botID)
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("should set the bot icon image when specified", func(t *testing.T) {
|
t.Run("should set the bot icon image when specified", func(t *testing.T) {
|
||||||
expectedBotId := model.NewId()
|
expectedBotID := model.NewId()
|
||||||
api := setupAPI()
|
api := setupAPI()
|
||||||
|
|
||||||
testsDir, _ := fileutils.FindDir("tests")
|
testsDir, _ := fileutils.FindDir("tests")
|
||||||
@@ -132,22 +132,22 @@ func TestEnsureBot(t *testing.T) {
|
|||||||
imageBytes, err := ioutil.ReadFile(testImage)
|
imageBytes, err := ioutil.ReadFile(testImage)
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
|
|
||||||
api.On("KVGet", plugin.BOT_USER_KEY).Return([]byte(expectedBotId), nil)
|
api.On("KVGet", plugin.BOT_USER_KEY).Return([]byte(expectedBotID), nil)
|
||||||
api.On("GetBundlePath").Return("", nil)
|
api.On("GetBundlePath").Return("", nil)
|
||||||
api.On("SetBotIconImage", expectedBotId, imageBytes).Return(nil)
|
api.On("SetBotIconImage", expectedBotID, imageBytes).Return(nil)
|
||||||
api.On("GetServerVersion").Return("5.10.0")
|
api.On("GetServerVersion").Return("5.10.0")
|
||||||
defer api.AssertExpectations(t)
|
defer api.AssertExpectations(t)
|
||||||
|
|
||||||
p := &plugin.HelpersImpl{}
|
p := &plugin.HelpersImpl{}
|
||||||
p.API = api
|
p.API = api
|
||||||
|
|
||||||
botId, err := p.EnsureBot(testbot, plugin.IconImagePath(testImage))
|
botID, err := p.EnsureBot(testbot, plugin.IconImagePath(testImage))
|
||||||
assert.Equal(t, expectedBotId, botId)
|
assert.Equal(t, expectedBotID, botID)
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("should set both the profile image and bot icon image when specified", func(t *testing.T) {
|
t.Run("should set both the profile image and bot icon image when specified", func(t *testing.T) {
|
||||||
expectedBotId := model.NewId()
|
expectedBotID := model.NewId()
|
||||||
api := setupAPI()
|
api := setupAPI()
|
||||||
|
|
||||||
testsDir, _ := fileutils.FindDir("tests")
|
testsDir, _ := fileutils.FindDir("tests")
|
||||||
@@ -155,74 +155,74 @@ func TestEnsureBot(t *testing.T) {
|
|||||||
imageBytes, err := ioutil.ReadFile(testImage)
|
imageBytes, err := ioutil.ReadFile(testImage)
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
|
|
||||||
api.On("KVGet", plugin.BOT_USER_KEY).Return([]byte(expectedBotId), nil)
|
api.On("KVGet", plugin.BOT_USER_KEY).Return([]byte(expectedBotID), nil)
|
||||||
api.On("GetBundlePath").Return("", nil)
|
api.On("GetBundlePath").Return("", nil)
|
||||||
api.On("SetProfileImage", expectedBotId, imageBytes).Return(nil)
|
api.On("SetProfileImage", expectedBotID, imageBytes).Return(nil)
|
||||||
api.On("SetBotIconImage", expectedBotId, imageBytes).Return(nil)
|
api.On("SetBotIconImage", expectedBotID, imageBytes).Return(nil)
|
||||||
api.On("GetServerVersion").Return("5.10.0")
|
api.On("GetServerVersion").Return("5.10.0")
|
||||||
defer api.AssertExpectations(t)
|
defer api.AssertExpectations(t)
|
||||||
|
|
||||||
p := &plugin.HelpersImpl{}
|
p := &plugin.HelpersImpl{}
|
||||||
p.API = api
|
p.API = api
|
||||||
|
|
||||||
botId, err := p.EnsureBot(testbot, plugin.ProfileImagePath(testImage), plugin.IconImagePath(testImage))
|
botID, err := p.EnsureBot(testbot, plugin.ProfileImagePath(testImage), plugin.IconImagePath(testImage))
|
||||||
assert.Equal(t, expectedBotId, botId)
|
assert.Equal(t, expectedBotID, botID)
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("if bot doesn't exist", func(t *testing.T) {
|
t.Run("if bot doesn't exist", func(t *testing.T) {
|
||||||
t.Run("should create the bot and return the ID", func(t *testing.T) {
|
t.Run("should create the bot and return the ID", func(t *testing.T) {
|
||||||
expectedBotId := model.NewId()
|
expectedBotID := model.NewId()
|
||||||
|
|
||||||
api := setupAPI()
|
api := setupAPI()
|
||||||
api.On("GetServerVersion").Return("5.10.0")
|
api.On("GetServerVersion").Return("5.10.0")
|
||||||
api.On("KVGet", plugin.BOT_USER_KEY).Return(nil, nil)
|
api.On("KVGet", plugin.BOT_USER_KEY).Return(nil, nil)
|
||||||
api.On("GetUserByUsername", testbot.Username).Return(nil, nil)
|
api.On("GetUserByUsername", testbot.Username).Return(nil, nil)
|
||||||
api.On("CreateBot", testbot).Return(&model.Bot{
|
api.On("CreateBot", testbot).Return(&model.Bot{
|
||||||
UserId: expectedBotId,
|
UserId: expectedBotID,
|
||||||
}, nil)
|
}, nil)
|
||||||
api.On("KVSet", plugin.BOT_USER_KEY, []byte(expectedBotId)).Return(nil)
|
api.On("KVSet", plugin.BOT_USER_KEY, []byte(expectedBotID)).Return(nil)
|
||||||
defer api.AssertExpectations(t)
|
defer api.AssertExpectations(t)
|
||||||
|
|
||||||
p := &plugin.HelpersImpl{}
|
p := &plugin.HelpersImpl{}
|
||||||
p.API = api
|
p.API = api
|
||||||
|
|
||||||
botId, err := p.EnsureBot(testbot)
|
botID, err := p.EnsureBot(testbot)
|
||||||
|
|
||||||
assert.Equal(t, expectedBotId, botId)
|
assert.Equal(t, expectedBotID, botID)
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("should claim existing bot and return the ID", func(t *testing.T) {
|
t.Run("should claim existing bot and return the ID", func(t *testing.T) {
|
||||||
expectedBotId := model.NewId()
|
expectedBotID := model.NewId()
|
||||||
|
|
||||||
api := setupAPI()
|
api := setupAPI()
|
||||||
api.On("GetServerVersion").Return("5.10.0")
|
api.On("GetServerVersion").Return("5.10.0")
|
||||||
api.On("KVGet", plugin.BOT_USER_KEY).Return(nil, nil)
|
api.On("KVGet", plugin.BOT_USER_KEY).Return(nil, nil)
|
||||||
api.On("GetUserByUsername", testbot.Username).Return(&model.User{
|
api.On("GetUserByUsername", testbot.Username).Return(&model.User{
|
||||||
Id: expectedBotId,
|
Id: expectedBotID,
|
||||||
IsBot: true,
|
IsBot: true,
|
||||||
}, nil)
|
}, nil)
|
||||||
api.On("KVSet", plugin.BOT_USER_KEY, []byte(expectedBotId)).Return(nil)
|
api.On("KVSet", plugin.BOT_USER_KEY, []byte(expectedBotID)).Return(nil)
|
||||||
defer api.AssertExpectations(t)
|
defer api.AssertExpectations(t)
|
||||||
|
|
||||||
p := &plugin.HelpersImpl{}
|
p := &plugin.HelpersImpl{}
|
||||||
p.API = api
|
p.API = api
|
||||||
|
|
||||||
botId, err := p.EnsureBot(testbot)
|
botID, err := p.EnsureBot(testbot)
|
||||||
|
|
||||||
assert.Equal(t, expectedBotId, botId)
|
assert.Equal(t, expectedBotID, botID)
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("should return the non-bot account but log a message if user exists with the same name and is not a bot", func(t *testing.T) {
|
t.Run("should return the non-bot account but log a message if user exists with the same name and is not a bot", func(t *testing.T) {
|
||||||
expectedBotId := model.NewId()
|
expectedBotID := model.NewId()
|
||||||
api := setupAPI()
|
api := setupAPI()
|
||||||
api.On("GetServerVersion").Return("5.10.0")
|
api.On("GetServerVersion").Return("5.10.0")
|
||||||
api.On("KVGet", plugin.BOT_USER_KEY).Return(nil, nil)
|
api.On("KVGet", plugin.BOT_USER_KEY).Return(nil, nil)
|
||||||
api.On("GetUserByUsername", testbot.Username).Return(&model.User{
|
api.On("GetUserByUsername", testbot.Username).Return(&model.User{
|
||||||
Id: expectedBotId,
|
Id: expectedBotID,
|
||||||
IsBot: false,
|
IsBot: false,
|
||||||
}, nil)
|
}, nil)
|
||||||
api.On("LogError", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return()
|
api.On("LogError", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return()
|
||||||
@@ -231,9 +231,9 @@ func TestEnsureBot(t *testing.T) {
|
|||||||
p := &plugin.HelpersImpl{}
|
p := &plugin.HelpersImpl{}
|
||||||
p.API = api
|
p.API = api
|
||||||
|
|
||||||
botId, err := p.EnsureBot(testbot)
|
botID, err := p.EnsureBot(testbot)
|
||||||
|
|
||||||
assert.Equal(t, expectedBotId, botId)
|
assert.Equal(t, expectedBotID, botID)
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -248,14 +248,14 @@ func TestEnsureBot(t *testing.T) {
|
|||||||
p := &plugin.HelpersImpl{}
|
p := &plugin.HelpersImpl{}
|
||||||
p.API = api
|
p.API = api
|
||||||
|
|
||||||
botId, err := p.EnsureBot(testbot)
|
botID, err := p.EnsureBot(testbot)
|
||||||
|
|
||||||
assert.Equal(t, "", botId)
|
assert.Equal(t, "", botID)
|
||||||
assert.NotNil(t, err)
|
assert.NotNil(t, err)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("should create bot and set the bot profile image when specified", func(t *testing.T) {
|
t.Run("should create bot and set the bot profile image when specified", func(t *testing.T) {
|
||||||
expectedBotId := model.NewId()
|
expectedBotID := model.NewId()
|
||||||
api := setupAPI()
|
api := setupAPI()
|
||||||
|
|
||||||
testsDir, _ := fileutils.FindDir("tests")
|
testsDir, _ := fileutils.FindDir("tests")
|
||||||
@@ -266,24 +266,24 @@ func TestEnsureBot(t *testing.T) {
|
|||||||
api.On("KVGet", plugin.BOT_USER_KEY).Return(nil, nil)
|
api.On("KVGet", plugin.BOT_USER_KEY).Return(nil, nil)
|
||||||
api.On("GetUserByUsername", testbot.Username).Return(nil, nil)
|
api.On("GetUserByUsername", testbot.Username).Return(nil, nil)
|
||||||
api.On("CreateBot", testbot).Return(&model.Bot{
|
api.On("CreateBot", testbot).Return(&model.Bot{
|
||||||
UserId: expectedBotId,
|
UserId: expectedBotID,
|
||||||
}, nil)
|
}, nil)
|
||||||
api.On("KVSet", plugin.BOT_USER_KEY, []byte(expectedBotId)).Return(nil)
|
api.On("KVSet", plugin.BOT_USER_KEY, []byte(expectedBotID)).Return(nil)
|
||||||
api.On("GetBundlePath").Return("", nil)
|
api.On("GetBundlePath").Return("", nil)
|
||||||
api.On("SetProfileImage", expectedBotId, imageBytes).Return(nil)
|
api.On("SetProfileImage", expectedBotID, imageBytes).Return(nil)
|
||||||
api.On("GetServerVersion").Return("5.10.0")
|
api.On("GetServerVersion").Return("5.10.0")
|
||||||
defer api.AssertExpectations(t)
|
defer api.AssertExpectations(t)
|
||||||
|
|
||||||
p := &plugin.HelpersImpl{}
|
p := &plugin.HelpersImpl{}
|
||||||
p.API = api
|
p.API = api
|
||||||
|
|
||||||
botId, err := p.EnsureBot(testbot, plugin.ProfileImagePath(testImage))
|
botID, err := p.EnsureBot(testbot, plugin.ProfileImagePath(testImage))
|
||||||
assert.Equal(t, expectedBotId, botId)
|
assert.Equal(t, expectedBotID, botID)
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("should create bot and set the bot icon image when specified", func(t *testing.T) {
|
t.Run("should create bot and set the bot icon image when specified", func(t *testing.T) {
|
||||||
expectedBotId := model.NewId()
|
expectedBotID := model.NewId()
|
||||||
api := setupAPI()
|
api := setupAPI()
|
||||||
|
|
||||||
testsDir, _ := fileutils.FindDir("tests")
|
testsDir, _ := fileutils.FindDir("tests")
|
||||||
@@ -294,24 +294,24 @@ func TestEnsureBot(t *testing.T) {
|
|||||||
api.On("KVGet", plugin.BOT_USER_KEY).Return(nil, nil)
|
api.On("KVGet", plugin.BOT_USER_KEY).Return(nil, nil)
|
||||||
api.On("GetUserByUsername", testbot.Username).Return(nil, nil)
|
api.On("GetUserByUsername", testbot.Username).Return(nil, nil)
|
||||||
api.On("CreateBot", testbot).Return(&model.Bot{
|
api.On("CreateBot", testbot).Return(&model.Bot{
|
||||||
UserId: expectedBotId,
|
UserId: expectedBotID,
|
||||||
}, nil)
|
}, nil)
|
||||||
api.On("KVSet", plugin.BOT_USER_KEY, []byte(expectedBotId)).Return(nil)
|
api.On("KVSet", plugin.BOT_USER_KEY, []byte(expectedBotID)).Return(nil)
|
||||||
api.On("GetBundlePath").Return("", nil)
|
api.On("GetBundlePath").Return("", nil)
|
||||||
api.On("SetBotIconImage", expectedBotId, imageBytes).Return(nil)
|
api.On("SetBotIconImage", expectedBotID, imageBytes).Return(nil)
|
||||||
api.On("GetServerVersion").Return("5.10.0")
|
api.On("GetServerVersion").Return("5.10.0")
|
||||||
defer api.AssertExpectations(t)
|
defer api.AssertExpectations(t)
|
||||||
|
|
||||||
p := &plugin.HelpersImpl{}
|
p := &plugin.HelpersImpl{}
|
||||||
p.API = api
|
p.API = api
|
||||||
|
|
||||||
botId, err := p.EnsureBot(testbot, plugin.IconImagePath(testImage))
|
botID, err := p.EnsureBot(testbot, plugin.IconImagePath(testImage))
|
||||||
assert.Equal(t, expectedBotId, botId)
|
assert.Equal(t, expectedBotID, botID)
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("should create bot and set both the profile image and bot icon image when specified", func(t *testing.T) {
|
t.Run("should create bot and set both the profile image and bot icon image when specified", func(t *testing.T) {
|
||||||
expectedBotId := model.NewId()
|
expectedBotID := model.NewId()
|
||||||
api := setupAPI()
|
api := setupAPI()
|
||||||
|
|
||||||
testsDir, _ := fileutils.FindDir("tests")
|
testsDir, _ := fileutils.FindDir("tests")
|
||||||
@@ -322,20 +322,20 @@ func TestEnsureBot(t *testing.T) {
|
|||||||
api.On("KVGet", plugin.BOT_USER_KEY).Return(nil, nil)
|
api.On("KVGet", plugin.BOT_USER_KEY).Return(nil, nil)
|
||||||
api.On("GetUserByUsername", testbot.Username).Return(nil, nil)
|
api.On("GetUserByUsername", testbot.Username).Return(nil, nil)
|
||||||
api.On("CreateBot", testbot).Return(&model.Bot{
|
api.On("CreateBot", testbot).Return(&model.Bot{
|
||||||
UserId: expectedBotId,
|
UserId: expectedBotID,
|
||||||
}, nil)
|
}, nil)
|
||||||
api.On("KVSet", plugin.BOT_USER_KEY, []byte(expectedBotId)).Return(nil)
|
api.On("KVSet", plugin.BOT_USER_KEY, []byte(expectedBotID)).Return(nil)
|
||||||
api.On("GetBundlePath").Return("", nil)
|
api.On("GetBundlePath").Return("", nil)
|
||||||
api.On("SetProfileImage", expectedBotId, imageBytes).Return(nil)
|
api.On("SetProfileImage", expectedBotID, imageBytes).Return(nil)
|
||||||
api.On("SetBotIconImage", expectedBotId, imageBytes).Return(nil)
|
api.On("SetBotIconImage", expectedBotID, imageBytes).Return(nil)
|
||||||
api.On("GetServerVersion").Return("5.10.0")
|
api.On("GetServerVersion").Return("5.10.0")
|
||||||
defer api.AssertExpectations(t)
|
defer api.AssertExpectations(t)
|
||||||
|
|
||||||
p := &plugin.HelpersImpl{}
|
p := &plugin.HelpersImpl{}
|
||||||
p.API = api
|
p.API = api
|
||||||
|
|
||||||
botId, err := p.EnsureBot(testbot, plugin.ProfileImagePath(testImage), plugin.IconImagePath(testImage))
|
botID, err := p.EnsureBot(testbot, plugin.ProfileImagePath(testImage), plugin.IconImagePath(testImage))
|
||||||
assert.Equal(t, expectedBotId, botId)
|
assert.Equal(t, expectedBotID, botID)
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -343,7 +343,7 @@ func TestEnsureBot(t *testing.T) {
|
|||||||
|
|
||||||
func TestShouldProcessMessage(t *testing.T) {
|
func TestShouldProcessMessage(t *testing.T) {
|
||||||
p := &plugin.HelpersImpl{}
|
p := &plugin.HelpersImpl{}
|
||||||
expectedBotId := model.NewId()
|
expectedBotID := model.NewId()
|
||||||
|
|
||||||
setupAPI := func() *plugintest.API {
|
setupAPI := func() *plugintest.API {
|
||||||
return &plugintest.API{}
|
return &plugintest.API{}
|
||||||
@@ -351,9 +351,9 @@ func TestShouldProcessMessage(t *testing.T) {
|
|||||||
|
|
||||||
t.Run("should not respond to itself", func(t *testing.T) {
|
t.Run("should not respond to itself", func(t *testing.T) {
|
||||||
api := setupAPI()
|
api := setupAPI()
|
||||||
api.On("KVGet", plugin.BOT_USER_KEY).Return([]byte(expectedBotId), nil)
|
api.On("KVGet", plugin.BOT_USER_KEY).Return([]byte(expectedBotID), nil)
|
||||||
p.API = api
|
p.API = api
|
||||||
shouldProcessMessage, _ := p.ShouldProcessMessage(&model.Post{Type: model.POST_HEADER_CHANGE, UserId: expectedBotId}, plugin.AllowSystemMessages(), plugin.AllowBots())
|
shouldProcessMessage, _ := p.ShouldProcessMessage(&model.Post{Type: model.POST_HEADER_CHANGE, UserId: expectedBotID}, plugin.AllowSystemMessages(), plugin.AllowBots())
|
||||||
|
|
||||||
assert.False(t, shouldProcessMessage)
|
assert.False(t, shouldProcessMessage)
|
||||||
})
|
})
|
||||||
@@ -369,7 +369,7 @@ func TestShouldProcessMessage(t *testing.T) {
|
|||||||
api := setupAPI()
|
api := setupAPI()
|
||||||
api.On("GetChannel", channelID).Return(&model.Channel{Id: channelID, Type: model.CHANNEL_GROUP}, nil)
|
api.On("GetChannel", channelID).Return(&model.Channel{Id: channelID, Type: model.CHANNEL_GROUP}, nil)
|
||||||
p.API = api
|
p.API = api
|
||||||
api.On("KVGet", plugin.BOT_USER_KEY).Return([]byte(expectedBotId), nil)
|
api.On("KVGet", plugin.BOT_USER_KEY).Return([]byte(expectedBotID), nil)
|
||||||
|
|
||||||
shouldProcessMessage, _ := p.ShouldProcessMessage(&model.Post{ChannelId: channelID}, plugin.AllowSystemMessages(), plugin.AllowBots(), plugin.FilterChannelIDs([]string{"another-channel-id"}))
|
shouldProcessMessage, _ := p.ShouldProcessMessage(&model.Post{ChannelId: channelID}, plugin.AllowSystemMessages(), plugin.AllowBots(), plugin.FilterChannelIDs([]string{"another-channel-id"}))
|
||||||
|
|
||||||
@@ -382,7 +382,7 @@ func TestShouldProcessMessage(t *testing.T) {
|
|||||||
api := setupAPI()
|
api := setupAPI()
|
||||||
p.API = api
|
p.API = api
|
||||||
api.On("GetUser", userID).Return(&model.User{IsBot: true}, nil)
|
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.BOT_USER_KEY).Return([]byte(expectedBotID), nil)
|
||||||
|
|
||||||
shouldProcessMessage, _ := p.ShouldProcessMessage(&model.Post{UserId: userID, ChannelId: channelID},
|
shouldProcessMessage, _ := p.ShouldProcessMessage(&model.Post{UserId: userID, ChannelId: channelID},
|
||||||
plugin.AllowSystemMessages(), plugin.FilterUserIDs([]string{"another-user-id"}))
|
plugin.AllowSystemMessages(), plugin.FilterUserIDs([]string{"another-user-id"}))
|
||||||
@@ -394,12 +394,12 @@ func TestShouldProcessMessage(t *testing.T) {
|
|||||||
userID := "user-id"
|
userID := "user-id"
|
||||||
channelID := "1"
|
channelID := "1"
|
||||||
channel := model.Channel{
|
channel := model.Channel{
|
||||||
Name: "user1__" + expectedBotId,
|
Name: "user1__" + expectedBotID,
|
||||||
Type: model.CHANNEL_OPEN,
|
Type: model.CHANNEL_OPEN,
|
||||||
}
|
}
|
||||||
api := setupAPI()
|
api := setupAPI()
|
||||||
api.On("GetChannel", channelID).Return(&channel, nil)
|
api.On("GetChannel", channelID).Return(&channel, nil)
|
||||||
api.On("KVGet", plugin.BOT_USER_KEY).Return([]byte(expectedBotId), nil)
|
api.On("KVGet", plugin.BOT_USER_KEY).Return([]byte(expectedBotID), nil)
|
||||||
p.API = api
|
p.API = api
|
||||||
|
|
||||||
shouldProcessMessage, _ := p.ShouldProcessMessage(&model.Post{UserId: userID, ChannelId: channelID}, plugin.AllowSystemMessages(), plugin.AllowBots(), plugin.OnlyBotDMs())
|
shouldProcessMessage, _ := p.ShouldProcessMessage(&model.Post{UserId: userID, ChannelId: channelID}, plugin.AllowSystemMessages(), plugin.AllowBots(), plugin.OnlyBotDMs())
|
||||||
@@ -410,7 +410,7 @@ func TestShouldProcessMessage(t *testing.T) {
|
|||||||
t.Run("should process the message", func(t *testing.T) {
|
t.Run("should process the message", func(t *testing.T) {
|
||||||
channelID := "1"
|
channelID := "1"
|
||||||
api := setupAPI()
|
api := setupAPI()
|
||||||
api.On("KVGet", plugin.BOT_USER_KEY).Return([]byte(expectedBotId), nil)
|
api.On("KVGet", plugin.BOT_USER_KEY).Return([]byte(expectedBotID), nil)
|
||||||
p.API = api
|
p.API = api
|
||||||
|
|
||||||
shouldProcessMessage, _ := p.ShouldProcessMessage(&model.Post{UserId: "1", Type: model.POST_HEADER_CHANGE, ChannelId: channelID},
|
shouldProcessMessage, _ := p.ShouldProcessMessage(&model.Post{UserId: "1", Type: model.POST_HEADER_CHANGE, ChannelId: channelID},
|
||||||
@@ -435,11 +435,11 @@ func TestShouldProcessMessage(t *testing.T) {
|
|||||||
channelID := "1"
|
channelID := "1"
|
||||||
api := setupAPI()
|
api := setupAPI()
|
||||||
channel := model.Channel{
|
channel := model.Channel{
|
||||||
Name: "user1__" + expectedBotId,
|
Name: "user1__" + expectedBotID,
|
||||||
Type: model.CHANNEL_DIRECT,
|
Type: model.CHANNEL_DIRECT,
|
||||||
}
|
}
|
||||||
api.On("GetChannel", channelID).Return(&channel, nil)
|
api.On("GetChannel", channelID).Return(&channel, nil)
|
||||||
api.On("KVGet", plugin.BOT_USER_KEY).Return([]byte(expectedBotId), nil)
|
api.On("KVGet", plugin.BOT_USER_KEY).Return([]byte(expectedBotID), nil)
|
||||||
p.API = api
|
p.API = api
|
||||||
|
|
||||||
shouldProcessMessage, _ := p.ShouldProcessMessage(&model.Post{UserId: "1", Type: model.POST_HEADER_CHANGE, ChannelId: channelID},
|
shouldProcessMessage, _ := p.ShouldProcessMessage(&model.Post{UserId: "1", Type: model.POST_HEADER_CHANGE, ChannelId: channelID},
|
||||||
|
|||||||
@@ -83,8 +83,8 @@ func (w *httpResponseWriterRPCClient) WriteHeader(statusCode int) {
|
|||||||
w.client.Call("Plugin.WriteHeader", statusCode, nil)
|
w.client.Call("Plugin.WriteHeader", statusCode, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *httpResponseWriterRPCClient) Close() error {
|
func (w *httpResponseWriterRPCClient) Close() error {
|
||||||
return h.client.Close()
|
return w.client.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
func connectHTTPResponseWriter(conn io.ReadWriteCloser) *httpResponseWriterRPCClient {
|
func connectHTTPResponseWriter(conn io.ReadWriteCloser) *httpResponseWriterRPCClient {
|
||||||
|
|||||||
@@ -84,18 +84,18 @@ func FieldListToEncodedErrors(structPrefix string, fieldList *ast.FieldList, fil
|
|||||||
}
|
}
|
||||||
|
|
||||||
if typeNameBuffer.String() != "error" {
|
if typeNameBuffer.String() != "error" {
|
||||||
nextLetter += 1
|
nextLetter++
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
name := ""
|
name := ""
|
||||||
if len(field.Names) == 0 {
|
if len(field.Names) == 0 {
|
||||||
name = string(nextLetter)
|
name = string(nextLetter)
|
||||||
nextLetter += 1
|
nextLetter++
|
||||||
} else {
|
} else {
|
||||||
for range field.Names {
|
for range field.Names {
|
||||||
name += string(nextLetter)
|
name += string(nextLetter)
|
||||||
nextLetter += 1
|
nextLetter++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,11 +125,11 @@ func FieldListDestruct(structPrefix string, fieldList *ast.FieldList, fileset *t
|
|||||||
}
|
}
|
||||||
if len(field.Names) == 0 {
|
if len(field.Names) == 0 {
|
||||||
result = append(result, structPrefix+string(nextLetter)+suffix)
|
result = append(result, structPrefix+string(nextLetter)+suffix)
|
||||||
nextLetter += 1
|
nextLetter++
|
||||||
} else {
|
} else {
|
||||||
for range field.Names {
|
for range field.Names {
|
||||||
result = append(result, structPrefix+string(nextLetter)+suffix)
|
result = append(result, structPrefix+string(nextLetter)+suffix)
|
||||||
nextLetter += 1
|
nextLetter++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -155,11 +155,11 @@ func FieldListToStructList(fieldList *ast.FieldList, fileset *token.FileSet) str
|
|||||||
}
|
}
|
||||||
if len(field.Names) == 0 {
|
if len(field.Names) == 0 {
|
||||||
result = append(result, string(nextLetter)+" "+typeName)
|
result = append(result, string(nextLetter)+" "+typeName)
|
||||||
nextLetter += 1
|
nextLetter++
|
||||||
} else {
|
} else {
|
||||||
for range field.Names {
|
for range field.Names {
|
||||||
result = append(result, string(nextLetter)+" "+typeName)
|
result = append(result, string(nextLetter)+" "+typeName)
|
||||||
nextLetter += 1
|
nextLetter++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ type HelloUserPlugin struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *HelloUserPlugin) ServeHTTP(context *plugin.Context, w http.ResponseWriter, r *http.Request) {
|
func (p *HelloUserPlugin) ServeHTTP(context *plugin.Context, w http.ResponseWriter, r *http.Request) {
|
||||||
userId := r.Header.Get("Mattermost-User-Id")
|
userID := r.Header.Get("Mattermost-User-Id")
|
||||||
user, err := p.API.GetUser(userId)
|
user, err := p.API.GetUser(userID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
p.API.LogError(err.Error())
|
p.API.LogError(err.Error())
|
||||||
|
|||||||
@@ -41,9 +41,10 @@ func (scheduler *Scheduler) NextScheduleTime(cfg *model.Config, now time.Time, p
|
|||||||
func (scheduler *Scheduler) ScheduleJob(cfg *model.Config, pendingJobs bool, lastSuccessfulJob *model.Job) (*model.Job, *model.AppError) {
|
func (scheduler *Scheduler) ScheduleJob(cfg *model.Config, pendingJobs bool, lastSuccessfulJob *model.Job) (*model.Job, *model.AppError) {
|
||||||
mlog.Debug("Scheduling Job", mlog.String("scheduler", scheduler.Name()))
|
mlog.Debug("Scheduling Job", mlog.String("scheduler", scheduler.Name()))
|
||||||
|
|
||||||
if job, err := scheduler.App.Srv.Jobs.CreateJob(model.JOB_TYPE_PLUGINS, nil); err != nil {
|
job, err := scheduler.App.Srv.Jobs.CreateJob(model.JOB_TYPE_PLUGINS, nil)
|
||||||
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
|
||||||
return job, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return job, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,16 +73,14 @@ func (worker *Worker) DoJob(job *model.Job) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err := worker.app.DeleteAllExpiredPluginKeys()
|
if err := worker.app.DeleteAllExpiredPluginKeys(); err != nil {
|
||||||
if err == nil {
|
|
||||||
mlog.Info("Worker: Job is complete", mlog.String("worker", worker.name), mlog.String("job_id", job.Id))
|
|
||||||
worker.setJobSuccess(job)
|
|
||||||
return
|
|
||||||
} else {
|
|
||||||
mlog.Error("Worker: Failed to delete expired keys", mlog.String("worker", worker.name), mlog.String("job_id", job.Id), mlog.String("error", err.Error()))
|
mlog.Error("Worker: Failed to delete expired keys", mlog.String("worker", worker.name), mlog.String("job_id", job.Id), mlog.String("error", err.Error()))
|
||||||
worker.setJobError(job, err)
|
worker.setJobError(job, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mlog.Info("Worker: Job is complete", mlog.String("worker", worker.name), mlog.String("job_id", job.Id))
|
||||||
|
worker.setJobSuccess(job)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (worker *Worker) setJobSuccess(job *model.Job) {
|
func (worker *Worker) setJobSuccess(job *model.Job) {
|
||||||
|
|||||||
@@ -18,15 +18,15 @@ import (
|
|||||||
|
|
||||||
func TestSupervisor(t *testing.T) {
|
func TestSupervisor(t *testing.T) {
|
||||||
for name, f := range map[string]func(*testing.T){
|
for name, f := range map[string]func(*testing.T){
|
||||||
"Supervisor_InvalidExecutablePath": testSupervisor_InvalidExecutablePath,
|
"Supervisor_InvalidExecutablePath": testSupervisorInvalidExecutablePath,
|
||||||
"Supervisor_NonExistentExecutablePath": testSupervisor_NonExistentExecutablePath,
|
"Supervisor_NonExistentExecutablePath": testSupervisorNonExistentExecutablePath,
|
||||||
"Supervisor_StartTimeout": testSupervisor_StartTimeout,
|
"Supervisor_StartTimeout": testSupervisorStartTimeout,
|
||||||
} {
|
} {
|
||||||
t.Run(name, f)
|
t.Run(name, f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func testSupervisor_InvalidExecutablePath(t *testing.T) {
|
func testSupervisorInvalidExecutablePath(t *testing.T) {
|
||||||
dir, err := ioutil.TempDir("", "")
|
dir, err := ioutil.TempDir("", "")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer os.RemoveAll(dir)
|
defer os.RemoveAll(dir)
|
||||||
@@ -45,7 +45,7 @@ func testSupervisor_InvalidExecutablePath(t *testing.T) {
|
|||||||
assert.Error(t, err)
|
assert.Error(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testSupervisor_NonExistentExecutablePath(t *testing.T) {
|
func testSupervisorNonExistentExecutablePath(t *testing.T) {
|
||||||
dir, err := ioutil.TempDir("", "")
|
dir, err := ioutil.TempDir("", "")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer os.RemoveAll(dir)
|
defer os.RemoveAll(dir)
|
||||||
@@ -65,7 +65,7 @@ func testSupervisor_NonExistentExecutablePath(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If plugin development goes really wrong, let's make sure plugin activation won't block forever.
|
// If plugin development goes really wrong, let's make sure plugin activation won't block forever.
|
||||||
func testSupervisor_StartTimeout(t *testing.T) {
|
func testSupervisorStartTimeout(t *testing.T) {
|
||||||
dir, err := ioutil.TempDir("", "")
|
dir, err := ioutil.TempDir("", "")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer os.RemoveAll(dir)
|
defer os.RemoveAll(dir)
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user