Files
mattermost/tests/plugin_tests/test_get_bundle_path_plugin/main.go
T
Eli Yukelzon 0e534c8a49 MM-14559 Rewrite existing plugin API tests to exclusively test via actual plugin (#10494)
* initial work on rewriting test cases using the raw literal format

* split out the embedded tests into separate file and implement the test using a generic tester function

* initial work on rewriting test cases using the raw literal format

* split out the embedded tests into separate file and implement the test using a generic tester function

* moved tests to separate dir to avoid conflicts

* removed duplicate files

* added license header

* fixed plugin paths

* moved all trivial tests to separate files
created "meta-test" that scans a folder of api tests and runs them

* remove rpc tests from make

* use fileutil.FindDir instead of pwd
clean up the test files
2019-04-01 08:39:45 -07:00

32 lines
879 B
Go

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
package main
import (
"fmt"
"path/filepath"
"github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/plugin"
)
type MyPlugin struct {
plugin.MattermostPlugin
}
func (p *MyPlugin) MessageWillBePosted(c *plugin.Context, post *model.Post) (*model.Post, string) {
bundlePath, err := p.API.GetBundlePath()
if err != nil {
return nil, err.Error() + "failed get bundle path"
} else if bundlePathFromConfig, _ := filepath.Abs(filepath.Join(*p.API.GetConfig().PluginSettings.Directory, "test_get_bundle_path_plugin")); bundlePathFromConfig != bundlePath {
return nil, fmt.Sprintf("Invalid bundle path returned: %v vs %v", bundlePathFromConfig, bundlePath)
}
return nil, ""
}
func main() {
plugin.ClientMain(&MyPlugin{})
}