Documentation ¶
Overview ¶
Package testutil contains helper functions for unit tests.
Index ¶
- func AssertProtoEqual(t *testing.T, expected, actual interface{}, msgAndArgs ...interface{}) bool
- func AssertProtoJSONEqual(t *testing.T, expected string, protoMsg interface{}, msgAndArgs ...interface{}) bool
- func ModRoot() string
- func RedisTLSConfig() *tls.Config
- func TestDataRoot() string
- func WithTestPostgres(handler func(dsn string) error) error
- func WithTestRedis(useTLS bool, handler func(rawURL string) error) error
- func WithTestRedisCluster(handler func(rawURL string) error) error
- func WithTestRedisSentinel(handler func(rawURL string) error) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertProtoEqual ¶ added in v0.17.0
AssertProtoEqual asserts that two protobuf messages equal. Slices of messages are also supported.
func AssertProtoJSONEqual ¶ added in v0.9.0
func AssertProtoJSONEqual(t *testing.T, expected string, protoMsg interface{}, msgAndArgs ...interface{}) bool
AssertProtoJSONEqual asserts that a protobuf message matches the given JSON. The protoMsg can also be a slice of protobuf messages.
func ModRoot ¶ added in v0.14.0
func ModRoot() string
ModRoot returns the directory containing the go.mod file.
func RedisTLSConfig ¶ added in v0.14.0
RedisTLSConfig returns the TLS Config to use with redis.
func TestDataRoot ¶ added in v0.14.0
func TestDataRoot() string
TestDataRoot returns the testdata directory.
func WithTestPostgres ¶ added in v0.18.0
WithTestPostgres starts a test DB and runs the given handler with the connection to it.
func WithTestRedis ¶ added in v0.14.0
WithTestRedis creates a test a test redis instance using docker.
func WithTestRedisCluster ¶ added in v0.14.0
WithTestRedisCluster creates a new redis cluster 3 node cluster.
func WithTestRedisSentinel ¶ added in v0.14.0
WithTestRedisSentinel creates a new redis sentinel 3 node cluster.
Types ¶
This section is empty.