Documentation ¶
Overview ¶
Package testutil provides testing helpers.
Index ¶
- func AssertEqual[T types.Type](tb testtb.TB, expected, actual T) bool
- func AssertEqualSlices[T types.Type](tb testtb.TB, expected, actual []T) bool
- func AssertNotEqual[T types.Type](tb testtb.TB, expected, actual T) bool
- func AssertNotEqualSlices[T types.Type](tb testtb.TB, expected, actual []T) bool
- func CollectionName(tb testtb.TB) string
- func CompareAndSetByPathNum[T types.CompositeTypeInterface](tb testtb.TB, expected, actual T, delta float64, path types.Path)
- func CompareAndSetByPathTime[T types.CompositeTypeInterface](tb testtb.TB, expected, actual T, delta time.Duration, path types.Path)
- func Ctx(tb testtb.TB) context.Context
- func DatabaseName(tb testtb.TB) string
- func DirectoryName(tb testtb.TB) string
- func Dump[T types.Type](tb testtb.TB, o T) string
- func DumpSlice[T types.Type](tb testtb.TB, s []T) string
- func GetByPath[T types.CompositeTypeInterface](tb testtb.TB, comp T, path types.Path) any
- func IndentJSON(tb testtb.TB, b []byte) []byte
- func LevelLogger(tb testtb.TB, level zap.AtomicLevel) *zap.Logger
- func Logger(tb testtb.TB) *zap.Logger
- func MustParseDumpFile(path ...string) []byte
- func ParseDump(tb testtb.TB, s string) []byte
- func ParseDumpFile(tb testtb.TB, path ...string) []byte
- func SetByPath[T types.CompositeTypeInterface](tb testtb.TB, comp T, value any, path types.Path)
- func TestHanaURI(tb testtb.TB) string
- func TestMySQLURI(tb testtb.TB, ctx context.Context, baseURI string) string
- func TestPostgreSQLURI(tb testtb.TB, ctx context.Context, baseURI string) string
- func TestSQLiteURI(tb testtb.TB, baseURI string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertEqual ¶
AssertEqual asserts that two BSON values are equal.
func AssertEqualSlices ¶
AssertEqualSlices asserts that two BSON slices are equal.
func AssertNotEqual ¶
AssertNotEqual asserts that two BSON values are not equal.
func AssertNotEqualSlices ¶
AssertNotEqualSlices asserts that two BSON slices are not equal.
func CollectionName ¶
CollectionName returns a stable FerretDB collection name for that test.
func CompareAndSetByPathNum ¶
func CompareAndSetByPathNum[T types.CompositeTypeInterface](tb testtb.TB, expected, actual T, delta float64, path types.Path)
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 ¶
func CompareAndSetByPathTime[T types.CompositeTypeInterface](tb testtb.TB, expected, actual T, delta time.Duration, path types.Path)
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 DatabaseName ¶
DatabaseName returns a stable FerretDB database name for that test.
func DirectoryName ¶
DirectoryName returns a stable directory name for that test.
It also could be used as PostgreSQL database name (not FerretDB database / PostgreSQL schema name).
func IndentJSON ¶
IndentJSON returns an indented form of the JSON input.
func LevelLogger ¶
LevelLogger returns zap test logger with given level and valid configuration.
func MustParseDumpFile ¶
MustParseDumpFile panics if fails to parse file input to byte array.
func ParseDumpFile ¶
ParseDumpFile parses file input to bytes, in tests.
func SetByPath ¶
SetByPath sets the value by path - a sequence of indexes and keys.
The path must exist.
func TestHanaURI ¶
TestHanaURI returns a HANA Database URL for testing. HANATODO Create a Database per test run?
func TestMySQLURI ¶
TestMySQLURI returns MySQL URI with test-specific database. It will be created before test and dropped after unless test fails.
Base URI may be empty.
func TestPostgreSQLURI ¶
TestPostgreSQLURI returns PostgreSQL URI with test-specific database. It will be created before test and dropped after unless test fails.
Base URI may be empty.
Types ¶
This section is empty.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package testfail provides testing helpers for expected tests failures.
|
Package testfail provides testing helpers for expected tests failures. |
Package teststress provides a helper for stress testing.
|
Package teststress provides a helper for stress testing. |
Package testtb provides a common testing interface.
|
Package testtb provides a common testing interface. |