[MM-18898] Stringify plugin.Log* parameters (#12700)
- Add stringutils with method that "stringify" object slices - "stringify" means convert each object to its string representation - Move plugin.Log* implementations to client_rpc, use stringify method before calling server method - Exclude Log* methods from generated RPC methods - No signature change for plugin.Log* API - Add test in plugin_api_test to use plugin.Log* methods with RPC
Этот коммит содержится в:
коммит произвёл
Ben Schumacher
родитель
5dbccd0f07
Коммит
7cc1f19453
@@ -1440,6 +1440,17 @@ func TestPluginAPIGetUnsanitizedConfig(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestPluginCallLogAPI(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
pluginID := "com.mattermost.sample"
|
||||
path, _ := fileutils.FindDir("mattermost-server/app/plugin_api_test")
|
||||
pluginCode, err := ioutil.ReadFile(filepath.Join(path, "plugin_using_log_api.go"))
|
||||
assert.NoError(t, err)
|
||||
setupPluginApiTest(t, string(pluginCode),
|
||||
`{"id": "com.mattermost.sample", "server": {"executable": "backend.exe"}, "settings_schema": {"settings": []}}`, pluginID, th.App)
|
||||
}
|
||||
|
||||
func TestPluginAddUserToChannel(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
29
app/plugin_api_test/plugin_using_log_api.go
Обычный файл
29
app/plugin_api_test/plugin_using_log_api.go
Обычный файл
@@ -0,0 +1,29 @@
|
||||
// Copyright (c) 2019-present Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/mattermost/mattermost-server/plugin"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type PluginUsingLogAPI struct {
|
||||
plugin.MattermostPlugin
|
||||
}
|
||||
|
||||
type Foo struct {
|
||||
bar float64
|
||||
}
|
||||
|
||||
func main() {
|
||||
plugin.ClientMain(&PluginUsingLogAPI{})
|
||||
}
|
||||
|
||||
func (p *PluginUsingLogAPI) OnActivate() error {
|
||||
p.API.LogDebug("LogDebug", "one", 1, "two", "two", "foo", Foo{bar: 3.1416})
|
||||
p.API.LogInfo("LogInfo", "one", 1, "two", "two", "foo", Foo{bar: 3.1416})
|
||||
p.API.LogWarn("LogWarn", "one", 1, "two", "two", "foo", Foo{bar: 3.1416})
|
||||
p.API.LogError("LogError", "error", errors.WithStack(errors.New("boom!")))
|
||||
return nil
|
||||
}
|
||||
Ссылка в новой задаче
Block a user