Documentation
¶
Overview ¶
Package testutil provides testing helpers.
Index ¶
- Variables
- func AssertEqual[T wirebson.Type](tb testing.TB, expected, actual T) booldeprecated
- func CollectionName(tb testing.TB) string
- func Ctx(tb testing.TB) context.Context
- func DatabaseName(tb testing.TB) string
- func Exclusive(ctx context.Context, reason string)
- func IndentJSON(tb testing.TB, b []byte) []byte
- func LevelLogger(tb testing.TB, level slog.Leveler) *slog.Logger
- func Logger(tb testing.TB) *slog.Logger
- func MustParseDumpFile(path ...string) []byte
- func PostgreSQLURL(tb testing.TB) string
- func Unindent(tb testing.TB, s string) string
Constants ¶
This section is empty.
Variables ¶
var ( // RootDir is the DocDB <root> directory. RootDir string // BinDir is the <root>/bin directory. BinDir string // BuildCertsDir is the <root>/build/certs directory. BuildCertsDir string // IntegrationDir is the <root>/integration directory. IntegrationDir string // TmpDir is the <root>/tmp directory. TmpDir string // TmpRecordsDir is the <root>/tmp/records directory. TmpRecordsDir string )
Functions ¶
func AssertEqual
deprecated
func CollectionName ¶
CollectionName returns a stable DocDB collection name for that test.
func Ctx ¶
Ctx returns test context with OpenTelemetry span, that also can be used with Exclusive. It is canceled when test is finished or interrupted.
Integration tests should use this function. Many unit tests could use the standard testing.T.Context instead.
func DatabaseName ¶
DatabaseName returns a stable DocDB database name for that test.
func Exclusive ¶
Exclusive signals that test calling that function can't be run in parallel with any other test that uses Ctx to get test context, including tests in other packages.
The bar for using this helper is very high. Most tests can run in parallel with other tests just fine by retrying operations, filtering results, or using different instances of system under test (collections, databases, etc).
func IndentJSON ¶
IndentJSON returns an indented form of the JSON input.
func LevelLogger ¶
LevelLogger returns a slog test logger for the given level (which might be dynamic).
func MustParseDumpFile ¶
MustParseDumpFile panics if fails to parse file input to byte array.
func PostgreSQLURL ¶
PostgreSQLURL returns PostgreSQL URL for testing.
It skips the test if it is in short mode.
Types ¶
This section is empty.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package teststress provides a helper for stress testing.
|
Package teststress provides a helper for stress testing. |