testutils

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CharSetAlphaNum is the alphanumeric character set for use with
	// RandStringFromCharSet
	CharSetAlphaNum = "abcdefghijklmnopqrstuvwxyz012346789"

	// CharSetAlpha is the alphabetical character set for use with
	// RandStringFromCharSet
	CharSetAlpha = "abcdefghijklmnopqrstuvwxyz"
)

Variables

View Source
var (
	NumTests          = 100
	Upstream          = "rabbitmq:5672"
	Username          = "admin"
	Password          = "password"
	Hostname          = "localhost"
	ToxiProxyPort     = 8474
	BrokenPort        = 5670
	HealthyPort       = 5671
	ExcludedPorts     = []int{BrokenPort, HealthyPort, ToxiProxyPort}
	BrokenConnectURL  = fmt.Sprintf("amqp://%s:%s@%s:%d/", Username, Password, Hostname, BrokenPort)
	HealthyConnectURL = fmt.Sprintf("amqp://%s:%s@%s:%d/", Username, Password, Hostname, HealthyPort)
)

Functions

func CallerFileLine

func CallerFileLine(up ...int) string

func CallerFuncName

func CallerFuncName(up ...int) string

func ConnectionNameGenerator

func ConnectionNameGenerator(options ...GeneratorOption) (nextConnName func() string)

func ConsumerNameGenerator

func ConsumerNameGenerator(queueName string, options ...GeneratorOption) (nextConsumerName func() string)

func ExchangeNameGenerator

func ExchangeNameGenerator(sessionName string, options ...GeneratorOption) (nextExchangeName func() string)

func FileLine

func FileLine(up ...int) string

func FilePath

func FilePath(relative string, up ...int) string

func FuncName

func FuncName(up ...int) string

func Jitter

func Jitter(min, max time.Duration) time.Duration

func MessageGenerator

func MessageGenerator(queueOrExchangeName string, options ...GeneratorOption) (nextMessage func() string)

func NewConnectURLGenerator

func NewConnectURLGenerator(excludePorts ...int) func() (proxyName, connectURL string, port int)

func NewExchangeQueueGenerator

func NewExchangeQueueGenerator(funcName string) func() ExchangeQueue

func NewPortGenerator

func NewPortGenerator(excludePorts ...int) func() int

func NextConnectURL

func NextConnectURL() (proxyName, connectURL string, port int)

func NextPort

func NextPort() int

func PoolNameGenerator

func PoolNameGenerator(funcName string, options ...GeneratorOption) (nextConnName func() string)

func QueueNameGenerator

func QueueNameGenerator(sessionName string, options ...GeneratorOption) (nextQueueName func() string)

func RandInt

func RandInt() int

RandInt generates a random integer

func RandIntRange

func RandIntRange(min int, max int) int

RandIntRange returns a random integer between min (inclusive) and max (exclusive)

func RandIntWithPrefix

func RandIntWithPrefix(name string) string

RandIntWithPrefix is used to generate a unique name with a prefix

func RandString

func RandString(strlen int) string

RandString generates a random alphanumeric string of the length specified

func RandStringFromCharSet

func RandStringFromCharSet(strlen int, charSet string) string

RandStringFromCharSet generates a random string by selecting characters from the charset provided

func RoutingKeyGenerator

func RoutingKeyGenerator(sessionName string, options ...GeneratorOption) (nextRoutingKey func() string)

func SessionNameGenerator

func SessionNameGenerator(connectionName string, options ...GeneratorOption) (nextSessionName func() string)

func VerifyLeak

func VerifyLeak(m *testing.M)

Types

type ExchangeQueue

type ExchangeQueue struct {
	Exchange   string
	Queue      string
	RoutingKey string

	ConsumerTag string

	NextPubMsg func() string
	NextSubMsg func() string
}

func NewExchangeQueue

func NewExchangeQueue(exchange, queue, routingKey string) ExchangeQueue

type GeneratorOption

type GeneratorOption func(*generatorOptions)

func WithPrefix

func WithPrefix(prefix string) GeneratorOption

func WithRandomSuffix

func WithRandomSuffix(addRandomSuffix bool) GeneratorOption

func WithSuffix

func WithSuffix(suffix string) GeneratorOption

Jump to

Keyboard shortcuts

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