tester

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package tester is a generic testing package with helpful methods for all packages

Index

Constants

This section is empty.

Variables

View Source
var ErrAppNameRequired = spverrors.Newf("app name is required")

ErrAppNameRequired is when the app name is required

View Source
var ErrFailedLoadingPostgresql = spverrors.Newf("failed loading postgresql server")

ErrFailedLoadingPostgresql is when loading postgresql failed

Functions

func CacheStore

func CacheStore() cachestore.ClientInterface

CacheStore will return a cache store for using in tests

func CreatePostgresServer

func CreatePostgresServer(port uint32) (*embeddedPostgres.EmbeddedPostgres, error)

CreatePostgresServer will create a new Postgresql server

func LoadMockRedis

func LoadMockRedis(
	idleTimeout time.Duration,
	maxConnTime time.Duration,
	maxActive int,
	maxIdle int,
) (client *cache.Client, conn *redigomock.Conn)

LoadMockRedis will load a mocked redis connection

func LoadRealRedis

func LoadRealRedis(
	connectionURL string,
	idleTimeout time.Duration,
	maxConnTime time.Duration,
	maxActive int,
	maxIdle int,
	dependency bool,
) (client *cache.Client, conn redis.Conn, err error)

LoadRealRedis will load a real redis connection

func Logger

func Logger(t testing.TB) zerolog.Logger

Logger returns a logger that can be used as a dependency in tests.

func RandomTablePrefix

func RandomTablePrefix() string

RandomTablePrefix will make a random prefix (avoid same tables for parallel tests)

func SQLiteTestConfig

func SQLiteTestConfig() *datastore.SQLiteConfig

SQLiteTestConfig will return a test-version of SQLite

Types

type AnyGUID

type AnyGUID struct{}

AnyGUID will fill the need for any GUID field

func (AnyGUID) Match

func (a AnyGUID) Match(v driver.Value) bool

Match satisfies sqlmock.Argument interface

type AnyTime

type AnyTime struct{}

AnyTime will fill the need for any timestamp field

func (AnyTime) Match

func (a AnyTime) Match(v driver.Value) bool

Match satisfies sqlmock.Argument interface

type CallDetails

type CallDetails struct {
	URL string

	RequestMethod  string
	RequestBody    []byte
	RequestHeaders Headers

	ResponseBody []byte
	ResponseCode int
}

CallDetails holds the details of a call made to the mocked server

type HTTPSniffer

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

func NewHTTPSniffer

func NewHTTPSniffer(next http.RoundTripper) *HTTPSniffer

func (*HTTPSniffer) GetCallByRegex

func (s *HTTPSniffer) GetCallByRegex(r string) *CallDetails

func (*HTTPSniffer) RoundTrip

func (s *HTTPSniffer) RoundTrip(req *http.Request) (*http.Response, error)

type Headers

type Headers map[string]string

func (Headers) Get

func (h Headers) Get(key string) (string, bool)

func (Headers) Set

func (h Headers) Set(key, value string)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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