testlib

package
v5.39.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 15, 2021 License: AGPL-3.0, Apache-2.0 Imports: 28 Imported by: 6

Documentation

Overview

Package testlib exposes helper methods for running unit tests against a containerized test store.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertLog added in v5.22.0

func AssertLog(t *testing.T, logs *bytes.Buffer, level, message string)

AssertLog asserts that a JSON-encoded buffer of logs contains one with the given level and message.

func AssertNoLog added in v5.23.0

func AssertNoLog(t *testing.T, logs *bytes.Buffer, level, message string)

AssertNoLog asserts that a JSON-encoded buffer of logs does not contains one with the given level and message.

func CopyFile added in v5.33.0

func CopyFile(src, dst string) error

func GetMockStoreForSetupFunctions added in v5.22.0

func GetMockStoreForSetupFunctions() *mocks.Store

func SetupTestResources

func SetupTestResources() (string, error)

Types

type FakeClusterInterface

type FakeClusterInterface struct {
	// contains filtered or unexported fields
}

func (*FakeClusterInterface) ClearMessages

func (c *FakeClusterInterface) ClearMessages()

func (*FakeClusterInterface) ConfigChanged

func (c *FakeClusterInterface) ConfigChanged(previousConfig *model.Config, newConfig *model.Config, sendToOtherServer bool) *model.AppError

func (*FakeClusterInterface) GetClusterId

func (c *FakeClusterInterface) GetClusterId() string

func (*FakeClusterInterface) GetClusterInfos

func (c *FakeClusterInterface) GetClusterInfos() []*model.ClusterInfo

func (*FakeClusterInterface) GetClusterStats

func (c *FakeClusterInterface) GetClusterStats() ([]*model.ClusterStats, *model.AppError)

func (*FakeClusterInterface) GetLogs

func (c *FakeClusterInterface) GetLogs(page, perPage int) ([]string, *model.AppError)

func (*FakeClusterInterface) GetMessages

func (c *FakeClusterInterface) GetMessages() []*model.ClusterMessage

func (*FakeClusterInterface) GetMyClusterInfo

func (c *FakeClusterInterface) GetMyClusterInfo() *model.ClusterInfo

func (*FakeClusterInterface) GetPluginStatuses

func (c *FakeClusterInterface) GetPluginStatuses() (model.PluginStatuses, *model.AppError)

func (*FakeClusterInterface) HealthScore added in v5.26.0

func (c *FakeClusterInterface) HealthScore() int

func (*FakeClusterInterface) IsLeader

func (c *FakeClusterInterface) IsLeader() bool

func (*FakeClusterInterface) NotifyMsg

func (c *FakeClusterInterface) NotifyMsg(buf []byte)

func (*FakeClusterInterface) RegisterClusterMessageHandler

func (c *FakeClusterInterface) RegisterClusterMessageHandler(event string, crm einterfaces.ClusterMessageHandler)

func (*FakeClusterInterface) SelectMessages added in v5.35.0

func (c *FakeClusterInterface) SelectMessages(filterCond func(message *model.ClusterMessage) bool) []*model.ClusterMessage

func (*FakeClusterInterface) SendClearRoleCacheMessage

func (c *FakeClusterInterface) SendClearRoleCacheMessage()

func (*FakeClusterInterface) SendClusterMessage

func (c *FakeClusterInterface) SendClusterMessage(message *model.ClusterMessage)

func (*FakeClusterInterface) SendClusterMessageToNode added in v5.36.0

func (c *FakeClusterInterface) SendClusterMessageToNode(nodeID string, message *model.ClusterMessage) error

func (*FakeClusterInterface) StartInterNodeCommunication

func (c *FakeClusterInterface) StartInterNodeCommunication()

func (*FakeClusterInterface) StopInterNodeCommunication

func (c *FakeClusterInterface) StopInterNodeCommunication()

type HelperOptions

type HelperOptions struct {
	EnableStore     bool
	EnableResources bool
	WithReadReplica bool
}

type MainHelper

type MainHelper struct {
	Settings         *model.SqlSettings
	Store            store.Store
	SearchEngine     *searchengine.Broker
	SQLStore         *sqlstore.SqlStore
	ClusterInterface *FakeClusterInterface
	// contains filtered or unexported fields
}

func NewMainHelper

func NewMainHelper() *MainHelper

func NewMainHelperWithOptions

func NewMainHelperWithOptions(options *HelperOptions) *MainHelper

func (*MainHelper) Close

func (h *MainHelper) Close() error

func (*MainHelper) GetClusterInterface

func (h *MainHelper) GetClusterInterface() *FakeClusterInterface

func (*MainHelper) GetSQLSettings added in v5.22.0

func (h *MainHelper) GetSQLSettings() *model.SqlSettings

func (*MainHelper) GetSQLStore added in v5.32.0

func (h *MainHelper) GetSQLStore() *sqlstore.SqlStore

func (*MainHelper) GetSearchEngine added in v5.24.0

func (h *MainHelper) GetSearchEngine() *searchengine.Broker

func (*MainHelper) GetStore

func (h *MainHelper) GetStore() store.Store

func (*MainHelper) Main

func (h *MainHelper) Main(m *testing.M)

func (*MainHelper) PreloadMigrations added in v5.30.0

func (h *MainHelper) PreloadMigrations()

PreloadMigrations preloads the migrations and roles into the database so that they are not run again when the migrations happen every time the server is started. This change is forward-compatible with new migrations and only new migrations will get executed. Only if the schema of either roles or systems table changes, this will break. In that case, just update the migrations or comment this out for the time being. In the worst case, only an optimization is lost.

Re-generate the files with: pg_dump -a -h localhost -U mmuser -d <> --no-comments --inserts -t roles -t systems mysqldump -u root -p <> --no-create-info --extended-insert=FALSE Systems Roles And keep only the permission related rows in the systems table output.

func (*MainHelper) SetReplicationLagForTesting added in v5.34.0

func (h *MainHelper) SetReplicationLagForTesting(seconds int) error

func (*MainHelper) ToggleReplicasOff added in v5.34.0

func (h *MainHelper) ToggleReplicasOff()

func (*MainHelper) ToggleReplicasOn added in v5.34.0

func (h *MainHelper) ToggleReplicasOn()

type TestStore

type TestStore struct {
	store.Store
}

func (*TestStore) Close

func (s *TestStore) Close()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL