golint fix (#13613)
Этот коммит содержится в:
коммит произвёл
Ben Schumacher
родитель
2186af4d13
Коммит
3865bc501e
@@ -41,4 +41,4 @@ issues:
|
|||||||
- linters:
|
- linters:
|
||||||
# ignore golint error for a lot of packages for now
|
# ignore golint error for a lot of packages for now
|
||||||
- golint
|
- golint
|
||||||
path: "api4|app|cmd|einterface|enterprise|imports|jobs|manualtesting|migrations|mlog|model|testlib|services|store|utils|web|wsapi|plugin/plugintest/api.go|plugin/api.go|plugin/context.go|plugin/client.go|plugin/client_rpc.go|plugin/client_rpc_generated.go|plugin/environment.go|plugin/health_check.go|plugin/hooks.go|plugin/supervisor.go|plugin/valid.go"
|
path: "api4|app|cmd|einterface|enterprise|imports|jobs|migrations|mlog|model|testlib|services|store|utils|web|wsapi|plugin/plugintest/api.go|plugin/api.go|plugin/context.go|plugin/client.go|plugin/client_rpc.go|plugin/client_rpc_generated.go|plugin/environment.go|plugin/health_check.go|plugin/hooks.go|plugin/supervisor.go|plugin/valid.go"
|
||||||
|
|||||||
@@ -466,7 +466,7 @@ func (me *TestHelper) TearDown() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (me *TestHelper) ResetRoleMigration() {
|
func (me *TestHelper) ResetRoleMigration() {
|
||||||
sqlSupplier := mainHelper.GetSqlSupplier()
|
sqlSupplier := mainHelper.GetSQLSupplier()
|
||||||
if _, err := sqlSupplier.GetMaster().Exec("DELETE from Roles"); err != nil {
|
if _, err := sqlSupplier.GetMaster().Exec("DELETE from Roles"); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@@ -479,7 +479,7 @@ func (me *TestHelper) ResetRoleMigration() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (me *TestHelper) ResetEmojisMigration() {
|
func (me *TestHelper) ResetEmojisMigration() {
|
||||||
sqlSupplier := mainHelper.GetSqlSupplier()
|
sqlSupplier := mainHelper.GetSQLSupplier()
|
||||||
if _, err := sqlSupplier.GetMaster().Exec("UPDATE Roles SET Permissions=REPLACE(Permissions, ' create_emojis', '') WHERE builtin=True"); err != nil {
|
if _, err := sqlSupplier.GetMaster().Exec("UPDATE Roles SET Permissions=REPLACE(Permissions, ' create_emojis', '') WHERE builtin=True"); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -675,7 +675,7 @@ func TestPermanentDeleteUser(t *testing.T) {
|
|||||||
var bots1 []*model.Bot
|
var bots1 []*model.Bot
|
||||||
var bots2 []*model.Bot
|
var bots2 []*model.Bot
|
||||||
|
|
||||||
sqlSupplier := mainHelper.GetSqlSupplier()
|
sqlSupplier := mainHelper.GetSQLSupplier()
|
||||||
_, err1 := sqlSupplier.GetMaster().Select(&bots1, "SELECT * FROM Bots")
|
_, err1 := sqlSupplier.GetMaster().Select(&bots1, "SELECT * FROM Bots")
|
||||||
assert.Nil(t, err1)
|
assert.Nil(t, err1)
|
||||||
assert.Equal(t, 1, len(bots1))
|
assert.Equal(t, 1, len(bots1))
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ func (h *testHelper) ConfigPath() string {
|
|||||||
|
|
||||||
// SetConfig replaces the configuration passed to a running command.
|
// SetConfig replaces the configuration passed to a running command.
|
||||||
func (h *testHelper) SetConfig(config *model.Config) {
|
func (h *testHelper) SetConfig(config *model.Config) {
|
||||||
config.SqlSettings = *mainHelper.GetSqlSettings()
|
config.SqlSettings = *mainHelper.GetSQLSettings()
|
||||||
|
|
||||||
// Disable strict password requirements for test
|
// Disable strict password requirements for test
|
||||||
*config.PasswordSettings.MinimumLength = 5
|
*config.PasswordSettings.MinimumLength = 5
|
||||||
|
|||||||
@@ -525,7 +525,7 @@ func TestConfigMigrate(t *testing.T) {
|
|||||||
th := Setup()
|
th := Setup()
|
||||||
defer th.TearDown()
|
defer th.TearDown()
|
||||||
|
|
||||||
sqlSettings := mainHelper.GetSqlSettings()
|
sqlSettings := mainHelper.GetSQLSettings()
|
||||||
sqlDSN := fmt.Sprintf("%s://%s", *sqlSettings.DriverName, *sqlSettings.DataSource)
|
sqlDSN := fmt.Sprintf("%s://%s", *sqlSettings.DriverName, *sqlSettings.DataSource)
|
||||||
fileDSN := "config.json"
|
fileDSN := "config.json"
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ func setupConfigDatabase(t *testing.T, cfg *model.Config, files map[string][]byt
|
|||||||
cfgData, err := config.MarshalConfig(cfg)
|
cfgData, err := config.MarshalConfig(cfg)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
db := sqlx.NewDb(mainHelper.GetSqlSupplier().GetMaster().Db, *mainHelper.GetSqlSettings().DriverName)
|
db := sqlx.NewDb(mainHelper.GetSQLSupplier().GetMaster().Db, *mainHelper.GetSQLSettings().DriverName)
|
||||||
err = config.InitializeConfigurationsTable(db)
|
err = config.InitializeConfigurationsTable(db)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
@@ -64,7 +64,7 @@ func getActualDatabaseConfig(t *testing.T) (string, *model.Config) {
|
|||||||
ID string `db:"Id"`
|
ID string `db:"Id"`
|
||||||
Value []byte `db:"Value"`
|
Value []byte `db:"Value"`
|
||||||
}
|
}
|
||||||
db := sqlx.NewDb(mainHelper.GetSqlSupplier().GetMaster().Db, *mainHelper.GetSqlSettings().DriverName)
|
db := sqlx.NewDb(mainHelper.GetSQLSupplier().GetMaster().Db, *mainHelper.GetSQLSettings().DriverName)
|
||||||
err := db.Get(&actual, "SELECT Id, Value FROM Configurations WHERE Active")
|
err := db.Get(&actual, "SELECT Id, Value FROM Configurations WHERE Active")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
@@ -93,7 +93,7 @@ func assertDatabaseNotEqualsConfig(t *testing.T, expectedCfg *model.Config) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestDatabaseStoreNew(t *testing.T) {
|
func TestDatabaseStoreNew(t *testing.T) {
|
||||||
sqlSettings := mainHelper.GetSqlSettings()
|
sqlSettings := mainHelper.GetSQLSettings()
|
||||||
|
|
||||||
t.Run("no existing configuration - initialization required", func(t *testing.T) {
|
t.Run("no existing configuration - initialization required", func(t *testing.T) {
|
||||||
ds, err := config.NewDatabaseStore(fmt.Sprintf("%s://%s", *sqlSettings.DriverName, *sqlSettings.DataSource))
|
ds, err := config.NewDatabaseStore(fmt.Sprintf("%s://%s", *sqlSettings.DriverName, *sqlSettings.DataSource))
|
||||||
@@ -147,7 +147,7 @@ func TestDatabaseStoreGet(t *testing.T) {
|
|||||||
_, tearDown := setupConfigDatabase(t, testConfig, nil)
|
_, tearDown := setupConfigDatabase(t, testConfig, nil)
|
||||||
defer tearDown()
|
defer tearDown()
|
||||||
|
|
||||||
sqlSettings := mainHelper.GetSqlSettings()
|
sqlSettings := mainHelper.GetSQLSettings()
|
||||||
ds, err := config.NewDatabaseStore(fmt.Sprintf("%s://%s", *sqlSettings.DriverName, *sqlSettings.DataSource))
|
ds, err := config.NewDatabaseStore(fmt.Sprintf("%s://%s", *sqlSettings.DriverName, *sqlSettings.DataSource))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer ds.Close()
|
defer ds.Close()
|
||||||
@@ -173,7 +173,7 @@ func TestDatabaseStoreGetEnivironmentOverrides(t *testing.T) {
|
|||||||
_, tearDown := setupConfigDatabase(t, testConfig, nil)
|
_, tearDown := setupConfigDatabase(t, testConfig, nil)
|
||||||
defer tearDown()
|
defer tearDown()
|
||||||
|
|
||||||
sqlSettings := mainHelper.GetSqlSettings()
|
sqlSettings := mainHelper.GetSQLSettings()
|
||||||
ds, err := config.NewDatabaseStore(fmt.Sprintf("%s://%s", *sqlSettings.DriverName, *sqlSettings.DataSource))
|
ds, err := config.NewDatabaseStore(fmt.Sprintf("%s://%s", *sqlSettings.DriverName, *sqlSettings.DataSource))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer ds.Close()
|
defer ds.Close()
|
||||||
@@ -196,7 +196,7 @@ func TestDatabaseStoreGetEnivironmentOverrides(t *testing.T) {
|
|||||||
_, tearDown := setupConfigDatabase(t, testConfig, nil)
|
_, tearDown := setupConfigDatabase(t, testConfig, nil)
|
||||||
defer tearDown()
|
defer tearDown()
|
||||||
|
|
||||||
sqlSettings := mainHelper.GetSqlSettings()
|
sqlSettings := mainHelper.GetSQLSettings()
|
||||||
ds, err := config.NewDatabaseStore(fmt.Sprintf("%s://%s", *sqlSettings.DriverName, *sqlSettings.DataSource))
|
ds, err := config.NewDatabaseStore(fmt.Sprintf("%s://%s", *sqlSettings.DriverName, *sqlSettings.DataSource))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer ds.Close()
|
defer ds.Close()
|
||||||
@@ -219,7 +219,7 @@ func TestDatabaseStoreGetEnivironmentOverrides(t *testing.T) {
|
|||||||
_, tearDown := setupConfigDatabase(t, testConfig, nil)
|
_, tearDown := setupConfigDatabase(t, testConfig, nil)
|
||||||
defer tearDown()
|
defer tearDown()
|
||||||
|
|
||||||
sqlSettings := mainHelper.GetSqlSettings()
|
sqlSettings := mainHelper.GetSQLSettings()
|
||||||
ds, err := config.NewDatabaseStore(fmt.Sprintf("%s://%s", *sqlSettings.DriverName, *sqlSettings.DataSource))
|
ds, err := config.NewDatabaseStore(fmt.Sprintf("%s://%s", *sqlSettings.DriverName, *sqlSettings.DataSource))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer ds.Close()
|
defer ds.Close()
|
||||||
@@ -242,7 +242,7 @@ func TestDatabaseStoreGetEnivironmentOverrides(t *testing.T) {
|
|||||||
_, tearDown := setupConfigDatabase(t, testConfig, nil)
|
_, tearDown := setupConfigDatabase(t, testConfig, nil)
|
||||||
defer tearDown()
|
defer tearDown()
|
||||||
|
|
||||||
sqlSettings := mainHelper.GetSqlSettings()
|
sqlSettings := mainHelper.GetSQLSettings()
|
||||||
ds, err := config.NewDatabaseStore(fmt.Sprintf("%s://%s", *sqlSettings.DriverName, *sqlSettings.DataSource))
|
ds, err := config.NewDatabaseStore(fmt.Sprintf("%s://%s", *sqlSettings.DriverName, *sqlSettings.DataSource))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer ds.Close()
|
defer ds.Close()
|
||||||
@@ -265,7 +265,7 @@ func TestDatabaseStoreGetEnivironmentOverrides(t *testing.T) {
|
|||||||
_, tearDown := setupConfigDatabase(t, testConfig, nil)
|
_, tearDown := setupConfigDatabase(t, testConfig, nil)
|
||||||
defer tearDown()
|
defer tearDown()
|
||||||
|
|
||||||
sqlSettings := mainHelper.GetSqlSettings()
|
sqlSettings := mainHelper.GetSQLSettings()
|
||||||
ds, err := config.NewDatabaseStore(fmt.Sprintf("%s://%s", *sqlSettings.DriverName, *sqlSettings.DataSource))
|
ds, err := config.NewDatabaseStore(fmt.Sprintf("%s://%s", *sqlSettings.DriverName, *sqlSettings.DataSource))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer ds.Close()
|
defer ds.Close()
|
||||||
@@ -291,7 +291,7 @@ func TestDatabaseStoreGetEnivironmentOverrides(t *testing.T) {
|
|||||||
_, tearDown := setupConfigDatabase(t, testConfig, nil)
|
_, tearDown := setupConfigDatabase(t, testConfig, nil)
|
||||||
defer tearDown()
|
defer tearDown()
|
||||||
|
|
||||||
sqlSettings := mainHelper.GetSqlSettings()
|
sqlSettings := mainHelper.GetSQLSettings()
|
||||||
ds, err := config.NewDatabaseStore(fmt.Sprintf("%s://%s", *sqlSettings.DriverName, *sqlSettings.DataSource))
|
ds, err := config.NewDatabaseStore(fmt.Sprintf("%s://%s", *sqlSettings.DriverName, *sqlSettings.DataSource))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer ds.Close()
|
defer ds.Close()
|
||||||
@@ -312,7 +312,7 @@ func TestDatabaseStoreGetEnivironmentOverrides(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestDatabaseStoreSet(t *testing.T) {
|
func TestDatabaseStoreSet(t *testing.T) {
|
||||||
sqlSettings := mainHelper.GetSqlSettings()
|
sqlSettings := mainHelper.GetSQLSettings()
|
||||||
|
|
||||||
t.Run("set same pointer value", func(t *testing.T) {
|
t.Run("set same pointer value", func(t *testing.T) {
|
||||||
t.Skip("not yet implemented")
|
t.Skip("not yet implemented")
|
||||||
@@ -458,7 +458,7 @@ func TestDatabaseStoreSet(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer ds.Close()
|
defer ds.Close()
|
||||||
|
|
||||||
db := sqlx.NewDb(mainHelper.GetSqlSupplier().GetMaster().Db, *sqlSettings.DriverName)
|
db := sqlx.NewDb(mainHelper.GetSQLSupplier().GetMaster().Db, *sqlSettings.DriverName)
|
||||||
_, err = db.Exec("DROP TABLE Configurations")
|
_, err = db.Exec("DROP TABLE Configurations")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
@@ -518,7 +518,7 @@ func TestDatabaseStoreSet(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestDatabaseStoreLoad(t *testing.T) {
|
func TestDatabaseStoreLoad(t *testing.T) {
|
||||||
sqlSettings := mainHelper.GetSqlSettings()
|
sqlSettings := mainHelper.GetSQLSettings()
|
||||||
|
|
||||||
t.Run("active configuration no longer exists", func(t *testing.T) {
|
t.Run("active configuration no longer exists", func(t *testing.T) {
|
||||||
_, tearDown := setupConfigDatabase(t, emptyConfig, nil)
|
_, tearDown := setupConfigDatabase(t, emptyConfig, nil)
|
||||||
@@ -703,7 +703,7 @@ func TestDatabaseStoreLoad(t *testing.T) {
|
|||||||
cfgData, err := config.MarshalConfig(invalidConfig)
|
cfgData, err := config.MarshalConfig(invalidConfig)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
db := sqlx.NewDb(mainHelper.GetSqlSupplier().GetMaster().Db, *sqlSettings.DriverName)
|
db := sqlx.NewDb(mainHelper.GetSQLSupplier().GetMaster().Db, *sqlSettings.DriverName)
|
||||||
truncateTables(t)
|
truncateTables(t)
|
||||||
id := model.NewId()
|
id := model.NewId()
|
||||||
_, err = db.NamedExec("INSERT INTO Configurations (Id, Value, CreateAt, Active) VALUES(:Id, :Value, :CreateAt, TRUE)", map[string]interface{}{
|
_, err = db.NamedExec("INSERT INTO Configurations (Id, Value, CreateAt, Active) VALUES(:Id, :Value, :CreateAt, TRUE)", map[string]interface{}{
|
||||||
@@ -954,7 +954,7 @@ func TestDatabaseStoreString(t *testing.T) {
|
|||||||
_, tearDown := setupConfigDatabase(t, emptyConfig, nil)
|
_, tearDown := setupConfigDatabase(t, emptyConfig, nil)
|
||||||
defer tearDown()
|
defer tearDown()
|
||||||
|
|
||||||
sqlSettings := mainHelper.GetSqlSettings()
|
sqlSettings := mainHelper.GetSQLSettings()
|
||||||
ds, err := config.NewDatabaseStore(fmt.Sprintf("%s://%s", *sqlSettings.DriverName, *sqlSettings.DataSource))
|
ds, err := config.NewDatabaseStore(fmt.Sprintf("%s://%s", *sqlSettings.DriverName, *sqlSettings.DataSource))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.NotNil(t, ds)
|
require.NotNil(t, ds)
|
||||||
|
|||||||
@@ -29,8 +29,8 @@ func TestMain(m *testing.M) {
|
|||||||
// truncateTable clears the given table
|
// truncateTable clears the given table
|
||||||
func truncateTable(t *testing.T, table string) {
|
func truncateTable(t *testing.T, table string) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
sqlSetting := mainHelper.GetSqlSettings()
|
sqlSetting := mainHelper.GetSQLSettings()
|
||||||
sqlSupplier := mainHelper.GetSqlSupplier()
|
sqlSupplier := mainHelper.GetSQLSupplier()
|
||||||
|
|
||||||
switch *sqlSetting.DriverName {
|
switch *sqlSetting.DriverName {
|
||||||
case model.DATABASE_DRIVER_MYSQL:
|
case model.DATABASE_DRIVER_MYSQL:
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import (
|
|||||||
|
|
||||||
func TestMigrateDatabaseToFile(t *testing.T) {
|
func TestMigrateDatabaseToFile(t *testing.T) {
|
||||||
helper := testlib.NewMainHelper()
|
helper := testlib.NewMainHelper()
|
||||||
sqlSettings := helper.GetSqlSettings()
|
sqlSettings := helper.GetSQLSettings()
|
||||||
defer storetest.CleanupSqlSettings(sqlSettings)
|
defer storetest.CleanupSqlSettings(sqlSettings)
|
||||||
sqlDSN := fmt.Sprintf("%s://%s", *sqlSettings.DriverName, *sqlSettings.DataSource)
|
sqlDSN := fmt.Sprintf("%s://%s", *sqlSettings.DriverName, *sqlSettings.DataSource)
|
||||||
fileDSN := "config.json"
|
fileDSN := "config.json"
|
||||||
@@ -54,7 +54,7 @@ func TestMigrateDatabaseToFile(t *testing.T) {
|
|||||||
|
|
||||||
func TestMigrateFileToDatabaseWhenFilePathIsNotSpecified(t *testing.T) {
|
func TestMigrateFileToDatabaseWhenFilePathIsNotSpecified(t *testing.T) {
|
||||||
helper := testlib.NewMainHelper()
|
helper := testlib.NewMainHelper()
|
||||||
sqlSettings := helper.GetSqlSettings()
|
sqlSettings := helper.GetSQLSettings()
|
||||||
defer storetest.CleanupSqlSettings(sqlSettings)
|
defer storetest.CleanupSqlSettings(sqlSettings)
|
||||||
sqlDSN := fmt.Sprintf("%s://%s", *sqlSettings.DriverName, *sqlSettings.DataSource)
|
sqlDSN := fmt.Sprintf("%s://%s", *sqlSettings.DriverName, *sqlSettings.DataSource)
|
||||||
fileDSN := "config.json"
|
fileDSN := "config.json"
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestNewStore(t *testing.T) {
|
func TestNewStore(t *testing.T) {
|
||||||
sqlSettings := mainHelper.GetSqlSettings()
|
sqlSettings := mainHelper.GetSQLSettings()
|
||||||
|
|
||||||
tempDir, err := ioutil.TempDir("", "TestNewStore")
|
tempDir, err := ioutil.TempDir("", "TestNewStore")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|||||||
@@ -3,9 +3,10 @@
|
|||||||
|
|
||||||
package imports
|
package imports
|
||||||
|
|
||||||
// This is a placeholder so this package can be imported in Team Edition when it will be otherwise empty
|
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
// This is a placeholder so this package can be imported in Team Edition when it will be otherwise empty.
|
||||||
_ "github.com/mattermost/mattermost-server/v5/migrations"
|
_ "github.com/mattermost/mattermost-server/v5/migrations"
|
||||||
|
|
||||||
|
// This is a placeholder so this package can be imported in Team Edition when it will be otherwise empty.
|
||||||
_ "github.com/mattermost/mattermost-server/v5/plugin/scheduler"
|
_ "github.com/mattermost/mattermost-server/v5/plugin/scheduler"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -19,16 +19,18 @@ import (
|
|||||||
"github.com/mattermost/mattermost-server/v5/web"
|
"github.com/mattermost/mattermost-server/v5/web"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// TestEnvironment is a helper struct used for tests in manualtesting.
|
||||||
type TestEnvironment struct {
|
type TestEnvironment struct {
|
||||||
Params map[string][]string
|
Params map[string][]string
|
||||||
Client *model.Client4
|
Client *model.Client4
|
||||||
CreatedTeamId string
|
CreatedTeamID string
|
||||||
CreatedUserId string
|
CreatedUserID string
|
||||||
Context *web.Context
|
Context *web.Context
|
||||||
Writer http.ResponseWriter
|
Writer http.ResponseWriter
|
||||||
Request *http.Request
|
Request *http.Request
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Init adds manualtest endpoint to the API.
|
||||||
func Init(api4 *api4.API) {
|
func Init(api4 *api4.API) {
|
||||||
api4.BaseRoutes.Root.Handle("/manualtest", api4.ApiHandler(manualTest)).Methods("GET")
|
api4.BaseRoutes.Root.Handle("/manualtest", api4.ApiHandler(manualTest)).Methods("GET")
|
||||||
}
|
}
|
||||||
@@ -73,19 +75,20 @@ func manualTest(c *web.Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
Type: model.TEAM_OPEN,
|
Type: model.TEAM_OPEN,
|
||||||
}
|
}
|
||||||
|
|
||||||
if createdTeam, err := c.App.Srv.Store.Team().Save(team); err != nil {
|
createdTeam, err := c.App.Srv.Store.Team().Save(team)
|
||||||
|
if err != nil {
|
||||||
c.Err = err
|
c.Err = err
|
||||||
return
|
return
|
||||||
} else {
|
|
||||||
channel := &model.Channel{DisplayName: "Town Square", Name: "town-square", Type: model.CHANNEL_OPEN, TeamId: createdTeam.Id}
|
|
||||||
if _, err := c.App.CreateChannel(channel, false); err != nil {
|
|
||||||
c.Err = err
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
teamID = createdTeam.Id
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
channel := &model.Channel{DisplayName: "Town Square", Name: "town-square", Type: model.CHANNEL_OPEN, TeamId: createdTeam.Id}
|
||||||
|
if _, err := c.App.CreateChannel(channel, false); err != nil {
|
||||||
|
c.Err = err
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
teamID = createdTeam.Id
|
||||||
|
|
||||||
// Create user for testing
|
// Create user for testing
|
||||||
user := &model.User{
|
user := &model.User{
|
||||||
Email: "success+" + model.NewId() + "simulator.amazonses.com",
|
Email: "success+" + model.NewId() + "simulator.amazonses.com",
|
||||||
@@ -126,8 +129,8 @@ func manualTest(c *web.Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
env := TestEnvironment{
|
env := TestEnvironment{
|
||||||
Params: params,
|
Params: params,
|
||||||
Client: client,
|
Client: client,
|
||||||
CreatedTeamId: teamID,
|
CreatedTeamID: teamID,
|
||||||
CreatedUserId: userID,
|
CreatedUserID: userID,
|
||||||
Context: c,
|
Context: c,
|
||||||
Writer: w,
|
Writer: w,
|
||||||
Request: r,
|
Request: r,
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import (
|
|||||||
"github.com/mattermost/mattermost-server/v5/model"
|
"github.com/mattermost/mattermost-server/v5/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
const LINK_POST_TEXT = `
|
const linkPostText = `
|
||||||
Some Links:
|
Some Links:
|
||||||
https://spinpunch.atlassian.net/issues/?filter=10101&jql=resolution%20in%20(Fixed%2C%20%22Won't%20Fix%22%2C%20Duplicate%2C%20%22Cannot%20Reproduce%22)%20AND%20Resolution%20%3D%20Fixed%20AND%20updated%20%3E%3D%20-7d%20ORDER%20BY%20updatedDate%20DESC
|
https://spinpunch.atlassian.net/issues/?filter=10101&jql=resolution%20in%20(Fixed%2C%20%22Won't%20Fix%22%2C%20Duplicate%2C%20%22Cannot%20Reproduce%22)%20AND%20Resolution%20%3D%20Fixed%20AND%20updated%20%3E%3D%20-7d%20ORDER%20BY%20updatedDate%20DESC
|
||||||
|
|
||||||
@@ -23,14 +23,14 @@ https://medium.com/@slackhq/11-useful-tips-for-getting-the-most-of-slack-5dfb3d1
|
|||||||
|
|
||||||
func testAutoLink(env TestEnvironment) *model.AppError {
|
func testAutoLink(env TestEnvironment) *model.AppError {
|
||||||
mlog.Info("Manual Auto Link Test")
|
mlog.Info("Manual Auto Link Test")
|
||||||
channelID, err := getChannelID(env.Context.App, model.DEFAULT_CHANNEL, env.CreatedTeamId, env.CreatedUserId)
|
channelID, err := getChannelID(env.Context.App, model.DEFAULT_CHANNEL, env.CreatedTeamID, env.CreatedUserID)
|
||||||
if !err {
|
if !err {
|
||||||
return model.NewAppError("/manualtest", "manaultesting.test_autolink.unable.app_error", nil, "", http.StatusInternalServerError)
|
return model.NewAppError("/manualtest", "manaultesting.test_autolink.unable.app_error", nil, "", http.StatusInternalServerError)
|
||||||
}
|
}
|
||||||
|
|
||||||
post := &model.Post{
|
post := &model.Post{
|
||||||
ChannelId: channelID,
|
ChannelId: channelID,
|
||||||
Message: LINK_POST_TEXT}
|
Message: linkPostText}
|
||||||
_, resp := env.Client.CreatePost(post)
|
_, resp := env.Client.CreatePost(post)
|
||||||
return resp.Error
|
return resp.Error
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -254,7 +254,7 @@ func (me *TestHelper) TearDown() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (me *TestHelper) ResetRoleMigration() {
|
func (me *TestHelper) ResetRoleMigration() {
|
||||||
sqlSupplier := mainHelper.GetSqlSupplier()
|
sqlSupplier := mainHelper.GetSQLSupplier()
|
||||||
if _, err := sqlSupplier.GetMaster().Exec("DELETE from Roles"); err != nil {
|
if _, err := sqlSupplier.GetMaster().Exec("DELETE from Roles"); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// 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.
|
||||||
|
|
||||||
// testlib exposes helper methods for running unit tests against a containerized test store.
|
// Package testlib exposes helper methods for running unit tests against a containerized test store.
|
||||||
package testlib
|
package testlib
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import (
|
|||||||
type MainHelper struct {
|
type MainHelper struct {
|
||||||
Settings *model.SqlSettings
|
Settings *model.SqlSettings
|
||||||
Store store.Store
|
Store store.Store
|
||||||
SqlSupplier *sqlstore.SqlSupplier
|
SQLSupplier *sqlstore.SqlSupplier
|
||||||
ClusterInterface *FakeClusterInterface
|
ClusterInterface *FakeClusterInterface
|
||||||
|
|
||||||
status int
|
status int
|
||||||
@@ -101,9 +101,9 @@ func (h *MainHelper) setupStore() {
|
|||||||
h.Settings = storetest.MakeSqlSettings(driverName)
|
h.Settings = storetest.MakeSqlSettings(driverName)
|
||||||
|
|
||||||
h.ClusterInterface = &FakeClusterInterface{}
|
h.ClusterInterface = &FakeClusterInterface{}
|
||||||
h.SqlSupplier = sqlstore.NewSqlSupplier(*h.Settings, nil)
|
h.SQLSupplier = sqlstore.NewSqlSupplier(*h.Settings, nil)
|
||||||
h.Store = &TestStore{
|
h.Store = &TestStore{
|
||||||
h.SqlSupplier,
|
h.SQLSupplier,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,7 +132,7 @@ func (h *MainHelper) Close() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *MainHelper) GetSqlSettings() *model.SqlSettings {
|
func (h *MainHelper) GetSQLSettings() *model.SqlSettings {
|
||||||
if h.Settings == nil {
|
if h.Settings == nil {
|
||||||
panic("MainHelper not initialized with database access.")
|
panic("MainHelper not initialized with database access.")
|
||||||
}
|
}
|
||||||
@@ -148,12 +148,12 @@ func (h *MainHelper) GetStore() store.Store {
|
|||||||
return h.Store
|
return h.Store
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *MainHelper) GetSqlSupplier() *sqlstore.SqlSupplier {
|
func (h *MainHelper) GetSQLSupplier() *sqlstore.SqlSupplier {
|
||||||
if h.SqlSupplier == nil {
|
if h.SQLSupplier == nil {
|
||||||
panic("MainHelper not initialized with sql supplier.")
|
panic("MainHelper not initialized with sql supplier.")
|
||||||
}
|
}
|
||||||
|
|
||||||
return h.SqlSupplier
|
return h.SQLSupplier
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *MainHelper) GetClusterInterface() *FakeClusterInterface {
|
func (h *MainHelper) GetClusterInterface() *FakeClusterInterface {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user