Documentation ¶
Overview ¶
Package testutils provides some utilities that may be useful for testing
Index ¶
- Variables
- func ChannelReceiveWithTimeout[T any](t *testing.T, channel <-chan T, timeout time.Duration) (msg T)
- func IfErrPanic(msg string, err error)
- func MockPermissions(ctx context.Context) context.Context
- func ParseDBURI(ctx context.Context) (string, string, *testcontainersx.DBContainer)
- func SetupDB()
- func TeardownDB()
- type LoadBalancerBuilder
- type OriginBuilder
- type PoolBuilder
- type PortBuilder
- type ProviderBuilder
Constants ¶
This section is empty.
Variables ¶
var ( NATSConn *eventtools.TestNats // NATSConn exported if needed for subscribers EventsConn events.Connection // EventsConn exported if needed for subscribers EntClient *ent.Client // EntClient to use as ent client DBContainer *testcontainersx.DBContainer // DBContainer to use through entire test suite )
Functions ¶
func ChannelReceiveWithTimeout ¶
func ChannelReceiveWithTimeout[T any](t *testing.T, channel <-chan T, timeout time.Duration) (msg T)
ChannelReceiveWithTimeout returns the next message from channel chan or panics if it timesout before
func IfErrPanic ¶
IfErrPanic conditionally panics on err with msg
func MockPermissions ¶
MockPermissions creates a context from the given context with mocks for permission-api methods
func ParseDBURI ¶
func ParseDBURI(ctx context.Context) (string, string, *testcontainersx.DBContainer)
ParseDBURI parses the kind of query language from TESTDB_URI env var and initializes DBContainer as required
Types ¶
type LoadBalancerBuilder ¶
type LoadBalancerBuilder struct { Name string OwnerID gidx.PrefixedID LocationID gidx.PrefixedID Provider *ent.Provider }
LoadBalancerBuilder is a loadbalancer-like struct for use in generating a loadbalancer using the ent client
func (*LoadBalancerBuilder) MustNew ¶
func (b *LoadBalancerBuilder) MustNew(ctx context.Context) *ent.LoadBalancer
MustNew creates a loadbalancer from the receiver
type OriginBuilder ¶
type OriginBuilder struct { Name string Target string PortNumber int Active bool PoolID gidx.PrefixedID }
OriginBuilder is an origin-like struct for use in generating an origin using the ent client
type PoolBuilder ¶
type PoolBuilder struct { Name string OwnerID gidx.PrefixedID Protocol pool.Protocol }
PoolBuilder is a pool-like struct for use in generating a pool using the ent client
type PortBuilder ¶
type PortBuilder struct { Name string LoadBalancerID gidx.PrefixedID Number int PoolIDs []gidx.PrefixedID }
PortBuilder is a port-like struct for use in generating a port using the ent client
type ProviderBuilder ¶
type ProviderBuilder struct { Name string OwnerID gidx.PrefixedID }
ProviderBuilder is a provider-like struct for use in generating a provider using the ent client