Documentation ¶
Overview ¶
Package _test provides utilities for cache testing
Index ¶
- Constants
- Variables
- func CacheBenchmarkGet(b *testing.B, cache imageserver_cache.Cache, workerCount int, ...)
- func CacheTestGetErrorMiss(t *testing.T, cache imageserver_cache.Cache)
- func CacheTestGetSet(t *testing.T, cache imageserver_cache.Cache, image *imageserver.Image)
- func CacheTestGetSetAllImages(t *testing.T, cache imageserver_cache.Cache)
- type FuncCache
- type MapCache
Constants ¶
View Source
const ( // KeyValid is a valid cache key (with content) KeyValid = "test" // KeyMiss is an invalid cache key (without content) KeyMiss = "unknown" )
Variables ¶
View Source
var ( // ParametersEmpty is an empty Parameters ParametersEmpty = make(imageserver.Parameters) )
Functions ¶
func CacheBenchmarkGet ¶
func CacheBenchmarkGet(b *testing.B, cache imageserver_cache.Cache, workerCount int, image *imageserver.Image)
CacheBenchmarkGet is a helper to benchmark cache Get()
func CacheTestGetErrorMiss ¶
func CacheTestGetErrorMiss(t *testing.T, cache imageserver_cache.Cache)
CacheTestGetErrorMiss is a helper to test cache Get() with a "cache miss" error
func CacheTestGetSet ¶
func CacheTestGetSet(t *testing.T, cache imageserver_cache.Cache, image *imageserver.Image)
CacheTestGetSet is a helper to test cache Get()/Set()
func CacheTestGetSetAllImages ¶
func CacheTestGetSetAllImages(t *testing.T, cache imageserver_cache.Cache)
CacheTestGetSetAllImages is a helper to test cache Get()/Set() with all images from test data
Types ¶
type FuncCache ¶
type FuncCache struct { GetFunc func(key string, parameters imageserver.Parameters) (*imageserver.Image, error) SetFunc func(key string, image *imageserver.Image, parameters imageserver.Parameters) error }
FuncCache is an Image Cache that forwards calls to user defined functions
func (*FuncCache) Get ¶
func (cache *FuncCache) Get(key string, parameters imageserver.Parameters) (*imageserver.Image, error)
Get forwards call to GetFunc
func (*FuncCache) Set ¶
func (cache *FuncCache) Set(key string, image *imageserver.Image, parameters imageserver.Parameters) error
Set forwards call to SetFunc
type MapCache ¶
type MapCache struct {
// contains filtered or unexported fields
}
MapCache is a simple Cache (it wraps a map) for tests
func (*MapCache) Get ¶
func (cache *MapCache) Get(key string, parameters imageserver.Parameters) (*imageserver.Image, error)
Get gets an Image from the MapCache
func (*MapCache) Set ¶
func (cache *MapCache) Set(key string, image *imageserver.Image, parameters imageserver.Parameters) error
Set sets an Image to the MapCache
Click to show internal directories.
Click to hide internal directories.