memcachemock

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2023 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

The package memcachemock is used to mock a memcache client.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(server ...string) *memcachemock

func NewFromSelector

func NewFromSelector(ss *memcache.ServerSelector) *memcachemock

Types

type CallModifier

type CallModifier interface {
	Maybe() CallModifier
	Times(n uint) CallModifier
	WillReturnError(err error)
}

type Expectation

type Expectation interface {
	sync.Locker
	fmt.Stringer
	// contains filtered or unexported methods
}

an Expectation interface

type ExpectationType

type ExpectationType[t any] interface {
	Expectation
	// contains filtered or unexported methods
}

type ExpectedAdd

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

ExpectedAdd is used to manage *memcache.Client.Add expectations

func (*ExpectedAdd) Maybe

func (e *ExpectedAdd) Maybe() CallModifier

Maybe allows the expected method call to be optional. Not calling an optional method will not cause an error while asserting expectations

func (*ExpectedAdd) String

func (e *ExpectedAdd) String() string

String returns string representation

func (*ExpectedAdd) Times

func (e *ExpectedAdd) Times(n uint) CallModifier

Times indicates that the expected method should only fire the indicated number of times. Zero value is ignored and means the same as one.

func (*ExpectedAdd) WillReturnError

func (e *ExpectedAdd) WillReturnError(err error)

WillReturnError allows to set an error for the expected method.

func (*ExpectedAdd) WithItem

func (e *ExpectedAdd) WithItem(item *memcache.Item) *ExpectedAdd

WithItem will match given expected memcache.Item to actual memcache.Item used when calling memcache.Client.Add(). If at least one field does not match, it will return an error.

type ExpectedAppend

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

ExpectedAppend is used to manage *memcache.Client.Append expectations

func (*ExpectedAppend) Maybe

func (e *ExpectedAppend) Maybe() CallModifier

Maybe allows the expected method call to be optional. Not calling an optional method will not cause an error while asserting expectations

func (*ExpectedAppend) String

func (e *ExpectedAppend) String() string

String returns string representation

func (*ExpectedAppend) Times

func (e *ExpectedAppend) Times(n uint) CallModifier

Times indicates that the expected method should only fire the indicated number of times. Zero value is ignored and means the same as one.

func (*ExpectedAppend) WillReturnError

func (e *ExpectedAppend) WillReturnError(err error)

WillReturnError allows to set an error for the expected method.

func (*ExpectedAppend) WithItem

func (e *ExpectedAppend) WithItem(item *memcache.Item) *ExpectedAppend

WithItem will match given expected memcache.Item to actual memcache.Item used when calling memcache.Client.Append(). If at least one field does not match, it will return an error.

type ExpectedClose

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

ExpectedClose is used to manage *memcache.Client.Close expectations

func (*ExpectedClose) Maybe

func (e *ExpectedClose) Maybe() CallModifier

Maybe allows the expected method call to be optional. Not calling an optional method will not cause an error while asserting expectations

func (*ExpectedClose) String

func (e *ExpectedClose) String() string

String returns string representation

func (*ExpectedClose) Times

func (e *ExpectedClose) Times(n uint) CallModifier

Times indicates that the expected method should only fire the indicated number of times. Zero value is ignored and means the same as one.

func (*ExpectedClose) WillReturnError

func (e *ExpectedClose) WillReturnError(err error)

WillReturnError allows to set an error for the expected method.

type ExpectedCompareAndSwap

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

ExpectedCompareAndSwap is used to manage *memcache.Client.CompareAndSwap expectations

func (*ExpectedCompareAndSwap) Maybe

func (e *ExpectedCompareAndSwap) Maybe() CallModifier

Maybe allows the expected method call to be optional. Not calling an optional method will not cause an error while asserting expectations

func (*ExpectedCompareAndSwap) String

func (e *ExpectedCompareAndSwap) String() string

String returns string representation

func (*ExpectedCompareAndSwap) Times

func (e *ExpectedCompareAndSwap) Times(n uint) CallModifier

Times indicates that the expected method should only fire the indicated number of times. Zero value is ignored and means the same as one.

func (*ExpectedCompareAndSwap) WillReturnError

func (e *ExpectedCompareAndSwap) WillReturnError(err error)

WillReturnError allows to set an error for the expected method.

func (*ExpectedCompareAndSwap) WithItem

WithItem will match given expected memcache.Item to actual memcache.Item used when calling memcache.Client.CompareAndSwap(). If at least one field does not match, it will return an error.

type ExpectedDecrement

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

ExpectedDecrement is used to manage *memcache.Client.Decrement expectations

func (*ExpectedDecrement) Maybe

func (e *ExpectedDecrement) Maybe() CallModifier

Maybe allows the expected method call to be optional. Not calling an optional method will not cause an error while asserting expectations

func (*ExpectedDecrement) String

func (e *ExpectedDecrement) String() string

String returns string representation

func (*ExpectedDecrement) Times

func (e *ExpectedDecrement) Times(n uint) CallModifier

Times indicates that the expected method should only fire the indicated number of times. Zero value is ignored and means the same as one.

func (*ExpectedDecrement) WillReturnError

func (e *ExpectedDecrement) WillReturnError(err error)

WillReturnError allows to set an error for the expected method.

func (*ExpectedDecrement) WillReturnValue

func (e *ExpectedDecrement) WillReturnValue(value uint64) *ExpectedDecrement

WillReturnValue specifies the value that will be returned when calling memcache.Client.Decrement().

func (*ExpectedDecrement) WithKeyAndDelta

func (e *ExpectedDecrement) WithKeyAndDelta(key string, delta uint64) *ExpectedDecrement

WithKeyAndDelta will match given expected key and delta value to actual key and delta used when calling memcache.Client.Decrement(). If at least one parameter does not match, it will return an error.

type ExpectedDelete

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

ExpectedDelete is used to manage *memcache.Client.Delete expectations

func (*ExpectedDelete) Maybe

func (e *ExpectedDelete) Maybe() CallModifier

Maybe allows the expected method call to be optional. Not calling an optional method will not cause an error while asserting expectations

func (*ExpectedDelete) String

func (e *ExpectedDelete) String() string

String returns string representation

func (*ExpectedDelete) Times

func (e *ExpectedDelete) Times(n uint) CallModifier

Times indicates that the expected method should only fire the indicated number of times. Zero value is ignored and means the same as one.

func (*ExpectedDelete) WillReturnError

func (e *ExpectedDelete) WillReturnError(err error)

WillReturnError allows to set an error for the expected method.

func (*ExpectedDelete) WithKey

func (e *ExpectedDelete) WithKey(key string) *ExpectedDelete

WithKey will match given expected key to actual key used when calling memcache.Client.Delete(). if the keys do not match, it will return an error.

type ExpectedDeleteAll

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

ExpectedDeleteAll is used to manage *memcache.Client.DeleteAll expectations

func (*ExpectedDeleteAll) Maybe

func (e *ExpectedDeleteAll) Maybe() CallModifier

Maybe allows the expected method call to be optional. Not calling an optional method will not cause an error while asserting expectations

func (*ExpectedDeleteAll) String

func (e *ExpectedDeleteAll) String() string

String returns string representation

func (*ExpectedDeleteAll) Times

func (e *ExpectedDeleteAll) Times(n uint) CallModifier

Times indicates that the expected method should only fire the indicated number of times. Zero value is ignored and means the same as one.

func (*ExpectedDeleteAll) WillReturnError

func (e *ExpectedDeleteAll) WillReturnError(err error)

WillReturnError allows to set an error for the expected method.

type ExpectedFlushAll

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

ExpectedFlushAll is used to manage *memcache.Client.FlushAll expectations

func (*ExpectedFlushAll) Maybe

func (e *ExpectedFlushAll) Maybe() CallModifier

Maybe allows the expected method call to be optional. Not calling an optional method will not cause an error while asserting expectations

func (*ExpectedFlushAll) String

func (e *ExpectedFlushAll) String() string

String returns string representation

func (*ExpectedFlushAll) Times

func (e *ExpectedFlushAll) Times(n uint) CallModifier

Times indicates that the expected method should only fire the indicated number of times. Zero value is ignored and means the same as one.

func (*ExpectedFlushAll) WillReturnError

func (e *ExpectedFlushAll) WillReturnError(err error)

WillReturnError allows to set an error for the expected method.

type ExpectedGet

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

ExpectedGet is used to manage *memcache.Client.Get expectations

func (*ExpectedGet) Maybe

func (e *ExpectedGet) Maybe() CallModifier

