_test

package
v0.0.0-...-0345585 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2014 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package _test provides utilities for cache testing

Index

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 NewMapCache

func NewMapCache() *MapCache

NewMapCache creates a new CacheMap

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

Jump to

Keyboard shortcuts

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