testutils

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2026 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DbName = "test_db"
	DbUser = "test_user"
	DbPass = "test_password"
	// Container config is valid for 30 minutes
	ContainerConfigTTL = 30 * time.Minute
)

Variables

View Source
var TestAssets embed.FS

Functions

func ArrayToPool

func ArrayToPool(array []string)

func GenerateDBAuthor

func GenerateDBAuthor() db.AuthorDB

func GetTestAssets

func GetTestAssets() embed.FS

Types

type ContainerConfig added in v0.0.5

type ContainerConfig struct {
	PostgresHost string `json:"postgres_host"`
	PostgresPort string `json:"postgres_port"`
	MySQLHost    string `json:"mysql_host"`
	MySQLPort    string `json:"mysql_port"`
	Username     string `json:"username"`
	Password     string `json:"password"`
	Database     string `json:"database"`
	CreatedAt    int64  `json:"created_at"`
}

ContainerConfig is serialized to share container info between test packages

type TestContainerConfiguration

type TestContainerConfiguration struct {
	Container *testcontainers.DockerContainer
	Host      string
	Port      string
	Username  string
	Password  string
	Database  string
}

func PrepareMySQLDB

func PrepareMySQLDB() (*TestContainerConfiguration, error)

func PreparePostgresDB

func PreparePostgresDB() (*TestContainerConfiguration, error)

type TestDBHandler

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

func NewTestDBHandler

func NewTestDBHandler(t *testing.T) *TestDBHandler

func (*TestDBHandler) AddTests

func (test *TestDBHandler) AddTests(testConfs ...TestRunConfig)

func (*TestDBHandler) InitMySQL

func (test *TestDBHandler) InitMySQL() *db.MysqlDB

func (*TestDBHandler) InitPostgres

func (test *TestDBHandler) InitPostgres() *db.PostgresDB

func (*TestDBHandler) StartTestDBHandler

func (test *TestDBHandler) StartTestDBHandler()

func (*TestDBHandler) TestRun

func (test *TestDBHandler) TestRun(
	t *testing.T,
	testRun TestRunConfig,
	newDS func() db.DataStore,
	dsName string,
)

type TestDataStore

type TestDataStore struct {
	DS                  db.DataStore
	Logger              *zap.SugaredLogger
	Hooks               *hooks2.Hook
	ReadOnlyManager     *pad.ReadOnlyManager
	SecurityManager     *pad.SecurityManager
	AuthorManager       *author.Manager
	PadManager          *pad.Manager
	PadMessageHandler   *ws.PadMessageHandler
	AdminMessageHandler *ws.AdminMessageHandler
	MockWebSocket       *ws.MockWebSocketConn
	Validator           *validator.Validate
	Hub                 *ws.Hub
	App                 *fiber.App
	PrivateAPI          fiber.Router
	Importer            *io.Importer
}

func (*TestDataStore) ToInitStore

func (t *TestDataStore) ToInitStore() *lib.InitStore

func (*TestDataStore) ToPluginStore added in v0.0.5

func (t *TestDataStore) ToPluginStore() *interfaces.EpPluginStore

type TestRunConfig

type TestRunConfig struct {
	Name string
	Test func(t *testing.T, tsStore TestDataStore)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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