testing

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanupRedis

func CleanupRedis(t *testing.T, rdb *redis.Client, checkClean bool, testName string)

CleanupRedis cleans up the Redis database after a test. If checkClean is true, it will check for keys in the database that contain the test name and fail the test if any are found. It will then flush the database.

func FormatTerminal

func FormatTerminal(e *log.Entry) []byte

FormatTerminal formats a log entry for terminal output. It differs from Clue's default terminal format in that it formats timestamps in milliseconds instead of seconds.

func NewRedisClient

func NewRedisClient(t *testing.T) *redis.Client

func NewTestContext

func NewTestContext(t *testing.T) context.Context

NewTestContext returns a new context with a logger that outputs to the terminal.

Types

type Buffer

type Buffer struct {
	// contains filtered or unexported fields
}

Buffer is a goroutine safe bytes.Buffer

func NewBufferedLogContext

func NewBufferedLogContext(t *testing.T) (context.Context, *Buffer)

NewBufferedLogContext returns a new context and buffer for capturing log output.

func (*Buffer) String

func (s *Buffer) String() string

func (*Buffer) Write

func (s *Buffer) Write(p []byte) (n int, err error)

type Hasher

type Hasher struct {
	Index     int64
	IndexFunc func(key string, numBuckets int64) int64
}

Hasher is a mock hasher for testing It can be used in two ways: 1. Use a static index to pick a bucket 2. Use a function to customize the hashing behavior

func (*Hasher) Hash

func (h *Hasher) Hash(key string, numBuckets int64) int64

Hash returns the bucket index for the given key

Jump to

Keyboard shortcuts

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