Documentation ¶
Overview ¶
Package testutil provides testing helpers.
Index ¶
- func AssertEqual[T types.Type](tb testing.TB, expected, actual T) bool
- func AssertNotEqual[T types.Type](tb testing.TB, expected, actual T) bool
- 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 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(ctx context.Context, tb testing.TB, opts *PoolOpts, l *zap.Logger) *pgdb.Pool
- func Schema(ctx context.Context, tb testing.TB, pool *pgdb.Pool) string
- func SchemaName(tb testing.TB) string
- func SetByPath[T types.CompositeTypeInterface](tb testing.TB, comp T, value any, path ...string)
- func Table(ctx context.Context, tb testing.TB, pool *pgdb.Pool, db string) string
- func TableName(tb testing.TB) string
- func WriteSeedCorpusFile(tb testing.TB, funcName string, b []byte)
- type PoolOpts
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertEqual ¶ added in v0.1.0
AssertEqual asserts that two BSON values are equal.
func AssertNotEqual ¶ added in v0.1.0
AssertNotEqual asserts that two BSON values are not equal.
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 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.
func SetByPath ¶ added in v0.0.5
SetByPath sets the value by path - a sequence of indexes and keys.
The path must exist.
func Table ¶ added in v0.1.0
Table creates FerretDB collection / PostgreSQL table for testing.
Name is stable for that test.