enable non-GOPATH testing with different mattermost-server folder name (#12930)
* enable non-GOPATH testing Tweak the testlib package to support finding the root without assuming the folder name of the repository. Fixes: MM-19729 * fix web tests
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
14b1777959
Коммит
6a906e91ad
@@ -27,6 +27,8 @@ const (
|
|||||||
actionSymlink
|
actionSymlink
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const root = "___mattermost-server"
|
||||||
|
|
||||||
type testResourceDetails struct {
|
type testResourceDetails struct {
|
||||||
src string
|
src string
|
||||||
dest string
|
dest string
|
||||||
@@ -50,6 +52,15 @@ func findFile(path string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func findDir(dir string) (string, bool) {
|
func findDir(dir string) (string, bool) {
|
||||||
|
if dir == root {
|
||||||
|
srcPath := findFile("go.mod")
|
||||||
|
if srcPath == "" {
|
||||||
|
return "./", false
|
||||||
|
}
|
||||||
|
|
||||||
|
return path.Dir(srcPath), true
|
||||||
|
}
|
||||||
|
|
||||||
found := fileutils.FindPath(dir, commonBaseSearchPaths, func(fileInfo os.FileInfo) bool {
|
found := fileutils.FindPath(dir, commonBaseSearchPaths, func(fileInfo os.FileInfo) bool {
|
||||||
return fileInfo.IsDir()
|
return fileInfo.IsDir()
|
||||||
})
|
})
|
||||||
@@ -65,7 +76,7 @@ func getTestResourcesToSetup() []testResourceDetails {
|
|||||||
var found bool
|
var found bool
|
||||||
|
|
||||||
var testResourcesToSetup = []testResourceDetails{
|
var testResourcesToSetup = []testResourceDetails{
|
||||||
{"mattermost-server", "mattermost-server", resourceTypeFolder, actionSymlink},
|
{root, "mattermost-server", resourceTypeFolder, actionSymlink},
|
||||||
{"i18n", "i18n", resourceTypeFolder, actionSymlink},
|
{"i18n", "i18n", resourceTypeFolder, actionSymlink},
|
||||||
{"templates", "templates", resourceTypeFolder, actionSymlink},
|
{"templates", "templates", resourceTypeFolder, actionSymlink},
|
||||||
{"tests", "tests", resourceTypeFolder, actionSymlink},
|
{"tests", "tests", resourceTypeFolder, actionSymlink},
|
||||||
|
|||||||
15
testlib/resources_test.go
Обычный файл
15
testlib/resources_test.go
Обычный файл
@@ -0,0 +1,15 @@
|
|||||||
|
package testlib
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestFindDir(t *testing.T) {
|
||||||
|
t.Run("find root", func(t *testing.T) {
|
||||||
|
path, found := findDir(root)
|
||||||
|
assert.True(t, found, "failed to find root")
|
||||||
|
assert.NotEmpty(t, path)
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -12,8 +12,6 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/mattermost/mattermost-server/testlib"
|
|
||||||
|
|
||||||
"github.com/mattermost/mattermost-server/app"
|
"github.com/mattermost/mattermost-server/app"
|
||||||
"github.com/mattermost/mattermost-server/config"
|
"github.com/mattermost/mattermost-server/config"
|
||||||
"github.com/mattermost/mattermost-server/model"
|
"github.com/mattermost/mattermost-server/model"
|
||||||
@@ -97,11 +95,6 @@ func Setup() *TestHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (th *TestHelper) InitPlugins() *TestHelper {
|
func (th *TestHelper) InitPlugins() *TestHelper {
|
||||||
|
|
||||||
if th.tempWorkspace == "" {
|
|
||||||
th.tempWorkspace, _ = testlib.SetupTestResources()
|
|
||||||
}
|
|
||||||
|
|
||||||
pluginDir := filepath.Join(th.tempWorkspace, "plugins")
|
pluginDir := filepath.Join(th.tempWorkspace, "plugins")
|
||||||
webappDir := filepath.Join(th.tempWorkspace, "webapp")
|
webappDir := filepath.Join(th.tempWorkspace, "webapp")
|
||||||
|
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user