testUtils

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Any anyMatcher = "any"
)

Functions

func Fetch

func Fetch(value interface{}, err error) func() (interface{}, error)

Fetch simplifies the code when writing fetch functions to be used by GetOrSet.

func FetchPanic

func FetchPanic() (interface{}, error)

FetchPanic returns a function that should not be called to be passed to GetOrSet.

func GetCacheError

func GetCacheError(get func(key string, result interface{}) (bool, error), key string)

func GetCacheHit

func GetCacheHit(get func(key string, result interface{}) (bool, error), key string, expectedValue int)

func GetCacheMiss

func GetCacheMiss(get func(key string, result interface{}) (bool, error), key string)

func GetOrSetCached

func GetOrSetCached(getOrSet func(string, interface{}, time.Duration, func() (interface{}, error)) error, key string, duration time.Duration, expectedValue int)

func GetOrSetError

func GetOrSetError(getOrSet func(string, interface{}, time.Duration, func() (interface{}, error)) error, key string, duration time.Duration, expectedErr error)

func GetOrSetFetch

func GetOrSetFetch(getOrSet func(string, interface{}, time.Duration, func() (interface{}, error)) error, key string, duration time.Duration, expectedValue int)

Types

type FakeCache

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

func NewFakeCache

func NewFakeCache() *FakeCache

func (*FakeCache) DeleteKey

func (c *FakeCache) DeleteKey(key string) bool

func (*FakeCache) ExpireKey

func (c *FakeCache) ExpireKey(key string) bool

func (*FakeCache) FailGetFor

func (c *FakeCache) FailGetFor(key string, err error)

func (*FakeCache) FailGetOrSetFor

func (c *FakeCache) FailGetOrSetFor(key string, err error)

func (*FakeCache) FailGetStaleFor

func (c *FakeCache) FailGetStaleFor(key string, err error)

func (*FakeCache) FailSetFor

func (c *FakeCache) FailSetFor(key string, err error)

func (*FakeCache) Get

func (c *FakeCache) Get(key string, result interface{}) (hit bool, err error)

func (*FakeCache) GetMustHaveBeenCalledWith

func (c *FakeCache) GetMustHaveBeenCalledWith(key string, times int) error

func (*FakeCache) GetMustNotHaveBeenCalledWith

func (c *FakeCache) GetMustNotHaveBeenCalledWith(key string) error

func (*FakeCache) GetOrSet

func (c *FakeCache) GetOrSet(key string, result interface{}, duration time.Duration, fetch func() (interface{}, error)) error

func (*FakeCache) GetOrSetMustHaveBeenCalledWith

func (c *FakeCache) GetOrSetMustHaveBeenCalledWith(key string, times int, duration interface{}) error

func (*FakeCache) GetOrSetMustNotHaveBeenCalledWith

func (c *FakeCache) GetOrSetMustNotHaveBeenCalledWith(key string, duration interface{}) error

func (*FakeCache) GetStale

func (c *FakeCache) GetStale(key string, result interface{}) (hit bool, err error)

func (*FakeCache) GetStaleMustHaveBeenCalledWith

func (c *FakeCache) GetStaleMustHaveBeenCalledWith(key string, times int) error

func (*FakeCache) GetStaleMustNotHaveBeenCalledWith

func (c *FakeCache) GetStaleMustNotHaveBeenCalledWith(key string) error

func (*FakeCache) Populate

func (c *FakeCache) Populate(key string, value interface{}, duration time.Duration) error

func (*FakeCache) Reset

func (c *FakeCache) Reset() *FakeCache

func (*FakeCache) Set

func (c *FakeCache) Set(key string, value interface{}, duration time.Duration) error

func (*FakeCache) SetMustHaveBeenCalledWith

func (c *FakeCache) SetMustHaveBeenCalledWith(key string, value interface{}, duration interface{}) error

func (*FakeCache) SetMustNotHaveBeenCalledWith

func (c *FakeCache) SetMustNotHaveBeenCalledWith(key string, value interface{}, duration interface{}) error

type Matcher

type Matcher interface {
	Matches(value interface{}) bool
}

Jump to

Keyboard shortcuts

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