Maybe allows the expected method call to be optional. Not calling an optional method will not cause an error while asserting expectations

func (*ExpectedGet) String

func (e *ExpectedGet) String() string

String returns string representation

func (*ExpectedGet) Times

func (e *ExpectedGet) Times(n uint) CallModifier

Times indicates that the expected method should only fire the indicated number of times. Zero value is ignored and means the same as one.

func (*ExpectedGet) WillReturnError

func (e *ExpectedGet) WillReturnError(err error)

WillReturnError allows to set an error for the expected method.

func (*ExpectedGet) WillReturnItem

func (e *ExpectedGet) WillReturnItem(item *memcache.Item) *ExpectedGet

WillReturnItem specifies the memcache.Item that will be returned when calling memcache.Client.Get().

func (*ExpectedGet) WithKey

func (e *ExpectedGet) WithKey(key string) *ExpectedGet

WithKey will match given expected key to actual key used when calling memcache.Client.Get(). if the keys do not match, it will return an error.

type ExpectedGetMulti

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

ExpectedGetMulti is used to manage *memcache.Client.GetMulti expectations

func (*ExpectedGetMulti) Maybe

func (e *ExpectedGetMulti) Maybe() CallModifier

Maybe allows the expected method call to be optional. Not calling an optional method will not cause an error while asserting expectations

func (*ExpectedGetMulti) String

func (e *ExpectedGetMulti) String() string

String returns string representation

func (*ExpectedGetMulti) Times

func (e *ExpectedGetMulti) Times(n uint) CallModifier

Times indicates that the expected method should only fire the indicated number of times. Zero value is ignored and means the same as one.

func (*ExpectedGetMulti) WillReturnError

func (e *ExpectedGetMulti) WillReturnError(err error)

WillReturnError allows to set an error for the expected method.

func (*ExpectedGetMulti) WillReturnItems

func (e *ExpectedGetMulti) WillReturnItems(items map[string]*memcache.Item) *ExpectedGetMulti

WillReturnItems specifies the map of memcache.Item that will be returned when calling memcache.Client.GetMulti().

func (*ExpectedGetMulti) WithKeys

func (e *ExpectedGetMulti) WithKeys(keys []string) *ExpectedGetMulti

WithKeys will match given expected keys to actual keys used when calling memcache.Client.GetMulti(). If at least one of the keys does not match, it will return an error.

type ExpectedIncrement

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

ExpectedIncrement is used to manage *memcache.Client.Increment expectations

func (*ExpectedIncrement) Maybe

func (e *ExpectedIncrement) Maybe() CallModifier

Maybe allows the expected method call to be optional. Not calling an optional method will not cause an error while asserting expectations

func (*ExpectedIncrement) String

func (e *ExpectedIncrement) String() string

String returns string representation

func (*ExpectedIncrement) Times

func (e *ExpectedIncrement) Times(n uint) CallModifier

Times indicates that the expected method should only fire the indicated number of times. Zero value is ignored and means the same as one.

func (*ExpectedIncrement) WillReturnError

func (e *ExpectedIncrement) WillReturnError(err error)

WillReturnError allows to set an error for the expected method.

func (*ExpectedIncrement) WillReturnValue

func (e *ExpectedIncrement) WillReturnValue(value uint64) *ExpectedIncrement

WillReturnValue specifies the value that will be returned when calling memcache.Client.Increment().

func (*ExpectedIncrement) WithKeyAndDelta

func (e *ExpectedIncrement) WithKeyAndDelta(key string, delta uint64) *ExpectedIncrement

WithKeyAndDelta will match given expected key and delta value to actual key and delta used when calling memcache.Client.Increment(). If at least one parameter does not match, it will return an error.

type ExpectedPing

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

ExpectedPing is used to manage *memcache.Client.Ping expectations

func (*ExpectedPing) Maybe

func (e *ExpectedPing) Maybe() CallModifier

Maybe allows the expected method call to be optional. Not calling an optional method will not cause an error while asserting expectations

func (*ExpectedPing) String

func (e *ExpectedPing) String() string

String returns string representation

func (*ExpectedPing) Times

func (e *ExpectedPing) Times(n uint) CallModifier

Times indicates that the expected method should only fire the indicated number of times. Zero value is ignored and means the same as one.

func (*ExpectedPing) WillReturnError

func (e *ExpectedPing) WillReturnError(err error)

WillReturnError allows to set an error for the expected method.

type ExpectedPrepend

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

ExpectedPrepend is used to manage *memcache.Client.Prepend expectations

func (*ExpectedPrepend) Maybe

func (e *ExpectedPrepend) Maybe() CallModifier

Maybe allows the expected method call to be optional. Not calling an optional method will not cause an error while asserting expectations

func (*ExpectedPrepend) String

func (e *ExpectedPrepend) String() string

String returns string representation

func (*ExpectedPrepend) Times

func (e *ExpectedPrepend) Times(n uint) CallModifier

Times indicates that the expected method should only fire the indicated number of times. Zero value is ignored and means the same as one.

func (*ExpectedPrepend) WillReturnError

func (e *ExpectedPrepend) WillReturnError(err error)

WillReturnError allows to set an error for the expected method.

func (*ExpectedPrepend) WithItem

func (e *ExpectedPrepend) WithItem(item *memcache.Item) *ExpectedPrepend

WithItem will match given expected memcache.Item to actual memcache.Item used when calling memcache.Client.Prepend(). If at least one field does not match, it will return an error.

type ExpectedReplace

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

ExpectedReplace is used to manage *memcache.Client.Replace expectations

func (*ExpectedReplace) Maybe

func (e *ExpectedReplace) Maybe() CallModifier

Maybe allows the expected method call to be optional. Not calling an optional method will not cause an error while asserting expectations

func (*ExpectedReplace) String

func (e *ExpectedReplace) String() string

String returns string representation

func (*ExpectedReplace) Times

func (e *ExpectedReplace) Times(n uint) CallModifier

Times indicates that the expected method should only fire the indicated number of times. Zero value is ignored and means the same as one.

func (*ExpectedReplace) WillReturnError

func (e *ExpectedReplace) WillReturnError(err error)

WillReturnError allows to set an error for the expected method.

func (*ExpectedReplace) WithItem

func (e *ExpectedReplace) WithItem(item *memcache.Item) *ExpectedReplace

WithItem will match given expected memcache.Item to actual memcache.Item used when calling memcache.Client.Replace(). If at least one field does not match, it will return an error.

type ExpectedSet

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

ExpectedSet is used to manage *memcache.Client.Set expectations

func (*ExpectedSet) Maybe

func (e *ExpectedSet) Maybe() CallModifier

Maybe allows the expected method call to be optional. Not calling an optional method will not cause an error while asserting expectations

func (*ExpectedSet) String

func (e *ExpectedSet) String() string

String returns string representation

func (*ExpectedSet) Times

func (e *ExpectedSet) Times(n uint) CallModifier

Times indicates that the expected method should only fire the indicated number of times. Zero value is ignored and means the same as one.

func (*ExpectedSet) WillReturnError

func (e *ExpectedSet) WillReturnError(err error)

WillReturnError allows to set an error for the expected method.

func (*ExpectedSet) WithItem

func (e *ExpectedSet) WithItem(item *memcache.Item) *ExpectedSet

WithItem will match given expected memcache.Item to actual memcache.Item used when calling memcache.Client.Set(). If at least one field does not match, it will return an error.

type ExpectedTouch

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

ExpectedTouch is used to manage *memcache.Client.Touch expectations

func (*ExpectedTouch) Maybe

func (e *ExpectedTouch) Maybe() CallModifier

Maybe allows the expected method call to be optional. Not calling an optional method will not cause an error while asserting expectations

func (*ExpectedTouch) String

func (e *ExpectedTouch) String() string

String returns string representation

func (*ExpectedTouch) Times

func (e *ExpectedTouch) Times(n uint) CallModifier

Times indicates that the expected method should only fire the indicated number of times. Zero value is ignored and means the same as one.

func (*ExpectedTouch) WillReturnError

func (e *ExpectedTouch) WillReturnError(err error)

WillReturnError allows to set an error for the expected method.

func (*ExpectedTouch) WithKeyAndSeconds

func (e *ExpectedTouch) WithKeyAndSeconds(key string, seconds int32) *ExpectedTouch

WithKeyAndSeconds will match given expected key and seconds value to actual key and seconds used when calling memcache.Client.Touch(). If at least one parameter does not match, it will return an error.

Jump to

Keyboard shortcuts

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