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
Этот коммит содержится в:
Jesse Hallam
2019-11-06 14:46:51 -05:00
коммит произвёл GitHub
родитель 14b1777959
Коммит 6a906e91ad
3 изменённых файлов: 27 добавлений и 8 удалений

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

@@ -27,6 +27,8 @@ const (
actionSymlink
)
const root = "___mattermost-server"
type testResourceDetails struct {
src string
dest string
@@ -50,6 +52,15 @@ func findFile(path string) string {
}
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 {
return fileInfo.IsDir()
})
@@ -65,7 +76,7 @@ func getTestResourcesToSetup() []testResourceDetails {
var found bool
var testResourcesToSetup = []testResourceDetails{
{"mattermost-server", "mattermost-server", resourceTypeFolder, actionSymlink},
{root, "mattermost-server", resourceTypeFolder, actionSymlink},
{"i18n", "i18n", resourceTypeFolder, actionSymlink},
{"templates", "templates", resourceTypeFolder, actionSymlink},
{"tests", "tests", resourceTypeFolder, actionSymlink},