Documentation
¶
Index ¶
- type Cacher
- type CacherMock
- func (mock *CacherMock) Expire(in1 string) error
- func (mock *CacherMock) ExpireCalls() []struct{ ... }
- func (mock *CacherMock) Get(in1 string) ([]byte, error)
- func (mock *CacherMock) GetCalls() []struct{ ... }
- func (mock *CacherMock) Put(in1 string, in2 time.Time, in3 []byte) error
- func (mock *CacherMock) PutCalls() []struct{ ... }
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cacher ¶
type Cacher interface { Get(string) ([]byte, error) Put(string, time.Time, []byte) error Expire(string) error }
Cacher defines the interface for a caching system so it can be customised.
type CacherMock ¶
type CacherMock struct { // ExpireFunc mocks the Expire method. ExpireFunc func(in1 string) error // GetFunc mocks the Get method. GetFunc func(in1 string) ([]byte, error) // PutFunc mocks the Put method. PutFunc func(in1 string, in2 time.Time, in3 []byte) error // contains filtered or unexported fields }
CacherMock is a mock implementation of Cacher.
func TestSomethingThatUsesCacher(t *testing.T) { // make and configure a mocked Cacher mockedCacher := &CacherMock{ ExpireFunc: func(in1 string) error { panic("TODO: mock out the Expire method") }, GetFunc: func(in1 string) ([]byte, error) { panic("TODO: mock out the Get method") }, PutFunc: func(in1 string, in2 time.Time, in3 []byte) error { panic("TODO: mock out the Put method") }, } // TODO: use mockedCacher in code that requires Cacher // and then make assertions. }
func (*CacherMock) Expire ¶
func (mock *CacherMock) Expire(in1 string) error
Expire calls ExpireFunc.
func (*CacherMock) ExpireCalls ¶
func (mock *CacherMock) ExpireCalls() []struct { In1 string }
ExpireCalls gets all the calls that were made to Expire. Check the length with:
len(mockedCacher.ExpireCalls())
func (*CacherMock) GetCalls ¶
func (mock *CacherMock) GetCalls() []struct { In1 string }
GetCalls gets all the calls that were made to Get. Check the length with:
len(mockedCacher.GetCalls())
Click to show internal directories.
Click to hide internal directories.