Documentation ¶
Overview ¶
Package testutil provides testing helpers.
Index ¶
- func AssertEqual[T types.Type](tb testing.TB, expected, actual T) bool
- func AssertEqualSlices[T types.Type](tb testing.TB, expected, actual []T) bool
- func AssertNotEqual[T types.Type](tb testing.TB, expected, actual T) bool
- func AssertNotEqualSlices[T types.Type](tb testing.TB, expected, actual []T) bool
- func CollectionName(tb testing.TB) string
- func CompareAndSetByPathNum[T types.CompositeTypeInterface](tb testing.TB, expected, actual T, delta float64, path types.Path)
- func CompareAndSetByPathTime[T types.CompositeTypeInterface](tb testing.TB, expected, actual T, delta time.Duration, path types.Path)
- func Ctx(tb testing.TB) context.Context
- func DatabaseName(tb testing.TB) string
- func Dump[T types.Type](tb testing.TB, o T) string
- func DumpSlice[T types.Type](tb testing.TB, s []T) string
- func GetByPath[T types.CompositeTypeInterface](tb testing.TB, comp T, path types.Path) any
- func IndentJSON(tb testing.TB, b []byte) []byte
- func Logger(tb testing.TB, level zap.AtomicLevel) *zap.Logger
- func MustParseDumpFile(path ...string) []byte
- func ParseDump(tb testing.TB, s string) []byte
- func ParseDumpFile(tb testing.TB, path ...string) []byte
- func PostgreSQLURL(tb testing.TB, opts *PostgreSQLURLOpts) string
- func SetByPath[T types.CompositeTypeInterface](tb testing.TB, comp T, value any, path types.Path)
- func TigrisURL(tb testing.TB) string
- func WriteSeedCorpusFile(tb testing.TB, funcName string, b []byte)
- type PostgreSQLURLOpts
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 AssertEqualSlices ¶ added in v0.5.1
AssertEqualSlices asserts that two BSON slices are equal.
func AssertNotEqual ¶ added in v0.1.0
AssertNotEqual asserts that two BSON values are not equal.
func AssertNotEqualSlices ¶ added in v0.5.1
AssertNotEqualSlices asserts that two BSON slices are not equal.
func CollectionName ¶ added in v0.5.1
CollectionName returns a stable FerretDB collection name for that test.
It should be called only once per test.
func CompareAndSetByPathNum ¶ added in v0.0.5
func CompareAndSetByPathNum[T types.CompositeTypeInterface](tb testing.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 ¶ added in v0.0.5
func CompareAndSetByPathTime[T types.CompositeTypeInterface](tb testing.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 ¶ added in v0.5.1
DatabaseName returns a stable FerretDB database name for that test.
It should be called only once per test.
func GetByPath ¶ added in v0.0.5
GetByPath returns a value by path - a sequence of indexes and keys.
func IndentJSON ¶ added in v0.4.0
IndentJSON returns an indented form of the JSON input.
func MustParseDumpFile ¶
MustParseDumpFile panics if fails to parse file input to byte array.
func ParseDumpFile ¶
ParseDumpFile parses file input to bytes, in tests.
func PostgreSQLURL ¶ added in v0.5.3
func PostgreSQLURL(tb testing.TB, opts *PostgreSQLURLOpts) string
PostgreSQLURL returns PostgreSQL URL for testing.
TODO remove this function https://github.com/FerretDB/FerretDB/issues/1568
func SetByPath ¶ added in v0.0.5
SetByPath sets the value by path - a sequence of indexes and keys.
The path must exist.
func TigrisURL ¶ added in v0.5.0
TigrisURL returns Tigris URL for testing.
TODO remove this function https://github.com/FerretDB/FerretDB/issues/1568
Types ¶
type PostgreSQLURLOpts ¶ added in v0.5.3
type PostgreSQLURLOpts struct { // PostgreSQL database name, defaults to `ferretdb`. DatabaseName string // If set, the pool will use read-only user. ReadOnly bool // Extra query parameters. Params map[string]string }
PostgreSQLURLOpts represents PostgreSQLURL options.