Centralize the GetPackagePath (#27004)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
e96db725ea
Коммит
cd51dec6e5
@@ -13,7 +13,6 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -27,7 +26,7 @@ import (
|
|||||||
"github.com/mattermost/mattermost/server/public/model"
|
"github.com/mattermost/mattermost/server/public/model"
|
||||||
"github.com/mattermost/mattermost/server/public/plugin"
|
"github.com/mattermost/mattermost/server/public/plugin"
|
||||||
"github.com/mattermost/mattermost/server/public/plugin/utils"
|
"github.com/mattermost/mattermost/server/public/plugin/utils"
|
||||||
"github.com/mattermost/mattermost/server/v8/channels/app/plugin_api_tests"
|
"github.com/mattermost/mattermost/server/v8"
|
||||||
"github.com/mattermost/mattermost/server/v8/channels/testlib"
|
"github.com/mattermost/mattermost/server/v8/channels/testlib"
|
||||||
"github.com/mattermost/mattermost/server/v8/channels/utils/fileutils"
|
"github.com/mattermost/mattermost/server/v8/channels/utils/fileutils"
|
||||||
)
|
)
|
||||||
@@ -1991,7 +1990,7 @@ func TestPluginWebSocketSession(t *testing.T) {
|
|||||||
pluginID := "com.mattermost.websocket_session_test"
|
pluginID := "com.mattermost.websocket_session_test"
|
||||||
|
|
||||||
// Compile plugin
|
// Compile plugin
|
||||||
fullPath := path.Join(plugin_api_tests.GetPackagePath(), "manual.test_websocket_session", "main.go")
|
fullPath := filepath.Join(server.GetPackagePath(), "channels", "app", "plugin_api_tests", "manual.test_websocket_session", "main.go")
|
||||||
pluginCode, err := os.ReadFile(fullPath)
|
pluginCode, err := os.ReadFile(fullPath)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.NotEmpty(t, pluginCode)
|
require.NotEmpty(t, pluginCode)
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
@@ -32,9 +31,8 @@ import (
|
|||||||
"github.com/mattermost/mattermost/server/public/plugin/utils"
|
"github.com/mattermost/mattermost/server/public/plugin/utils"
|
||||||
"github.com/mattermost/mattermost/server/public/shared/i18n"
|
"github.com/mattermost/mattermost/server/public/shared/i18n"
|
||||||
"github.com/mattermost/mattermost/server/public/shared/request"
|
"github.com/mattermost/mattermost/server/public/shared/request"
|
||||||
"github.com/mattermost/mattermost/server/v8/channels/app/plugin_api_tests"
|
"github.com/mattermost/mattermost/server/v8"
|
||||||
"github.com/mattermost/mattermost/server/v8/einterfaces/mocks"
|
"github.com/mattermost/mattermost/server/v8/einterfaces/mocks"
|
||||||
"github.com/mattermost/mattermost/server/v8/tests"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func getDefaultPluginSettingsSchema() string {
|
func getDefaultPluginSettingsSchema() string {
|
||||||
@@ -858,7 +856,7 @@ func TestPluginAPILoadPluginConfiguration(t *testing.T) {
|
|||||||
cfg.PluginSettings.Plugins["testloadpluginconfig"] = pluginJson
|
cfg.PluginSettings.Plugins["testloadpluginconfig"] = pluginJson
|
||||||
})
|
})
|
||||||
|
|
||||||
fullPath := path.Join(plugin_api_tests.GetPackagePath(), "manual.test_load_configuration_plugin", "main.go")
|
fullPath := filepath.Join(server.GetPackagePath(), "channels", "app", "plugin_api_tests", "manual.test_load_configuration_plugin", "main.go")
|
||||||
|
|
||||||
err = pluginAPIHookTest(t, th, fullPath, "testloadpluginconfig", `{"id": "testloadpluginconfig", "server": {"executable": "backend.exe"}, "settings_schema": {
|
err = pluginAPIHookTest(t, th, fullPath, "testloadpluginconfig", `{"id": "testloadpluginconfig", "server": {"executable": "backend.exe"}, "settings_schema": {
|
||||||
"settings": [
|
"settings": [
|
||||||
@@ -891,7 +889,7 @@ func TestPluginAPILoadPluginConfigurationDefaults(t *testing.T) {
|
|||||||
cfg.PluginSettings.Plugins["testloadpluginconfig"] = pluginJson
|
cfg.PluginSettings.Plugins["testloadpluginconfig"] = pluginJson
|
||||||
})
|
})
|
||||||
|
|
||||||
fullPath := path.Join(plugin_api_tests.GetPackagePath(), "manual.test_load_configuration_defaults_plugin", "main.go")
|
fullPath := filepath.Join(server.GetPackagePath(), "channels", "app", "plugin_api_tests", "manual.test_load_configuration_defaults_plugin", "main.go")
|
||||||
|
|
||||||
err = pluginAPIHookTest(t, th, fullPath, "testloadpluginconfig", `{
|
err = pluginAPIHookTest(t, th, fullPath, "testloadpluginconfig", `{
|
||||||
"settings": [
|
"settings": [
|
||||||
@@ -979,7 +977,7 @@ func TestPluginAPIInstallPlugin(t *testing.T) {
|
|||||||
defer th.TearDown()
|
defer th.TearDown()
|
||||||
api := th.SetupPluginAPI()
|
api := th.SetupPluginAPI()
|
||||||
|
|
||||||
tarData, err := os.ReadFile(filepath.Join(tests.GetPackagePath(), "testplugin.tar.gz"))
|
tarData, err := os.ReadFile(filepath.Join(server.GetPackagePath(), "tests", "testplugin.tar.gz"))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
_, appErr := api.InstallPlugin(bytes.NewReader(tarData), true)
|
_, appErr := api.InstallPlugin(bytes.NewReader(tarData), true)
|
||||||
@@ -1055,7 +1053,7 @@ func TestInstallPlugin(t *testing.T) {
|
|||||||
defer th.TearDown()
|
defer th.TearDown()
|
||||||
|
|
||||||
// start an http server to serve plugin's tarball to the test.
|
// start an http server to serve plugin's tarball to the test.
|
||||||
ts := httptest.NewServer(http.FileServer(http.Dir(tests.GetPackagePath())))
|
ts := httptest.NewServer(http.FileServer(http.Dir(filepath.Join(server.GetPackagePath(), "tests"))))
|
||||||
defer ts.Close()
|
defer ts.Close()
|
||||||
|
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||||
@@ -1253,14 +1251,14 @@ func pluginAPIHookTest(t *testing.T, th *TestHelper, fileName string, id string,
|
|||||||
|
|
||||||
func TestBasicAPIPlugins(t *testing.T) {
|
func TestBasicAPIPlugins(t *testing.T) {
|
||||||
defaultSchema := getDefaultPluginSettingsSchema()
|
defaultSchema := getDefaultPluginSettingsSchema()
|
||||||
testFolder := plugin_api_tests.GetPackagePath()
|
testFolder := filepath.Join(server.GetPackagePath(), "channels", "app", "plugin_api_tests")
|
||||||
dirs, err := os.ReadDir(testFolder)
|
dirs, err := os.ReadDir(testFolder)
|
||||||
require.NoError(t, err, "Cannot read test folder %v", testFolder)
|
require.NoError(t, err, "Cannot read test folder %v", testFolder)
|
||||||
for _, dir := range dirs {
|
for _, dir := range dirs {
|
||||||
d := dir.Name()
|
d := dir.Name()
|
||||||
if dir.IsDir() && !strings.HasPrefix(d, "manual.") {
|
if dir.IsDir() && !strings.HasPrefix(d, "manual.") {
|
||||||
t.Run(d, func(t *testing.T) {
|
t.Run(d, func(t *testing.T) {
|
||||||
mainPath := path.Join(testFolder, d, "main.go")
|
mainPath := filepath.Join(testFolder, d, "main.go")
|
||||||
_, err := os.Stat(mainPath)
|
_, err := os.Stat(mainPath)
|
||||||
require.NoError(t, err, "Cannot find plugin main file at %v", mainPath)
|
require.NoError(t, err, "Cannot find plugin main file at %v", mainPath)
|
||||||
th := Setup(t).InitBasic().DeleteBots()
|
th := Setup(t).InitBasic().DeleteBots()
|
||||||
@@ -1838,7 +1836,7 @@ func TestPluginHTTPConnHijack(t *testing.T) {
|
|||||||
th := Setup(t)
|
th := Setup(t)
|
||||||
defer th.TearDown()
|
defer th.TearDown()
|
||||||
|
|
||||||
fullPath := path.Join(plugin_api_tests.GetPackagePath(), "manual.test_http_hijack_plugin", "main.go")
|
fullPath := filepath.Join(server.GetPackagePath(), "channels", "app", "plugin_api_tests", "manual.test_http_hijack_plugin", "main.go")
|
||||||
|
|
||||||
pluginCode, err := os.ReadFile(fullPath)
|
pluginCode, err := os.ReadFile(fullPath)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -1871,7 +1869,7 @@ func TestPluginHTTPUpgradeWebSocket(t *testing.T) {
|
|||||||
th := Setup(t)
|
th := Setup(t)
|
||||||
defer th.TearDown()
|
defer th.TearDown()
|
||||||
|
|
||||||
fullPath := path.Join(plugin_api_tests.GetPackagePath(), "manual.test_http_upgrade_websocket_plugin", "main.go")
|
fullPath := filepath.Join(server.GetPackagePath(), "channels", "app", "plugin_api_tests", "manual.test_http_upgrade_websocket_plugin", "main.go")
|
||||||
|
|
||||||
pluginCode, err := os.ReadFile(fullPath)
|
pluginCode, err := os.ReadFile(fullPath)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -2418,7 +2416,7 @@ func TestPluginServeMetrics(t *testing.T) {
|
|||||||
cfg.MetricsSettings.ListenAddress = prevAddress
|
cfg.MetricsSettings.ListenAddress = prevAddress
|
||||||
})
|
})
|
||||||
|
|
||||||
fullPath := path.Join(plugin_api_tests.GetPackagePath(), "manual.test_serve_metrics_plugin", "main.go")
|
fullPath := filepath.Join(server.GetPackagePath(), "channels", "app", "plugin_api_tests", "manual.test_serve_metrics_plugin", "main.go")
|
||||||
|
|
||||||
pluginCode, err := os.ReadFile(fullPath)
|
pluginCode, err := os.ReadFile(fullPath)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
||||||
// See LICENSE.txt for license information.
|
|
||||||
|
|
||||||
package plugin_api_tests
|
|
||||||
|
|
||||||
import (
|
|
||||||
"path/filepath"
|
|
||||||
"runtime"
|
|
||||||
)
|
|
||||||
|
|
||||||
// GetPackagePath returns the filepath to this package for use in tests that need to read data here.
|
|
||||||
func GetPackagePath() string {
|
|
||||||
// Find the path to this file
|
|
||||||
_, filename, _, _ := runtime.Caller(0)
|
|
||||||
|
|
||||||
// Return the containing directory
|
|
||||||
return filepath.Dir(filename)
|
|
||||||
}
|
|
||||||
@@ -15,11 +15,11 @@ import (
|
|||||||
|
|
||||||
"github.com/mattermost/mattermost/server/public/model"
|
"github.com/mattermost/mattermost/server/public/model"
|
||||||
"github.com/mattermost/mattermost/server/public/shared/mlog"
|
"github.com/mattermost/mattermost/server/public/shared/mlog"
|
||||||
|
"github.com/mattermost/mattermost/server/v8"
|
||||||
"github.com/mattermost/mattermost/server/v8/channels/store"
|
"github.com/mattermost/mattermost/server/v8/channels/store"
|
||||||
"github.com/mattermost/mattermost/server/v8/channels/store/searchlayer"
|
"github.com/mattermost/mattermost/server/v8/channels/store/searchlayer"
|
||||||
"github.com/mattermost/mattermost/server/v8/channels/store/sqlstore"
|
"github.com/mattermost/mattermost/server/v8/channels/store/sqlstore"
|
||||||
"github.com/mattermost/mattermost/server/v8/channels/store/storetest"
|
"github.com/mattermost/mattermost/server/v8/channels/store/storetest"
|
||||||
"github.com/mattermost/mattermost/server/v8/channels/testlib/testdata"
|
|
||||||
"github.com/mattermost/mattermost/server/v8/channels/utils"
|
"github.com/mattermost/mattermost/server/v8/channels/utils"
|
||||||
"github.com/mattermost/mattermost/server/v8/platform/services/searchengine"
|
"github.com/mattermost/mattermost/server/v8/platform/services/searchengine"
|
||||||
)
|
)
|
||||||
@@ -198,13 +198,13 @@ func (h *MainHelper) PreloadMigrations() {
|
|||||||
|
|
||||||
switch *h.Settings.DriverName {
|
switch *h.Settings.DriverName {
|
||||||
case model.DatabaseDriverPostgres:
|
case model.DatabaseDriverPostgres:
|
||||||
finalPath := filepath.Join(testdata.GetPackagePath(), "postgres_migration_warmup.sql")
|
finalPath := filepath.Join(server.GetPackagePath(), "channels", "testlib", "testdata", "postgres_migration_warmup.sql")
|
||||||
buf, err = os.ReadFile(finalPath)
|
buf, err = os.ReadFile(finalPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(fmt.Errorf("cannot read file: %v", err))
|
panic(fmt.Errorf("cannot read file: %v", err))
|
||||||
}
|
}
|
||||||
case model.DatabaseDriverMysql:
|
case model.DatabaseDriverMysql:
|
||||||
finalPath := filepath.Join(testdata.GetPackagePath(), "mysql_migration_warmup.sql")
|
finalPath := filepath.Join(server.GetPackagePath(), "channels", "testlib", "testdata", "mysql_migration_warmup.sql")
|
||||||
buf, err = os.ReadFile(finalPath)
|
buf, err = os.ReadFile(finalPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(fmt.Errorf("cannot read file: %v", err))
|
panic(fmt.Errorf("cannot read file: %v", err))
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import (
|
|||||||
|
|
||||||
"github.com/mattermost/mattermost/server/public/model"
|
"github.com/mattermost/mattermost/server/public/model"
|
||||||
"github.com/mattermost/mattermost/server/public/utils"
|
"github.com/mattermost/mattermost/server/public/utils"
|
||||||
"github.com/mattermost/mattermost/server/v8/channels/testlib/testdata"
|
"github.com/mattermost/mattermost/server/v8"
|
||||||
"github.com/mattermost/mattermost/server/v8/channels/utils/fileutils"
|
"github.com/mattermost/mattermost/server/v8/channels/utils/fileutils"
|
||||||
"github.com/mattermost/mattermost/server/v8/platform/shared/filestore"
|
"github.com/mattermost/mattermost/server/v8/platform/shared/filestore"
|
||||||
)
|
)
|
||||||
@@ -41,7 +41,7 @@ type testResourceDetails struct {
|
|||||||
func findFile(path string) string {
|
func findFile(path string) string {
|
||||||
// Use the testdata path to search from the root of the monorepo.
|
// Use the testdata path to search from the root of the monorepo.
|
||||||
searchPaths := fileutils.CommonBaseSearchPaths()
|
searchPaths := fileutils.CommonBaseSearchPaths()
|
||||||
searchPaths = append(searchPaths, filepath.Join(testdata.GetPackagePath(), "../../../"))
|
searchPaths = append(searchPaths, filepath.Join(server.GetPackagePath(), "channels", "testlib", "testdata", "../../../"))
|
||||||
|
|
||||||
return fileutils.FindPath(path, searchPaths, func(fileInfo os.FileInfo) bool {
|
return fileutils.FindPath(path, searchPaths, func(fileInfo os.FileInfo) bool {
|
||||||
return !fileInfo.IsDir()
|
return !fileInfo.IsDir()
|
||||||
@@ -60,7 +60,7 @@ func findDir(dir string) (string, bool) {
|
|||||||
|
|
||||||
// Use the testdata path to search from the root of the monorepo.
|
// Use the testdata path to search from the root of the monorepo.
|
||||||
searchPaths := fileutils.CommonBaseSearchPaths()
|
searchPaths := fileutils.CommonBaseSearchPaths()
|
||||||
searchPaths = append(searchPaths, filepath.Join(testdata.GetPackagePath(), "../../../"))
|
searchPaths = append(searchPaths, filepath.Join(server.GetPackagePath(), "channels", "testlib", "testdata", "../../../"))
|
||||||
|
|
||||||
found := fileutils.FindPath(dir, searchPaths, func(fileInfo os.FileInfo) bool {
|
found := fileutils.FindPath(dir, searchPaths, func(fileInfo os.FileInfo) bool {
|
||||||
return fileInfo.IsDir()
|
return fileInfo.IsDir()
|
||||||
|
|||||||
18
server/channels/testlib/testdata/path.go
поставляемый
18
server/channels/testlib/testdata/path.go
поставляемый
@@ -1,18 +0,0 @@
|
|||||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
||||||
// See LICENSE.txt for license information.
|
|
||||||
|
|
||||||
package testdata
|
|
||||||
|
|
||||||
import (
|
|
||||||
"path/filepath"
|
|
||||||
"runtime"
|
|
||||||
)
|
|
||||||
|
|
||||||
// GetPackagePath returns the filepath to this package for in tests that need to read data here.
|
|
||||||
func GetPackagePath() string {
|
|
||||||
// Find the path to this file
|
|
||||||
_, filename, _, _ := runtime.Caller(0)
|
|
||||||
|
|
||||||
// Return the containing directory
|
|
||||||
return filepath.Dir(filename)
|
|
||||||
}
|
|
||||||
@@ -6,6 +6,8 @@ package fileutils
|
|||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
|
"github.com/mattermost/mattermost/server/v8"
|
||||||
)
|
)
|
||||||
|
|
||||||
func CommonBaseSearchPaths() []string {
|
func CommonBaseSearchPaths() []string {
|
||||||
@@ -17,6 +19,8 @@ func CommonBaseSearchPaths() []string {
|
|||||||
"../../../..",
|
"../../../..",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// this enables the server to be used in tests from a different repository
|
||||||
|
paths = append(paths, server.GetPackagePath())
|
||||||
return paths
|
return paths
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,9 +9,9 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/mattermost/mattermost/server/v8"
|
||||||
"github.com/mattermost/mattermost/server/v8/cmd/mmctl/client"
|
"github.com/mattermost/mattermost/server/v8/cmd/mmctl/client"
|
||||||
"github.com/mattermost/mattermost/server/v8/cmd/mmctl/printer"
|
"github.com/mattermost/mattermost/server/v8/cmd/mmctl/printer"
|
||||||
"github.com/mattermost/mattermost/server/v8/tests"
|
|
||||||
|
|
||||||
"github.com/mattermost/mattermost/server/public/model"
|
"github.com/mattermost/mattermost/server/public/model"
|
||||||
"github.com/mattermost/mattermost/server/public/utils"
|
"github.com/mattermost/mattermost/server/public/utils"
|
||||||
@@ -21,7 +21,7 @@ import (
|
|||||||
func (s *MmctlE2ETestSuite) TestExportListCmdF() {
|
func (s *MmctlE2ETestSuite) TestExportListCmdF() {
|
||||||
s.SetupTestHelper()
|
s.SetupTestHelper()
|
||||||
importName := "import_test.zip"
|
importName := "import_test.zip"
|
||||||
importFilePath := filepath.Join(tests.GetPackagePath(), importName)
|
importFilePath := filepath.Join(server.GetPackagePath(), "tests", importName)
|
||||||
exportPath, err := filepath.Abs(filepath.Join(*s.th.App.Config().FileSettings.Directory,
|
exportPath, err := filepath.Abs(filepath.Join(*s.th.App.Config().FileSettings.Directory,
|
||||||
*s.th.App.Config().ExportSettings.Directory))
|
*s.th.App.Config().ExportSettings.Directory))
|
||||||
s.Require().Nil(err)
|
s.Require().Nil(err)
|
||||||
@@ -73,7 +73,7 @@ func (s *MmctlE2ETestSuite) TestExportListCmdF() {
|
|||||||
func (s *MmctlE2ETestSuite) TestExportDeleteCmdF() {
|
func (s *MmctlE2ETestSuite) TestExportDeleteCmdF() {
|
||||||
s.SetupTestHelper()
|
s.SetupTestHelper()
|
||||||
importName := "import_test.zip"
|
importName := "import_test.zip"
|
||||||
importFilePath := filepath.Join(tests.GetPackagePath(), importName)
|
importFilePath := filepath.Join(server.GetPackagePath(), "tests", importName)
|
||||||
exportPath, err := filepath.Abs(filepath.Join(*s.th.App.Config().FileSettings.Directory,
|
exportPath, err := filepath.Abs(filepath.Join(*s.th.App.Config().FileSettings.Directory,
|
||||||
*s.th.App.Config().ExportSettings.Directory))
|
*s.th.App.Config().ExportSettings.Directory))
|
||||||
s.Require().Nil(err)
|
s.Require().Nil(err)
|
||||||
@@ -179,7 +179,7 @@ func (s *MmctlE2ETestSuite) TestExportCreateCmdF() {
|
|||||||
func (s *MmctlE2ETestSuite) TestExportDownloadCmdF() {
|
func (s *MmctlE2ETestSuite) TestExportDownloadCmdF() {
|
||||||
s.SetupTestHelper()
|
s.SetupTestHelper()
|
||||||
importName := "import_test.zip"
|
importName := "import_test.zip"
|
||||||
importFilePath := filepath.Join(tests.GetPackagePath(), importName)
|
importFilePath := filepath.Join(server.GetPackagePath(), "tests", importName)
|
||||||
exportPath, err := filepath.Abs(filepath.Join(*s.th.App.Config().FileSettings.Directory,
|
exportPath, err := filepath.Abs(filepath.Join(*s.th.App.Config().FileSettings.Directory,
|
||||||
*s.th.App.Config().ExportSettings.Directory))
|
*s.th.App.Config().ExportSettings.Directory))
|
||||||
s.Require().Nil(err)
|
s.Require().Nil(err)
|
||||||
|
|||||||
@@ -9,9 +9,9 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/mattermost/mattermost/server/v8"
|
||||||
"github.com/mattermost/mattermost/server/v8/cmd/mmctl/client"
|
"github.com/mattermost/mattermost/server/v8/cmd/mmctl/client"
|
||||||
"github.com/mattermost/mattermost/server/v8/cmd/mmctl/printer"
|
"github.com/mattermost/mattermost/server/v8/cmd/mmctl/printer"
|
||||||
"github.com/mattermost/mattermost/server/v8/tests"
|
|
||||||
|
|
||||||
"github.com/mattermost/mattermost/server/public/model"
|
"github.com/mattermost/mattermost/server/public/model"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
@@ -20,7 +20,7 @@ import (
|
|||||||
func (s *MmctlE2ETestSuite) TestExtractRunCmdF() {
|
func (s *MmctlE2ETestSuite) TestExtractRunCmdF() {
|
||||||
s.SetupTestHelper().InitBasic()
|
s.SetupTestHelper().InitBasic()
|
||||||
docName := "sample-doc.pdf"
|
docName := "sample-doc.pdf"
|
||||||
docFilePath := filepath.Join(tests.GetPackagePath(), docName)
|
docFilePath := filepath.Join(server.GetPackagePath(), "tests", docName)
|
||||||
|
|
||||||
s.Run("no permissions", func() {
|
s.Run("no permissions", func() {
|
||||||
printer.Clean()
|
printer.Clean()
|
||||||
|
|||||||
@@ -9,9 +9,9 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/mattermost/mattermost/server/v8"
|
||||||
"github.com/mattermost/mattermost/server/v8/cmd/mmctl/client"
|
"github.com/mattermost/mattermost/server/v8/cmd/mmctl/client"
|
||||||
"github.com/mattermost/mattermost/server/v8/cmd/mmctl/printer"
|
"github.com/mattermost/mattermost/server/v8/cmd/mmctl/printer"
|
||||||
"github.com/mattermost/mattermost/server/v8/tests"
|
|
||||||
|
|
||||||
"github.com/mattermost/mattermost/server/public/model"
|
"github.com/mattermost/mattermost/server/public/model"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
@@ -20,7 +20,7 @@ import (
|
|||||||
func (s *MmctlE2ETestSuite) TestImportUploadCmdF() {
|
func (s *MmctlE2ETestSuite) TestImportUploadCmdF() {
|
||||||
s.SetupTestHelper().InitBasic()
|
s.SetupTestHelper().InitBasic()
|
||||||
importName := "import_test.zip"
|
importName := "import_test.zip"
|
||||||
importFilePath := filepath.Join(tests.GetPackagePath(), importName)
|
importFilePath := filepath.Join(server.GetPackagePath(), "tests", importName)
|
||||||
info, err := os.Stat(importFilePath)
|
info, err := os.Stat(importFilePath)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
@@ -92,7 +92,7 @@ func (s *MmctlE2ETestSuite) TestImportUploadCmdF() {
|
|||||||
func (s *MmctlE2ETestSuite) TestImportProcessCmdF() {
|
func (s *MmctlE2ETestSuite) TestImportProcessCmdF() {
|
||||||
s.SetupTestHelper().InitBasic()
|
s.SetupTestHelper().InitBasic()
|
||||||
importName := "import_test.zip"
|
importName := "import_test.zip"
|
||||||
importFilePath := filepath.Join(tests.GetPackagePath(), "import_test.zip")
|
importFilePath := filepath.Join(server.GetPackagePath(), "tests", "import_test.zip")
|
||||||
|
|
||||||
s.Run("no permissions", func() {
|
s.Run("no permissions", func() {
|
||||||
printer.Clean()
|
printer.Clean()
|
||||||
@@ -131,7 +131,7 @@ func (s *MmctlE2ETestSuite) TestImportProcessCmdF() {
|
|||||||
func (s *MmctlE2ETestSuite) TestImportListAvailableCmdF() {
|
func (s *MmctlE2ETestSuite) TestImportListAvailableCmdF() {
|
||||||
s.SetupTestHelper().InitBasic()
|
s.SetupTestHelper().InitBasic()
|
||||||
importName := "import_test.zip"
|
importName := "import_test.zip"
|
||||||
importFilePath := filepath.Join(tests.GetPackagePath(), importName)
|
importFilePath := filepath.Join(server.GetPackagePath(), "tests", importName)
|
||||||
|
|
||||||
s.Run("no permissions", func() {
|
s.Run("no permissions", func() {
|
||||||
printer.Clean()
|
printer.Clean()
|
||||||
@@ -371,7 +371,7 @@ func (s *MmctlE2ETestSuite) TestImportValidateCmdF() {
|
|||||||
s.SetupTestHelper().InitBasic()
|
s.SetupTestHelper().InitBasic()
|
||||||
|
|
||||||
importName := "import_test.zip"
|
importName := "import_test.zip"
|
||||||
importFilePath := filepath.Join(tests.GetPackagePath(), importName)
|
importFilePath := filepath.Join(server.GetPackagePath(), "tests", importName)
|
||||||
|
|
||||||
s.RunForSystemAdminAndLocal("defaults", func(c client.Client) {
|
s.RunForSystemAdminAndLocal("defaults", func(c client.Client) {
|
||||||
printer.Clean()
|
printer.Clean()
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import (
|
|||||||
|
|
||||||
"github.com/hashicorp/go-multierror"
|
"github.com/hashicorp/go-multierror"
|
||||||
"github.com/mattermost/mattermost/server/public/model"
|
"github.com/mattermost/mattermost/server/public/model"
|
||||||
|
"github.com/mattermost/mattermost/server/v8"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@@ -16,13 +17,12 @@ import (
|
|||||||
|
|
||||||
"github.com/mattermost/mattermost/server/v8/cmd/mmctl/client"
|
"github.com/mattermost/mattermost/server/v8/cmd/mmctl/client"
|
||||||
"github.com/mattermost/mattermost/server/v8/cmd/mmctl/printer"
|
"github.com/mattermost/mattermost/server/v8/cmd/mmctl/printer"
|
||||||
"github.com/mattermost/mattermost/server/v8/tests"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s *MmctlE2ETestSuite) TestPluginAddCmd() {
|
func (s *MmctlE2ETestSuite) TestPluginAddCmd() {
|
||||||
s.SetupTestHelper().InitBasic()
|
s.SetupTestHelper().InitBasic()
|
||||||
|
|
||||||
pluginPath := filepath.Join(tests.GetPackagePath(), "testplugin.tar.gz")
|
pluginPath := filepath.Join(server.GetPackagePath(), "tests", "testplugin.tar.gz")
|
||||||
|
|
||||||
s.RunForSystemAdminAndLocal("add an already installed plugin without force", func(c client.Client) {
|
s.RunForSystemAdminAndLocal("add an already installed plugin without force", func(c client.Client) {
|
||||||
printer.Clean()
|
printer.Clean()
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||||
// See LICENSE.txt for license information.
|
// See LICENSE.txt for license information.
|
||||||
|
|
||||||
package tests
|
package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
Ссылка в новой задаче
Block a user