test

package
v0.0.0-...-9c552bb Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2024 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLocalAuthority

func GetLocalAuthority() (string, error)

GetLocalAuthority returns host:port of local server

func JSONBytesEqual

func JSONBytesEqual(t *testing.T, expected, actual []byte, msgAndArgs ...interface{})

JSONBytesEqual unmarshalls two jsons into objects and uses ObjectsEqual

func ObjectsEqual

func ObjectsEqual(t *testing.T, expected, actual interface{}, msgAndArgs ...interface{})

ObjectsEqual uses reflect.DeepEqual under the hood

func RenewGet

func RenewGet(url string) (*http.Response, error)

RenewGet executes HTTP GET requests with retry and timeout

Types

type ClickHouseContainer

type ClickHouseContainer struct {
	Container testcontainers.Container
	Context   context.Context

	Port     int
	Dsns     []string
	Database string
	// contains filtered or unexported fields
}

ClickHouseContainer is a ClickHouse testcontainer

func NewClickhouseContainer

func NewClickhouseContainer(ctx context.Context) (*ClickHouseContainer, error)

NewClickhouseContainer creates new Clickhouse test container if CH_TEST_PORT is not defined. Otherwise uses db at defined port. This logic is required for running test at CI environment

func (*ClickHouseContainer) Close

func (ch *ClickHouseContainer) Close() error

Close terminates underlying docker container

func (*ClickHouseContainer) CountRows

func (ch *ClickHouseContainer) CountRows(table string) (int, error)

CountRows returns row count in DB table with name = table or error if occurred

func (*ClickHouseContainer) GetSortedRows

func (ch *ClickHouseContainer) GetSortedRows(table, selectClause, whereClause, orderClause string) ([]map[string]interface{}, error)

type Container

type Container interface {
	io.Closer
	CountRows(table string) (int, error)
	GetSortedRows(table, selectClause, whereClause, orderClause string) ([]map[string]interface{}, error)
}

type ContainerWrapper

type ContainerWrapper struct {
	Container Container
}

type Integration

type Integration struct {
	Name             string
	ReqUrn           string
	ReqBodyPath      string
	ExpectedJSONPath string
	XAuthToken       string

	ExpectedHTTPCode     int
	ExpectedErrMsg       string
	ExpectedDeleteCookie bool
}

Integration is a struct for running Integration tests

type MySQLContainer

type MySQLContainer struct {
	Container testcontainers.Container
	Context   context.Context
	Host      string
	Port      int
	Database  string
	Username  string
	Password  string
	// contains filtered or unexported fields
}

MySQLContainer is a MySQL testcontainer

func NewMySQLContainer

func NewMySQLContainer(ctx context.Context) (*MySQLContainer, error)

NewMySQLContainer creates new MySQL test container if MYSQL_TEST_PORT is not defined. Otherwise uses db at defined port. This logic is required for running test at CI environment

func (*MySQLContainer) Close

func (mc *MySQLContainer) Close() error

Close terminates underlying mysql docker container

func (*MySQLContainer) CountRows

func (mc *MySQLContainer) CountRows(table string) (int, error)

func (*MySQLContainer) GetSortedRows

func (mc *MySQLContainer) GetSortedRows(table, selectClause, whereClause, orderClause string) ([]map[string]interface{}, error)

GetSortedRows returns all selected row from table ordered according to orderClause or error if occurred

type PostgresContainer

type PostgresContainer struct {
	Container testcontainers.Container
	Context   context.Context
	Host      string
	Port      int
	Database  string
	Schema    string
	Username  string
	Password  string
	// contains filtered or unexported fields
}

PostgresContainer is a Postgres testcontainer

func NewPostgresContainer

func NewPostgresContainer(ctx context.Context) (*PostgresContainer, error)

NewPostgresContainer creates new Postgres test container if PG_TEST_PORT is not defined. Otherwise uses db at defined port. This logic is required for running test at CI environment

func (*PostgresContainer) Close

func (pgc *PostgresContainer) Close() error

Close terminates underlying postgres docker container

func (*PostgresContainer) CountRows

func (pgc *PostgresContainer) CountRows(table string) (int, error)

CountRows returns row count in DB table with name = table or error if occurred

func (*PostgresContainer) GetSortedRows

func (pgc *PostgresContainer) GetSortedRows(table, selectClause, whereClause, orderClause string) ([]map[string]interface{}, error)

GetSortedRows returns all selected row from table ordered according to orderClause or error if occurred

type RandomGenerator

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

RandomGenerator is a random data generator it is suggested to use 1 RandomGenerator per 1 table

func NewRandomGenerator

func NewRandomGenerator(uniqueID UniqueIDIface) *RandomGenerator

func (*RandomGenerator) GenerateData

func (rg *RandomGenerator) GenerateData(columns int, rows int) ([]map[string]interface{}, error)

func (*RandomGenerator) GenerateDataWithUniqueIDs

func (rg *RandomGenerator) GenerateDataWithUniqueIDs(columns int, rows int, uniqueCount int) ([]map[string]interface{}, error)

GenerateDataWithUniqueIDs returns array of objects with length=rows. The amount of objects with uniqueID = uniqueCount

type RedisContainer

type RedisContainer struct {
	Container testcontainers.Container
	Context   context.Context
	Host      string
	Port      int
}

RedisContainer is a Redis testcontainer

func NewRedisContainer

func NewRedisContainer(ctx context.Context) (*RedisContainer, error)

NewRedisContainer creates new Redis test container if REDIS_TEST_PORT is not defined. Otherwise uses redis at defined port. This logic is required for running test at CI environment

func (*RedisContainer) Close

func (rc *RedisContainer) Close()

Close terminates underlying docker container

type UniqueIDIface

type UniqueIDIface interface {
	Set(obj map[string]interface{}, id string) error
}

UniqueIDIface is used for preventing cycle dependency

Jump to

Keyboard shortcuts

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