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
Этот коммит содержится в:
Eli Yukelzon
2019-04-01 18:39:45 +03:00
коммит произвёл Christopher Speller
родитель d14235b4e0
Коммит 0e534c8a49
18 изменённых файлов: 972 добавлений и 539 удалений

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

@@ -0,0 +1,49 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
package main
import (
"fmt"
"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) {
uid := "{{.BasicUser.Id}}"
statuses := []string{model.STATUS_ONLINE, model.STATUS_AWAY, model.STATUS_DND, model.STATUS_OFFLINE}
for _, s := range statuses {
status, err := p.API.UpdateUserStatus(uid, s)
if err != nil {
return nil, err.Error()
}
if status == nil {
return nil, "Status was expected, got nil"
}
if s != status.Status {
return nil, fmt.Sprintf("Invalid status returned: %v != %v", s, status.Status)
}
}
status, err := p.API.UpdateUserStatus(uid, "notrealstatus")
if err == nil {
return nil, "Expected to get an error while updating invalid user status"
}
if status != nil {
return nil, "Status was expected to be nil, got: " + status.Status
}
return nil, ""
}
func main() {
plugin.ClientMain(&MyPlugin{})
}