Documentation ¶
Overview ¶
Package testutil provides testing helpers.
Index ¶
- func CompareAndSetByPathNum[T types.CompositeTypeInterface](tb testing.TB, expected, actual T, delta float64, path ...string)
- func CompareAndSetByPathTime[T types.CompositeTypeInterface](tb testing.TB, expected, actual T, delta time.Duration, path ...string)
- func CreateTable(ctx context.Context, tb testing.TB, pool *pg.Pool, db string) string
- func Ctx(tb testing.TB) context.Context
- func Dump[T types.Type](tb testing.TB, o T) string
- func GetByPath[T types.CompositeTypeInterface](tb testing.TB, comp T, path ...string) any
- func MustParseDumpFile(path ...string) []byte
- func ParseDump(tb testing.TB, s string) []byte
- func ParseDumpFile(tb testing.TB, path ...string) []byte
- func Pool(_ context.Context, tb testing.TB, opts *PoolOpts) *pg.Pool
- func Schema(ctx context.Context, tb testing.TB, pool *pg.Pool) string
- func SchemaName(tb testing.TB) string
- func SetByPath[T types.CompositeTypeInterface](tb testing.TB, comp T, value any, path ...string)
- func TableName(tb testing.TB) string
- type PoolOpts
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompareAndSetByPathNum ¶ added in v0.0.5
func CompareAndSetByPathNum[T types.CompositeTypeInterface](tb testing.TB, expected, actual T, 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[T types.CompositeTypeInterface](tb testing.TB, expected, actual T, 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
CreateTable creates FerretDB collection / PostgreSQL table for testing.
Name is stable for that test.
func GetByPath ¶ added in v0.0.5
GetByPath returns a value by path - a sequence of indexes and keys.
func MustParseDumpFile ¶
func Schema ¶
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
SchemaName returns a stable schema name for that test.