testutil

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareAndSetByPathNum added in v0.0.5

func CompareAndSetByPathNum(tb testing.TB, expected, actual types.CompositeType, delta float64, path ...string)

CompareAndSetByPathNum asserts that two values with the same path in two objects (documents or arrays) are within a given numerical delta, then updates the expected object with the actual value.

func CompareAndSetByPathTime added in v0.0.5

func CompareAndSetByPathTime(tb testing.TB, expected, actual types.CompositeType, delta time.Duration, path ...string)

CompareAndSetByPathTime asserts that two values with the same path in two objects (documents or arrays) are within a given time delta, then updates the expected object with the actual value.

func CreateTable added in v0.0.5

func CreateTable(ctx context.Context, tb testing.TB, pool *pg.Pool, db string) string

CreateTable creates FerretDB collection / PostgreSQL table for testing.

Name is stable for that test.

func Ctx

func Ctx(tb testing.TB) context.Context

func GetByPath added in v0.0.5

func GetByPath(tb testing.TB, comp types.CompositeType, path ...string) any

GetByPath returns a value by path - a sequence of indexes and keys.

func MustParseDumpFile

func MustParseDumpFile(path ...string) []byte

func ParseDump

func ParseDump(tb testing.TB, s string) []byte

func ParseDumpFile

func ParseDumpFile(tb testing.TB, path ...string) []byte

func Pool

func Pool(_ context.Context, tb testing.TB, opts *PoolOpts) *pg.Pool

Pool creates a new connection connection pool for testing.

func Schema

func Schema(ctx context.Context, tb testing.TB, pool *pg.Pool) string

Schema creates a new FerretDB database / PostgreSQL schema for testing.

Name is stable for that test. It is automatically dropped if test pass.

func SchemaName added in v0.0.5

func SchemaName(tb testing.TB) string

SchemaName returns a stable schema name for that test.

func SetByPath added in v0.0.5

func SetByPath(tb testing.TB, comp types.CompositeType, value any, path ...string)

SetByPath sets the value by path - a sequence of indexes and keys.

The path must exist.

func TableName added in v0.0.5

func TableName(tb testing.TB) string

TableName returns a stable table name for that test.

Types

type PoolOpts added in v0.0.5

type PoolOpts struct {
	// If set, the pool will use read-only user.
	ReadOnly bool
}

PoolOpts represents options for creating a connection pool.

Jump to

Keyboard shortcuts

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