testutil

package
v0.0.0-...-031a617 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2025 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContainerBuilder

type ContainerBuilder struct {
	*dockertest.Pool
	// contains filtered or unexported fields
}

func NewContainerBuilder

func NewContainerBuilder(endpoint string) (*ContainerBuilder, error)

NewContainerBuilder creates a new ContainerBuilder instance. The endpoint parameter specifies the Docker endpoint to connect to. can be empty to use the default.

func (*ContainerBuilder) AddContainer

func (builder *ContainerBuilder) AddContainer(id string, containerInfo ContainerInfo)

func (*ContainerBuilder) AllContainerIDs

func (builder *ContainerBuilder) AllContainerIDs() []string

func (*ContainerBuilder) FindContainer

func (builder *ContainerBuilder) FindContainer(containerName string) (*docker.APIContainers, error)

func (*ContainerBuilder) GetContainerInfo

func (builder *ContainerBuilder) GetContainerInfo(id string) (ContainerInfo, bool)

func (*ContainerBuilder) PruneAll

func (builder *ContainerBuilder) PruneAll() error

func (*ContainerBuilder) RemoveByID

func (builder *ContainerBuilder) RemoveByID(containerID string) error

type ContainerInfo

type ContainerInfo struct {
	Name string
	Type ContainerType
}

type ContainerType

type ContainerType string
const (
	ContainerTypeMongoDB ContainerType = "mongodb"
)
var (
	PostgresContainer ContainerType = "postgres"
)
var (
	RedisContainer ContainerType = "redis"
)

type PostgresContainerOptions

type PostgresContainerOptions struct {
	Name         string
	Host         string
	Port         string
	Username     string
	Password     string
	DatabaseName string
	ImageRepo    string
	ImageTag     string
}

type PostgresContainerResult

type PostgresContainerResult struct {
	Name         string
	Host         string
	Port         string
	Username     string
	Password     string
	DatabaseName string
}

func BuildPostgresContainer

func BuildPostgresContainer(builder *ContainerBuilder, options PostgresContainerOptions) (PostgresContainerResult, error)

type RedisContainerOptions

type RedisContainerOptions struct {
	Name      string
	Host      string
	Port      string
	Password  string
	ImageRepo string
	ImageTag  string
}

type RedisContainerResult

type RedisContainerResult struct {
	Name     string
	Host     string
	Port     string
	Password string
}

func BuildRedisContainer

func BuildRedisContainer(builder *ContainerBuilder, options RedisContainerOptions) (RedisContainerResult, error)

BuildRedisContainer builds and starts a Redis container based on the provided options.

type TestInstance

type TestInstance struct {
	T                   *testing.T
	Config              infra.Config
	SqlxDB              *sqlx.DB
	PgxConn             *pgx.Conn
	ImMemConsumerReader *mq.InMemoryConsumer
	Redis               redis.UniversalClient
	MockProducer        *mq.MockProducer
	ContainerBuilder    *ContainerBuilder
	Ctx                 context.Context
}

func NewTestInstance

func NewTestInstance(t *testing.T) (*TestInstance, error)

func (*TestInstance) ClearRedisData

func (ti *TestInstance) ClearRedisData() error

func (*TestInstance) GetTestInfraProvider

func (ti *TestInstance) GetTestInfraProvider() (fx.Option, error)

func (*TestInstance) PGCopyFromLargeJson

func (ti *TestInstance) PGCopyFromLargeJson() error

func (*TestInstance) ResetAndRunSeedData

func (ti *TestInstance) ResetAndRunSeedData() error

func (*TestInstance) ResetDB

func (ti *TestInstance) ResetDB() error

func (*TestInstance) RunDBMigrations

func (ti *TestInstance) RunDBMigrations() error

func (*TestInstance) TeardownInfra

func (ti *TestInstance) TeardownInfra() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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