testutils

package
v0.0.33 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2023 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Package testutils provides some utilities that may be useful for testing

Index

Constants

This section is empty.

Variables

View Source
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

func IfErrPanic(msg string, err error)

IfErrPanic conditionally panics on err with msg

func MockPermissions

func MockPermissions(ctx context.Context) context.Context

MockPermissions creates a context from the given context with mocks for permission-api methods

func ParseDBURI

ParseDBURI parses the kind of query language from TESTDB_URI env var and initializes DBContainer as required

func SetupDB

func SetupDB()

SetupDB sets up in-memory nats server/conn, database and ent client to interact with db

func TeardownDB

func TeardownDB()

TeardownDB used for clean up test setup

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

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

func (*OriginBuilder) MustNew

func (o *OriginBuilder) MustNew(ctx context.Context) *ent.Origin

MustNew creates an origin from the receiver

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

func (*PoolBuilder) MustNew

func (p *PoolBuilder) MustNew(ctx context.Context) *ent.Pool

MustNew creates a pool from the receiver

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

func (*PortBuilder) MustNew

func (p *PortBuilder) MustNew(ctx context.Context) *ent.Port

MustNew creates a port from the receiver

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

func (*ProviderBuilder) MustNew

func (p *ProviderBuilder) MustNew(ctx context.Context) *ent.Provider

MustNew creates a provider from the receiver

Jump to

Keyboard shortcuts

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