testutil

package
v0.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 26, 2022 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package testutil provides testing helpers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertEqual added in v0.1.0

func AssertEqual[T types.Type](tb testing.TB, expected, actual T) bool

AssertEqual asserts that two BSON values are equal.

func AssertEqualSlices added in v0.5.1

func AssertEqualSlices[T types.Type](tb testing.TB, expected, actual []T) bool

AssertEqual asserts that two BSON slices are equal.

func AssertNotEqual added in v0.1.0

func AssertNotEqual[T types.Type](tb testing.TB, expected, actual T) bool

AssertNotEqual asserts that two BSON values are not equal.

func AssertNotEqualSlices added in v0.5.1

func AssertNotEqualSlices[T types.Type](tb testing.TB, expected, actual []T) bool

AssertNotEqualSlices asserts that two BSON slices are not equal.

func CollectionName added in v0.5.1

func CollectionName(tb testing.TB) string

CollectionName returns a stable collection name for that 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 Ctx

func Ctx(tb testing.TB) context.Context

Ctx returns test context.

func DatabaseName added in v0.5.1

func DatabaseName(tb testing.TB) string

DatabaseName returns a stable database name for that test.

func Dump added in v0.0.6

func Dump[T types.Type](tb testing.TB, o T) string

Dump returns string representation for debugging.

func DumpSlice added in v0.5.1

func DumpSlice[T types.Type](tb testing.TB, s []T) string

DumpSlice returns string representation for debugging.

func GetByPath added in v0.0.5

func GetByPath[T types.CompositeTypeInterface](tb testing.TB, comp T, path types.Path) any

GetByPath returns a value by path - a sequence of indexes and keys.

func IndentJSON added in v0.4.0

func IndentJSON(tb testing.TB, b []byte) []byte

IndentJSON returns an indented form of the JSON input.

func MustParseDumpFile

func MustParseDumpFile(path ...string) []byte

MustParseDumpFile panics if fails to parse file input to byte array.

func ParseDump

func ParseDump(tb testing.TB, s string) []byte

ParseDump parses string to bytes, in tests.

func ParseDumpFile

func ParseDumpFile(tb testing.TB, path ...string) []byte

ParseDumpFile parses file input to bytes, in tests.

func PoolConnString added in v0.5.0

func PoolConnString(tb testing.TB, opts *PoolOpts) string

PoolConnString returns PostgreSQL connection string for testing.

func SchemaName deprecated added in v0.0.5

func SchemaName(tb testing.TB) string

SchemaName should not be used.

Deprecated: use DatabaseName instead.

func SetByPath added in v0.0.5

func SetByPath[T types.CompositeTypeInterface](tb testing.TB, comp T, value any, path types.Path)

SetByPath sets the value by path - a sequence of indexes and keys.

The path must exist.

func TableName deprecated added in v0.0.5

func TableName(tb testing.TB) string

TableName should not be used.

Deprecated: use CollectionName instead.

func TigrisURL added in v0.5.0

func TigrisURL(tb testing.TB) string

TigrisURL returns Tigris URL for testing.

func WriteSeedCorpusFile added in v0.1.0

func WriteSeedCorpusFile(tb testing.TB, funcName string, b []byte)

WriteSeedCorpusFile adds given data to the fuzzing seed corpus for given fuzz function.

It can be an alternative to using f.Add.

Types

type PoolOpts added in v0.0.5

type PoolOpts struct {
	// If set, the pool will use read-only user.
	ReadOnly bool
}

PoolOpts represents options for creating a connection pool.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL