testutil

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2024 License: Apache-2.0 Imports: 40 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MinPort = 2048
	MaxPort = 16384
)

Variables

This section is empty.

Functions

func CreateDB added in v0.8.0

func CreateDB(t *testing.T, log zerolog.Logger, ctx context.Context, dir string) (*sql.DB, lock.LockFactory, string)

func CreateDBWithType added in v0.8.0

func CreateDBWithType(t *testing.T, log zerolog.Logger, ctx context.Context, dir string, dbType sql.Type) (*sql.DB, lock.LockFactory, string)

func DBType added in v0.8.0

func DBType(t *testing.T) sql.Type

func GetFreePort

func GetFreePort(host string, tcp bool, udp bool) (string, error)

Hack to find a free tcp and udp port

func NewLogger added in v0.7.0

func NewLogger(t *testing.T) zerolog.Logger

func NilError added in v0.9.0

func NilError(t assert.TestingT, err error, msgAndArgs ...interface{})

func ParseEnv added in v0.2.0

func ParseEnv(envvar string) (string, string, error)

func ParseEnvs added in v0.2.0

func ParseEnvs(r io.Reader) (map[string]string, error)

func TestCreate added in v0.8.0

func TestCreate(t *testing.T, lastVersion uint, dataFixtures DataFixtures, setupDBFn SetupDBFn)

func TestImportExport added in v0.8.0

func TestImportExport(t *testing.T, importFixtureFile string, setupDBFn SetupDBFn, seqs map[string]uint64)

func TestMigrate added in v0.8.0

func TestMigrate(t *testing.T, lastVersion uint, dataFixtures DataFixtures, setupDBFn SetupDBFn)

func Wait added in v0.2.0

func Wait(timeout time.Duration, f CheckFunc) error

Types

type CheckFunc added in v0.2.0

type CheckFunc func() (bool, error)

type ColInfo added in v0.9.0

type ColInfo struct {
	Name     string `json:"name"`
	Type     string `json:"type"`
	Nullable bool   `json:"nullable"`
}

type ColType added in v0.9.0

type ColType int
const (
	ColTypeString ColType = iota
	ColTypeBool
	ColTypeInt
	ColTypeFloat
	ColTypeTime
	ColTypeDuration
	ColTypeJSON
	ColTypeByteArray
)

type CreateData added in v0.9.0

type CreateData struct {
	DDL       DDL         `json:"ddl"`
	Sequences []Sequence  `json:"sequences"`
	Tables    []TableInfo `json:"tables"`
}

type DBContext added in v0.8.0

type DBContext struct {
	D            manager.DB
	DBM          *manager.DBManager
	LF           lock.LockFactory
	DBConnString string
	Schema       []TableInfo
}

func (*DBContext) AtlasConnString added in v0.8.0

func (c *DBContext) AtlasConnString() string

func (*DBContext) Column added in v0.9.0

func (c *DBContext) Column(tableName, colName string) (ColInfo, bool)

func (*DBContext) ColumnType added in v0.9.0

func (c *DBContext) ColumnType(tableName, colName string) (ColType, error)

func (*DBContext) Export added in v0.9.0

func (c *DBContext) Export(ctx context.Context, tables []string, w io.Writer) error

func (*DBContext) Import added in v0.9.0

func (c *DBContext) Import(ctx context.Context, r io.Reader, createData *CreateData) error

func (*DBContext) Table added in v0.9.0

func (c *DBContext) Table(tableName string) (TableInfo, bool)

func (*DBContext) Tables added in v0.9.0

func (c *DBContext) Tables() []string

type DDL added in v0.8.0

type DDL struct {
	Postgres []string `json:"postgres"`
	Sqlite3  []string `json:"sqlite3"`
}

type DataFixtures added in v0.9.0

type DataFixtures map[uint]string

type GiteaConfig

type GiteaConfig struct {
	Data              string
	User              string
	HTTPListenAddress string
	HTTPPort          string
	SSHListenAddress  string
	SSHPort           string
}

type Process

type Process struct {
	Cmd *gexpect.ExpectSubprocess
	// contains filtered or unexported fields
}

func (*Process) Kill

func (p *Process) Kill()

func (*Process) Signal

func (p *Process) Signal(sig os.Signal) error

func (*Process) Start

func (p *Process) Start() error

func (*Process) StartExpect

func (p *Process) StartExpect() error

func (*Process) Stop

func (p *Process) Stop()

func (*Process) Wait

func (p *Process) Wait(timeout time.Duration) error

type Sequence added in v0.9.0

type Sequence struct {
	Name   string `json:"name"`
	Table  string `json:"table"`
	Column string `json:"column"`
}

type SetupDBFn added in v0.8.0

type SetupDBFn func(ctx context.Context, t *testing.T, dir string) *DBContext

type TableInfo added in v0.9.0

type TableInfo struct {
	Name    string    `json:"name"`
	Columns []ColInfo `json:"columns"`
}

type TestGitea

type TestGitea struct {
	Process

	GiteaPath         string
	ConfigPath        string
	HTTPListenAddress string
	HTTPPort          string
	SSHListenAddress  string
	SSHPort           string
}

func NewTestGitea

func NewTestGitea(t *testing.T, dir, dockerBridgeAddress string, a ...string) (*TestGitea, error)

Jump to

Keyboard shortcuts

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