|
@@ -2,7 +2,7 @@ package mocks
|
|
|
|
|
|
// Code generated by http://github.com/gojuno/minimock (dev). DO NOT EDIT.
|
|
|
|
|
|
-//go:generate minimock -i github.com/dmitriygnatenko/internal/interfaces.ICache -o ./mocks/i_cache_minimock.go -n ICacheMock
|
|
|
+//go:generate minimock -i github.com/dmitriygnatenko/internal/interfaces.Cache -o ./mocks/cache_minimock.go -n CacheMock
|
|
|
|
|
|
import (
|
|
|
"sync"
|
|
@@ -12,77 +12,77 @@ import (
|
|
|
"github.com/gojuno/minimock/v3"
|
|
|
)
|
|
|
|
|
|
-// ICacheMock implements interfaces.ICache
|
|
|
-type ICacheMock struct {
|
|
|
+// CacheMock implements interfaces.Cache
|
|
|
+type CacheMock struct {
|
|
|
t minimock.Tester
|
|
|
|
|
|
funcFlushAll func()
|
|
|
inspectFuncFlushAll func()
|
|
|
afterFlushAllCounter uint64
|
|
|
beforeFlushAllCounter uint64
|
|
|
- FlushAllMock mICacheMockFlushAll
|
|
|
+ FlushAllMock mCacheMockFlushAll
|
|
|
|
|
|
funcGet func(key string) (p1 interface{}, b1 bool)
|
|
|
inspectFuncGet func(key string)
|
|
|
afterGetCounter uint64
|
|
|
beforeGetCounter uint64
|
|
|
- GetMock mICacheMockGet
|
|
|
+ GetMock mCacheMockGet
|
|
|
|
|
|
funcSet func(key string, value interface{})
|
|
|
inspectFuncSet func(key string, value interface{})
|
|
|
afterSetCounter uint64
|
|
|
beforeSetCounter uint64
|
|
|
- SetMock mICacheMockSet
|
|
|
+ SetMock mCacheMockSet
|
|
|
}
|
|
|
|
|
|
-// NewICacheMock returns a mock for interfaces.ICache
|
|
|
-func NewICacheMock(t minimock.Tester) *ICacheMock {
|
|
|
- m := &ICacheMock{t: t}
|
|
|
+// NewCacheMock returns a mock for interfaces.Cache
|
|
|
+func NewCacheMock(t minimock.Tester) *CacheMock {
|
|
|
+ m := &CacheMock{t: t}
|
|
|
if controller, ok := t.(minimock.MockController); ok {
|
|
|
controller.RegisterMocker(m)
|
|
|
}
|
|
|
|
|
|
- m.FlushAllMock = mICacheMockFlushAll{mock: m}
|
|
|
+ m.FlushAllMock = mCacheMockFlushAll{mock: m}
|
|
|
|
|
|
- m.GetMock = mICacheMockGet{mock: m}
|
|
|
- m.GetMock.callArgs = []*ICacheMockGetParams{}
|
|
|
+ m.GetMock = mCacheMockGet{mock: m}
|
|
|
+ m.GetMock.callArgs = []*CacheMockGetParams{}
|
|
|
|
|
|
- m.SetMock = mICacheMockSet{mock: m}
|
|
|
- m.SetMock.callArgs = []*ICacheMockSetParams{}
|
|
|
+ m.SetMock = mCacheMockSet{mock: m}
|
|
|
+ m.SetMock.callArgs = []*CacheMockSetParams{}
|
|
|
|
|
|
return m
|
|
|
}
|
|
|
|
|
|
-type mICacheMockFlushAll struct {
|
|
|
- mock *ICacheMock
|
|
|
- defaultExpectation *ICacheMockFlushAllExpectation
|
|
|
- expectations []*ICacheMockFlushAllExpectation
|
|
|
+type mCacheMockFlushAll struct {
|
|
|
+ mock *CacheMock
|
|
|
+ defaultExpectation *CacheMockFlushAllExpectation
|
|
|
+ expectations []*CacheMockFlushAllExpectation
|
|
|
}
|
|
|
|
|
|
-// ICacheMockFlushAllExpectation specifies expectation struct of the ICache.FlushAll
|
|
|
-type ICacheMockFlushAllExpectation struct {
|
|
|
- mock *ICacheMock
|
|
|
+// CacheMockFlushAllExpectation specifies expectation struct of the Cache.FlushAll
|
|
|
+type CacheMockFlushAllExpectation struct {
|
|
|
+ mock *CacheMock
|
|
|
|
|
|
Counter uint64
|
|
|
}
|
|
|
|
|
|
-// Expect sets up expected params for ICache.FlushAll
|
|
|
-func (mmFlushAll *mICacheMockFlushAll) Expect() *mICacheMockFlushAll {
|
|
|
+// Expect sets up expected params for Cache.FlushAll
|
|
|
+func (mmFlushAll *mCacheMockFlushAll) Expect() *mCacheMockFlushAll {
|
|
|
if mmFlushAll.mock.funcFlushAll != nil {
|
|
|
- mmFlushAll.mock.t.Fatalf("ICacheMock.FlushAll mock is already set by Set")
|
|
|
+ mmFlushAll.mock.t.Fatalf("CacheMock.FlushAll mock is already set by Set")
|
|
|
}
|
|
|
|
|
|
if mmFlushAll.defaultExpectation == nil {
|
|
|
- mmFlushAll.defaultExpectation = &ICacheMockFlushAllExpectation{}
|
|
|
+ mmFlushAll.defaultExpectation = &CacheMockFlushAllExpectation{}
|
|
|
}
|
|
|
|
|
|
return mmFlushAll
|
|
|
}
|
|
|
|
|
|
-// Inspect accepts an inspector function that has same arguments as the ICache.FlushAll
|
|
|
-func (mmFlushAll *mICacheMockFlushAll) Inspect(f func()) *mICacheMockFlushAll {
|
|
|
+// Inspect accepts an inspector function that has same arguments as the Cache.FlushAll
|
|
|
+func (mmFlushAll *mCacheMockFlushAll) Inspect(f func()) *mCacheMockFlushAll {
|
|
|
if mmFlushAll.mock.inspectFuncFlushAll != nil {
|
|
|
- mmFlushAll.mock.t.Fatalf("Inspect function is already set for ICacheMock.FlushAll")
|
|
|
+ mmFlushAll.mock.t.Fatalf("Inspect function is already set for CacheMock.FlushAll")
|
|
|
}
|
|
|
|
|
|
mmFlushAll.mock.inspectFuncFlushAll = f
|
|
@@ -90,35 +90,35 @@ func (mmFlushAll *mICacheMockFlushAll) Inspect(f func()) *mICacheMockFlushAll {
|
|
|
return mmFlushAll
|
|
|
}
|
|
|
|
|
|
-// Return sets up results that will be returned by ICache.FlushAll
|
|
|
-func (mmFlushAll *mICacheMockFlushAll) Return() *ICacheMock {
|
|
|
+// Return sets up results that will be returned by Cache.FlushAll
|
|
|
+func (mmFlushAll *mCacheMockFlushAll) Return() *CacheMock {
|
|
|
if mmFlushAll.mock.funcFlushAll != nil {
|
|
|
- mmFlushAll.mock.t.Fatalf("ICacheMock.FlushAll mock is already set by Set")
|
|
|
+ mmFlushAll.mock.t.Fatalf("CacheMock.FlushAll mock is already set by Set")
|
|
|
}
|
|
|
|
|
|
if mmFlushAll.defaultExpectation == nil {
|
|
|
- mmFlushAll.defaultExpectation = &ICacheMockFlushAllExpectation{mock: mmFlushAll.mock}
|
|
|
+ mmFlushAll.defaultExpectation = &CacheMockFlushAllExpectation{mock: mmFlushAll.mock}
|
|
|
}
|
|
|
|
|
|
return mmFlushAll.mock
|
|
|
}
|
|
|
|
|
|
-//Set uses given function f to mock the ICache.FlushAll method
|
|
|
-func (mmFlushAll *mICacheMockFlushAll) Set(f func()) *ICacheMock {
|
|
|
+// Set uses given function f to mock the Cache.FlushAll method
|
|
|
+func (mmFlushAll *mCacheMockFlushAll) Set(f func()) *CacheMock {
|
|
|
if mmFlushAll.defaultExpectation != nil {
|
|
|
- mmFlushAll.mock.t.Fatalf("Default expectation is already set for the ICache.FlushAll method")
|
|
|
+ mmFlushAll.mock.t.Fatalf("Default expectation is already set for the Cache.FlushAll method")
|
|
|
}
|
|
|
|
|
|
if len(mmFlushAll.expectations) > 0 {
|
|
|
- mmFlushAll.mock.t.Fatalf("Some expectations are already set for the ICache.FlushAll method")
|
|
|
+ mmFlushAll.mock.t.Fatalf("Some expectations are already set for the Cache.FlushAll method")
|
|
|
}
|
|
|
|
|
|
mmFlushAll.mock.funcFlushAll = f
|
|
|
return mmFlushAll.mock
|
|
|
}
|
|
|
|
|
|
-// FlushAll implements interfaces.ICache
|
|
|
-func (mmFlushAll *ICacheMock) FlushAll() {
|
|
|
+// FlushAll implements interfaces.Cache
|
|
|
+func (mmFlushAll *CacheMock) FlushAll() {
|
|
|
mm_atomic.AddUint64(&mmFlushAll.beforeFlushAllCounter, 1)
|
|
|
defer mm_atomic.AddUint64(&mmFlushAll.afterFlushAllCounter, 1)
|
|
|
|
|
@@ -136,23 +136,23 @@ func (mmFlushAll *ICacheMock) FlushAll() {
|
|
|
mmFlushAll.funcFlushAll()
|
|
|
return
|
|
|
}
|
|
|
- mmFlushAll.t.Fatalf("Unexpected call to ICacheMock.FlushAll.")
|
|
|
+ mmFlushAll.t.Fatalf("Unexpected call to CacheMock.FlushAll.")
|
|
|
|
|
|
}
|
|
|
|
|
|
-// FlushAllAfterCounter returns a count of finished ICacheMock.FlushAll invocations
|
|
|
-func (mmFlushAll *ICacheMock) FlushAllAfterCounter() uint64 {
|
|
|
+// FlushAllAfterCounter returns a count of finished CacheMock.FlushAll invocations
|
|
|
+func (mmFlushAll *CacheMock) FlushAllAfterCounter() uint64 {
|
|
|
return mm_atomic.LoadUint64(&mmFlushAll.afterFlushAllCounter)
|
|
|
}
|
|
|
|
|
|
-// FlushAllBeforeCounter returns a count of ICacheMock.FlushAll invocations
|
|
|
-func (mmFlushAll *ICacheMock) FlushAllBeforeCounter() uint64 {
|
|
|
+// FlushAllBeforeCounter returns a count of CacheMock.FlushAll invocations
|
|
|
+func (mmFlushAll *CacheMock) FlushAllBeforeCounter() uint64 {
|
|
|
return mm_atomic.LoadUint64(&mmFlushAll.beforeFlushAllCounter)
|
|
|
}
|
|
|
|
|
|
// MinimockFlushAllDone returns true if the count of the FlushAll invocations corresponds
|
|
|
// the number of defined expectations
|
|
|
-func (m *ICacheMock) MinimockFlushAllDone() bool {
|
|
|
+func (m *CacheMock) MinimockFlushAllDone() bool {
|
|
|
for _, e := range m.FlushAllMock.expectations {
|
|
|
if mm_atomic.LoadUint64(&e.Counter) < 1 {
|
|
|
return false
|
|
@@ -171,62 +171,62 @@ func (m *ICacheMock) MinimockFlushAllDone() bool {
|
|
|
}
|
|
|
|
|
|
// MinimockFlushAllInspect logs each unmet expectation
|
|
|
-func (m *ICacheMock) MinimockFlushAllInspect() {
|
|
|
+func (m *CacheMock) MinimockFlushAllInspect() {
|
|
|
for _, e := range m.FlushAllMock.expectations {
|
|
|
if mm_atomic.LoadUint64(&e.Counter) < 1 {
|
|
|
- m.t.Error("Expected call to ICacheMock.FlushAll")
|
|
|
+ m.t.Error("Expected call to CacheMock.FlushAll")
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// if default expectation was set then invocations count should be greater than zero
|
|
|
if m.FlushAllMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterFlushAllCounter) < 1 {
|
|
|
- m.t.Error("Expected call to ICacheMock.FlushAll")
|
|
|
+ m.t.Error("Expected call to CacheMock.FlushAll")
|
|
|
}
|
|
|
// if func was set then invocations count should be greater than zero
|
|
|
if m.funcFlushAll != nil && mm_atomic.LoadUint64(&m.afterFlushAllCounter) < 1 {
|
|
|
- m.t.Error("Expected call to ICacheMock.FlushAll")
|
|
|
+ m.t.Error("Expected call to CacheMock.FlushAll")
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-type mICacheMockGet struct {
|
|
|
- mock *ICacheMock
|
|
|
- defaultExpectation *ICacheMockGetExpectation
|
|
|
- expectations []*ICacheMockGetExpectation
|
|
|
+type mCacheMockGet struct {
|
|
|
+ mock *CacheMock
|
|
|
+ defaultExpectation *CacheMockGetExpectation
|
|
|
+ expectations []*CacheMockGetExpectation
|
|
|
|
|
|
- callArgs []*ICacheMockGetParams
|
|
|
+ callArgs []*CacheMockGetParams
|
|
|
mutex sync.RWMutex
|
|
|
}
|
|
|
|
|
|
-// ICacheMockGetExpectation specifies expectation struct of the ICache.Get
|
|
|
-type ICacheMockGetExpectation struct {
|
|
|
- mock *ICacheMock
|
|
|
- params *ICacheMockGetParams
|
|
|
- results *ICacheMockGetResults
|
|
|
+// CacheMockGetExpectation specifies expectation struct of the Cache.Get
|
|
|
+type CacheMockGetExpectation struct {
|
|
|
+ mock *CacheMock
|
|
|
+ params *CacheMockGetParams
|
|
|
+ results *CacheMockGetResults
|
|
|
Counter uint64
|
|
|
}
|
|
|
|
|
|
-// ICacheMockGetParams contains parameters of the ICache.Get
|
|
|
-type ICacheMockGetParams struct {
|
|
|
+// CacheMockGetParams contains parameters of the Cache.Get
|
|
|
+type CacheMockGetParams struct {
|
|
|
key string
|
|
|
}
|
|
|
|
|
|
-// ICacheMockGetResults contains results of the ICache.Get
|
|
|
-type ICacheMockGetResults struct {
|
|
|
+// CacheMockGetResults contains results of the Cache.Get
|
|
|
+type CacheMockGetResults struct {
|
|
|
p1 interface{}
|
|
|
b1 bool
|
|
|
}
|
|
|
|
|
|
-// Expect sets up expected params for ICache.Get
|
|
|
-func (mmGet *mICacheMockGet) Expect(key string) *mICacheMockGet {
|
|
|
+// Expect sets up expected params for Cache.Get
|
|
|
+func (mmGet *mCacheMockGet) Expect(key string) *mCacheMockGet {
|
|
|
if mmGet.mock.funcGet != nil {
|
|
|
- mmGet.mock.t.Fatalf("ICacheMock.Get mock is already set by Set")
|
|
|
+ mmGet.mock.t.Fatalf("CacheMock.Get mock is already set by Set")
|
|
|
}
|
|
|
|
|
|
if mmGet.defaultExpectation == nil {
|
|
|
- mmGet.defaultExpectation = &ICacheMockGetExpectation{}
|
|
|
+ mmGet.defaultExpectation = &CacheMockGetExpectation{}
|
|
|
}
|
|
|
|
|
|
- mmGet.defaultExpectation.params = &ICacheMockGetParams{key}
|
|
|
+ mmGet.defaultExpectation.params = &CacheMockGetParams{key}
|
|
|
for _, e := range mmGet.expectations {
|
|
|
if minimock.Equal(e.params, mmGet.defaultExpectation.params) {
|
|
|
mmGet.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGet.defaultExpectation.params)
|
|
@@ -236,10 +236,10 @@ func (mmGet *mICacheMockGet) Expect(key string) *mICacheMockGet {
|
|
|
return mmGet
|
|
|
}
|
|
|
|
|
|
-// Inspect accepts an inspector function that has same arguments as the ICache.Get
|
|
|
-func (mmGet *mICacheMockGet) Inspect(f func(key string)) *mICacheMockGet {
|
|
|
+// Inspect accepts an inspector function that has same arguments as the Cache.Get
|
|
|
+func (mmGet *mCacheMockGet) Inspect(f func(key string)) *mCacheMockGet {
|
|
|
if mmGet.mock.inspectFuncGet != nil {
|
|
|
- mmGet.mock.t.Fatalf("Inspect function is already set for ICacheMock.Get")
|
|
|
+ mmGet.mock.t.Fatalf("Inspect function is already set for CacheMock.Get")
|
|
|
}
|
|
|
|
|
|
mmGet.mock.inspectFuncGet = f
|
|
@@ -247,56 +247,56 @@ func (mmGet *mICacheMockGet) Inspect(f func(key string)) *mICacheMockGet {
|
|
|
return mmGet
|
|
|
}
|
|
|
|
|
|
-// Return sets up results that will be returned by ICache.Get
|
|
|
-func (mmGet *mICacheMockGet) Return(p1 interface{}, b1 bool) *ICacheMock {
|
|
|
+// Return sets up results that will be returned by Cache.Get
|
|
|
+func (mmGet *mCacheMockGet) Return(p1 interface{}, b1 bool) *CacheMock {
|
|
|
if mmGet.mock.funcGet != nil {
|
|
|
- mmGet.mock.t.Fatalf("ICacheMock.Get mock is already set by Set")
|
|
|
+ mmGet.mock.t.Fatalf("CacheMock.Get mock is already set by Set")
|
|
|
}
|
|
|
|
|
|
if mmGet.defaultExpectation == nil {
|
|
|
- mmGet.defaultExpectation = &ICacheMockGetExpectation{mock: mmGet.mock}
|
|
|
+ mmGet.defaultExpectation = &CacheMockGetExpectation{mock: mmGet.mock}
|
|
|
}
|
|
|
- mmGet.defaultExpectation.results = &ICacheMockGetResults{p1, b1}
|
|
|
+ mmGet.defaultExpectation.results = &CacheMockGetResults{p1, b1}
|
|
|
return mmGet.mock
|
|
|
}
|
|
|
|
|
|
-//Set uses given function f to mock the ICache.Get method
|
|
|
-func (mmGet *mICacheMockGet) Set(f func(key string) (p1 interface{}, b1 bool)) *ICacheMock {
|
|
|
+// Set uses given function f to mock the Cache.Get method
|
|
|
+func (mmGet *mCacheMockGet) Set(f func(key string) (p1 interface{}, b1 bool)) *CacheMock {
|
|
|
if mmGet.defaultExpectation != nil {
|
|
|
- mmGet.mock.t.Fatalf("Default expectation is already set for the ICache.Get method")
|
|
|
+ mmGet.mock.t.Fatalf("Default expectation is already set for the Cache.Get method")
|
|
|
}
|
|
|
|
|
|
if len(mmGet.expectations) > 0 {
|
|
|
- mmGet.mock.t.Fatalf("Some expectations are already set for the ICache.Get method")
|
|
|
+ mmGet.mock.t.Fatalf("Some expectations are already set for the Cache.Get method")
|
|
|
}
|
|
|
|
|
|
mmGet.mock.funcGet = f
|
|
|
return mmGet.mock
|
|
|
}
|
|
|
|
|
|
-// When sets expectation for the ICache.Get which will trigger the result defined by the following
|
|
|
+// When sets expectation for the Cache.Get which will trigger the result defined by the following
|
|
|
// Then helper
|
|
|
-func (mmGet *mICacheMockGet) When(key string) *ICacheMockGetExpectation {
|
|
|
+func (mmGet *mCacheMockGet) When(key string) *CacheMockGetExpectation {
|
|
|
if mmGet.mock.funcGet != nil {
|
|
|
- mmGet.mock.t.Fatalf("ICacheMock.Get mock is already set by Set")
|
|
|
+ mmGet.mock.t.Fatalf("CacheMock.Get mock is already set by Set")
|
|
|
}
|
|
|
|
|
|
- expectation := &ICacheMockGetExpectation{
|
|
|
+ expectation := &CacheMockGetExpectation{
|
|
|
mock: mmGet.mock,
|
|
|
- params: &ICacheMockGetParams{key},
|
|
|
+ params: &CacheMockGetParams{key},
|
|
|
}
|
|
|
mmGet.expectations = append(mmGet.expectations, expectation)
|
|
|
return expectation
|
|
|
}
|
|
|
|
|
|
-// Then sets up ICache.Get return parameters for the expectation previously defined by the When method
|
|
|
-func (e *ICacheMockGetExpectation) Then(p1 interface{}, b1 bool) *ICacheMock {
|
|
|
- e.results = &ICacheMockGetResults{p1, b1}
|
|
|
+// Then sets up Cache.Get return parameters for the expectation previously defined by the When method
|
|
|
+func (e *CacheMockGetExpectation) Then(p1 interface{}, b1 bool) *CacheMock {
|
|
|
+ e.results = &CacheMockGetResults{p1, b1}
|
|
|
return e.mock
|
|
|
}
|
|
|
|
|
|
-// Get implements interfaces.ICache
|
|
|
-func (mmGet *ICacheMock) Get(key string) (p1 interface{}, b1 bool) {
|
|
|
+// Get implements interfaces.Cache
|
|
|
+func (mmGet *CacheMock) Get(key string) (p1 interface{}, b1 bool) {
|
|
|
mm_atomic.AddUint64(&mmGet.beforeGetCounter, 1)
|
|
|
defer mm_atomic.AddUint64(&mmGet.afterGetCounter, 1)
|
|
|
|
|
@@ -304,7 +304,7 @@ func (mmGet *ICacheMock) Get(key string) (p1 interface{}, b1 bool) {
|
|
|
mmGet.inspectFuncGet(key)
|
|
|
}
|
|
|
|
|
|
- mm_params := &ICacheMockGetParams{key}
|
|
|
+ mm_params := &CacheMockGetParams{key}
|
|
|
|
|
|
// Record call args
|
|
|
mmGet.GetMock.mutex.Lock()
|
|
@@ -321,40 +321,40 @@ func (mmGet *ICacheMock) Get(key string) (p1 interface{}, b1 bool) {
|
|
|
if mmGet.GetMock.defaultExpectation != nil {
|
|
|
mm_atomic.AddUint64(&mmGet.GetMock.defaultExpectation.Counter, 1)
|
|
|
mm_want := mmGet.GetMock.defaultExpectation.params
|
|
|
- mm_got := ICacheMockGetParams{key}
|
|
|
+ mm_got := CacheMockGetParams{key}
|
|
|
if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
|
|
|
- mmGet.t.Errorf("ICacheMock.Get got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
|
|
|
+ mmGet.t.Errorf("CacheMock.Get got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
|
|
|
}
|
|
|
|
|
|
mm_results := mmGet.GetMock.defaultExpectation.results
|
|
|
if mm_results == nil {
|
|
|
- mmGet.t.Fatal("No results are set for the ICacheMock.Get")
|
|
|
+ mmGet.t.Fatal("No results are set for the CacheMock.Get")
|
|
|
}
|
|
|
return (*mm_results).p1, (*mm_results).b1
|
|
|
}
|
|
|
if mmGet.funcGet != nil {
|
|
|
return mmGet.funcGet(key)
|
|
|
}
|
|
|
- mmGet.t.Fatalf("Unexpected call to ICacheMock.Get. %v", key)
|
|
|
+ mmGet.t.Fatalf("Unexpected call to CacheMock.Get. %v", key)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-// GetAfterCounter returns a count of finished ICacheMock.Get invocations
|
|
|
-func (mmGet *ICacheMock) GetAfterCounter() uint64 {
|
|
|
+// GetAfterCounter returns a count of finished CacheMock.Get invocations
|
|
|
+func (mmGet *CacheMock) GetAfterCounter() uint64 {
|
|
|
return mm_atomic.LoadUint64(&mmGet.afterGetCounter)
|
|
|
}
|
|
|
|
|
|
-// GetBeforeCounter returns a count of ICacheMock.Get invocations
|
|
|
-func (mmGet *ICacheMock) GetBeforeCounter() uint64 {
|
|
|
+// GetBeforeCounter returns a count of CacheMock.Get invocations
|
|
|
+func (mmGet *CacheMock) GetBeforeCounter() uint64 {
|
|
|
return mm_atomic.LoadUint64(&mmGet.beforeGetCounter)
|
|
|
}
|
|
|
|
|
|
-// Calls returns a list of arguments used in each call to ICacheMock.Get.
|
|
|
+// Calls returns a list of arguments used in each call to CacheMock.Get.
|
|
|
// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
|
|
|
-func (mmGet *mICacheMockGet) Calls() []*ICacheMockGetParams {
|
|
|
+func (mmGet *mCacheMockGet) Calls() []*CacheMockGetParams {
|
|
|
mmGet.mutex.RLock()
|
|
|
|
|
|
- argCopy := make([]*ICacheMockGetParams, len(mmGet.callArgs))
|
|
|
+ argCopy := make([]*CacheMockGetParams, len(mmGet.callArgs))
|
|
|
copy(argCopy, mmGet.callArgs)
|
|
|
|
|
|
mmGet.mutex.RUnlock()
|
|
@@ -364,7 +364,7 @@ func (mmGet *mICacheMockGet) Calls() []*ICacheMockGetParams {
|
|
|
|
|
|
// MinimockGetDone returns true if the count of the Get invocations corresponds
|
|
|
// the number of defined expectations
|
|
|
-func (m *ICacheMock) MinimockGetDone() bool {
|
|
|
+func (m *CacheMock) MinimockGetDone() bool {
|
|
|
for _, e := range m.GetMock.expectations {
|
|
|
if mm_atomic.LoadUint64(&e.Counter) < 1 {
|
|
|
return false
|
|
@@ -383,61 +383,61 @@ func (m *ICacheMock) MinimockGetDone() bool {
|
|
|
}
|
|
|
|
|
|
// MinimockGetInspect logs each unmet expectation
|
|
|
-func (m *ICacheMock) MinimockGetInspect() {
|
|
|
+func (m *CacheMock) MinimockGetInspect() {
|
|
|
for _, e := range m.GetMock.expectations {
|
|
|
if mm_atomic.LoadUint64(&e.Counter) < 1 {
|
|
|
- m.t.Errorf("Expected call to ICacheMock.Get with params: %#v", *e.params)
|
|
|
+ m.t.Errorf("Expected call to CacheMock.Get with params: %#v", *e.params)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// if default expectation was set then invocations count should be greater than zero
|
|
|
if m.GetMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetCounter) < 1 {
|
|
|
if m.GetMock.defaultExpectation.params == nil {
|
|
|
- m.t.Error("Expected call to ICacheMock.Get")
|
|
|
+ m.t.Error("Expected call to CacheMock.Get")
|
|
|
} else {
|
|
|
- m.t.Errorf("Expected call to ICacheMock.Get with params: %#v", *m.GetMock.defaultExpectation.params)
|
|
|
+ m.t.Errorf("Expected call to CacheMock.Get with params: %#v", *m.GetMock.defaultExpectation.params)
|
|
|
}
|
|
|
}
|
|
|
// if func was set then invocations count should be greater than zero
|
|
|
if m.funcGet != nil && mm_atomic.LoadUint64(&m.afterGetCounter) < 1 {
|
|
|
- m.t.Error("Expected call to ICacheMock.Get")
|
|
|
+ m.t.Error("Expected call to CacheMock.Get")
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-type mICacheMockSet struct {
|
|
|
- mock *ICacheMock
|
|
|
- defaultExpectation *ICacheMockSetExpectation
|
|
|
- expectations []*ICacheMockSetExpectation
|
|
|
+type mCacheMockSet struct {
|
|
|
+ mock *CacheMock
|
|
|
+ defaultExpectation *CacheMockSetExpectation
|
|
|
+ expectations []*CacheMockSetExpectation
|
|
|
|
|
|
- callArgs []*ICacheMockSetParams
|
|
|
+ callArgs []*CacheMockSetParams
|
|
|
mutex sync.RWMutex
|
|
|
}
|
|
|
|
|
|
-// ICacheMockSetExpectation specifies expectation struct of the ICache.Set
|
|
|
-type ICacheMockSetExpectation struct {
|
|
|
- mock *ICacheMock
|
|
|
- params *ICacheMockSetParams
|
|
|
+// CacheMockSetExpectation specifies expectation struct of the Cache.Set
|
|
|
+type CacheMockSetExpectation struct {
|
|
|
+ mock *CacheMock
|
|
|
+ params *CacheMockSetParams
|
|
|
|
|
|
Counter uint64
|
|
|
}
|
|
|
|
|
|
-// ICacheMockSetParams contains parameters of the ICache.Set
|
|
|
-type ICacheMockSetParams struct {
|
|
|
+// CacheMockSetParams contains parameters of the Cache.Set
|
|
|
+type CacheMockSetParams struct {
|
|
|
key string
|
|
|
value interface{}
|
|
|
}
|
|
|
|
|
|
-// Expect sets up expected params for ICache.Set
|
|
|
-func (mmSet *mICacheMockSet) Expect(key string, value interface{}) *mICacheMockSet {
|
|
|
+// Expect sets up expected params for Cache.Set
|
|
|
+func (mmSet *mCacheMockSet) Expect(key string, value interface{}) *mCacheMockSet {
|
|
|
if mmSet.mock.funcSet != nil {
|
|
|
- mmSet.mock.t.Fatalf("ICacheMock.Set mock is already set by Set")
|
|
|
+ mmSet.mock.t.Fatalf("CacheMock.Set mock is already set by Set")
|
|
|
}
|
|
|
|
|
|
if mmSet.defaultExpectation == nil {
|
|
|
- mmSet.defaultExpectation = &ICacheMockSetExpectation{}
|
|
|
+ mmSet.defaultExpectation = &CacheMockSetExpectation{}
|
|
|
}
|
|
|
|
|
|
- mmSet.defaultExpectation.params = &ICacheMockSetParams{key, value}
|
|
|
+ mmSet.defaultExpectation.params = &CacheMockSetParams{key, value}
|
|
|
for _, e := range mmSet.expectations {
|
|
|
if minimock.Equal(e.params, mmSet.defaultExpectation.params) {
|
|
|
mmSet.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmSet.defaultExpectation.params)
|
|
@@ -447,10 +447,10 @@ func (mmSet *mICacheMockSet) Expect(key string, value interface{}) *mICacheMockS
|
|
|
return mmSet
|
|
|
}
|
|
|
|
|
|
-// Inspect accepts an inspector function that has same arguments as the ICache.Set
|
|
|
-func (mmSet *mICacheMockSet) Inspect(f func(key string, value interface{})) *mICacheMockSet {
|
|
|
+// Inspect accepts an inspector function that has same arguments as the Cache.Set
|
|
|
+func (mmSet *mCacheMockSet) Inspect(f func(key string, value interface{})) *mCacheMockSet {
|
|
|
if mmSet.mock.inspectFuncSet != nil {
|
|
|
- mmSet.mock.t.Fatalf("Inspect function is already set for ICacheMock.Set")
|
|
|
+ mmSet.mock.t.Fatalf("Inspect function is already set for CacheMock.Set")
|
|
|
}
|
|
|
|
|
|
mmSet.mock.inspectFuncSet = f
|
|
@@ -458,35 +458,35 @@ func (mmSet *mICacheMockSet) Inspect(f func(key string, value interface{})) *mIC
|
|
|
return mmSet
|
|
|
}
|
|
|
|
|
|
-// Return sets up results that will be returned by ICache.Set
|
|
|
-func (mmSet *mICacheMockSet) Return() *ICacheMock {
|
|
|
+// Return sets up results that will be returned by Cache.Set
|
|
|
+func (mmSet *mCacheMockSet) Return() *CacheMock {
|
|
|
if mmSet.mock.funcSet != nil {
|
|
|
- mmSet.mock.t.Fatalf("ICacheMock.Set mock is already set by Set")
|
|
|
+ mmSet.mock.t.Fatalf("CacheMock.Set mock is already set by Set")
|
|
|
}
|
|
|
|
|
|
if mmSet.defaultExpectation == nil {
|
|
|
- mmSet.defaultExpectation = &ICacheMockSetExpectation{mock: mmSet.mock}
|
|
|
+ mmSet.defaultExpectation = &CacheMockSetExpectation{mock: mmSet.mock}
|
|
|
}
|
|
|
|
|
|
return mmSet.mock
|
|
|
}
|
|
|
|
|
|
-//Set uses given function f to mock the ICache.Set method
|
|
|
-func (mmSet *mICacheMockSet) Set(f func(key string, value interface{})) *ICacheMock {
|
|
|
+// Set uses given function f to mock the Cache.Set method
|
|
|
+func (mmSet *mCacheMockSet) Set(f func(key string, value interface{})) *CacheMock {
|
|
|
if mmSet.defaultExpectation != nil {
|
|
|
- mmSet.mock.t.Fatalf("Default expectation is already set for the ICache.Set method")
|
|
|
+ mmSet.mock.t.Fatalf("Default expectation is already set for the Cache.Set method")
|
|
|
}
|
|
|
|
|
|
if len(mmSet.expectations) > 0 {
|
|
|
- mmSet.mock.t.Fatalf("Some expectations are already set for the ICache.Set method")
|
|
|
+ mmSet.mock.t.Fatalf("Some expectations are already set for the Cache.Set method")
|
|
|
}
|
|
|
|
|
|
mmSet.mock.funcSet = f
|
|
|
return mmSet.mock
|
|
|
}
|
|
|
|
|
|
-// Set implements interfaces.ICache
|
|
|
-func (mmSet *ICacheMock) Set(key string, value interface{}) {
|
|
|
+// Set implements interfaces.Cache
|
|
|
+func (mmSet *CacheMock) Set(key string, value interface{}) {
|
|
|
mm_atomic.AddUint64(&mmSet.beforeSetCounter, 1)
|
|
|
defer mm_atomic.AddUint64(&mmSet.afterSetCounter, 1)
|
|
|
|
|
@@ -494,7 +494,7 @@ func (mmSet *ICacheMock) Set(key string, value interface{}) {
|
|
|
mmSet.inspectFuncSet(key, value)
|
|
|
}
|
|
|
|
|
|
- mm_params := &ICacheMockSetParams{key, value}
|
|
|
+ mm_params := &CacheMockSetParams{key, value}
|
|
|
|
|
|
// Record call args
|
|
|
mmSet.SetMock.mutex.Lock()
|
|
@@ -511,9 +511,9 @@ func (mmSet *ICacheMock) Set(key string, value interface{}) {
|
|
|
if mmSet.SetMock.defaultExpectation != nil {
|
|
|
mm_atomic.AddUint64(&mmSet.SetMock.defaultExpectation.Counter, 1)
|
|
|
mm_want := mmSet.SetMock.defaultExpectation.params
|
|
|
- mm_got := ICacheMockSetParams{key, value}
|
|
|
+ mm_got := CacheMockSetParams{key, value}
|
|
|
if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
|
|
|
- mmSet.t.Errorf("ICacheMock.Set got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
|
|
|
+ mmSet.t.Errorf("CacheMock.Set got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
|
|
|
}
|
|
|
|
|
|
return
|
|
@@ -523,26 +523,26 @@ func (mmSet *ICacheMock) Set(key string, value interface{}) {
|
|
|
mmSet.funcSet(key, value)
|
|
|
return
|
|
|
}
|
|
|
- mmSet.t.Fatalf("Unexpected call to ICacheMock.Set. %v %v", key, value)
|
|
|
+ mmSet.t.Fatalf("Unexpected call to CacheMock.Set. %v %v", key, value)
|
|
|
|
|
|
}
|
|
|
|
|
|
-// SetAfterCounter returns a count of finished ICacheMock.Set invocations
|
|
|
-func (mmSet *ICacheMock) SetAfterCounter() uint64 {
|
|
|
+// SetAfterCounter returns a count of finished CacheMock.Set invocations
|
|
|
+func (mmSet *CacheMock) SetAfterCounter() uint64 {
|
|
|
return mm_atomic.LoadUint64(&mmSet.afterSetCounter)
|
|
|
}
|
|
|
|
|
|
-// SetBeforeCounter returns a count of ICacheMock.Set invocations
|
|
|
-func (mmSet *ICacheMock) SetBeforeCounter() uint64 {
|
|
|
+// SetBeforeCounter returns a count of CacheMock.Set invocations
|
|
|
+func (mmSet *CacheMock) SetBeforeCounter() uint64 {
|
|
|
return mm_atomic.LoadUint64(&mmSet.beforeSetCounter)
|
|
|
}
|
|
|
|
|
|
-// Calls returns a list of arguments used in each call to ICacheMock.Set.
|
|
|
+// Calls returns a list of arguments used in each call to CacheMock.Set.
|
|
|
// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
|
|
|
-func (mmSet *mICacheMockSet) Calls() []*ICacheMockSetParams {
|
|
|
+func (mmSet *mCacheMockSet) Calls() []*CacheMockSetParams {
|
|
|
mmSet.mutex.RLock()
|
|
|
|
|
|
- argCopy := make([]*ICacheMockSetParams, len(mmSet.callArgs))
|
|
|
+ argCopy := make([]*CacheMockSetParams, len(mmSet.callArgs))
|
|
|
copy(argCopy, mmSet.callArgs)
|
|
|
|
|
|
mmSet.mutex.RUnlock()
|
|
@@ -552,7 +552,7 @@ func (mmSet *mICacheMockSet) Calls() []*ICacheMockSetParams {
|
|
|
|
|
|
// MinimockSetDone returns true if the count of the Set invocations corresponds
|
|
|
// the number of defined expectations
|
|
|
-func (m *ICacheMock) MinimockSetDone() bool {
|
|
|
+func (m *CacheMock) MinimockSetDone() bool {
|
|
|
for _, e := range m.SetMock.expectations {
|
|
|
if mm_atomic.LoadUint64(&e.Counter) < 1 {
|
|
|
return false
|
|
@@ -571,29 +571,29 @@ func (m *ICacheMock) MinimockSetDone() bool {
|
|
|
}
|
|
|
|
|
|
// MinimockSetInspect logs each unmet expectation
|
|
|
-func (m *ICacheMock) MinimockSetInspect() {
|
|
|
+func (m *CacheMock) MinimockSetInspect() {
|
|
|
for _, e := range m.SetMock.expectations {
|
|
|
if mm_atomic.LoadUint64(&e.Counter) < 1 {
|
|
|
- m.t.Errorf("Expected call to ICacheMock.Set with params: %#v", *e.params)
|
|
|
+ m.t.Errorf("Expected call to CacheMock.Set with params: %#v", *e.params)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// if default expectation was set then invocations count should be greater than zero
|
|
|
if m.SetMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterSetCounter) < 1 {
|
|
|
if m.SetMock.defaultExpectation.params == nil {
|
|
|
- m.t.Error("Expected call to ICacheMock.Set")
|
|
|
+ m.t.Error("Expected call to CacheMock.Set")
|
|
|
} else {
|
|
|
- m.t.Errorf("Expected call to ICacheMock.Set with params: %#v", *m.SetMock.defaultExpectation.params)
|
|
|
+ m.t.Errorf("Expected call to CacheMock.Set with params: %#v", *m.SetMock.defaultExpectation.params)
|
|
|
}
|
|
|
}
|
|
|
// if func was set then invocations count should be greater than zero
|
|
|
if m.funcSet != nil && mm_atomic.LoadUint64(&m.afterSetCounter) < 1 {
|
|
|
- m.t.Error("Expected call to ICacheMock.Set")
|
|
|
+ m.t.Error("Expected call to CacheMock.Set")
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// MinimockFinish checks that all mocked methods have been called the expected number of times
|
|
|
-func (m *ICacheMock) MinimockFinish() {
|
|
|
+func (m *CacheMock) MinimockFinish() {
|
|
|
if !m.minimockDone() {
|
|
|
m.MinimockFlushAllInspect()
|
|
|
|
|
@@ -605,7 +605,7 @@ func (m *ICacheMock) MinimockFinish() {
|
|
|
}
|
|
|
|
|
|
// MinimockWait waits for all mocked methods to be called the expected number of times
|
|
|
-func (m *ICacheMock) MinimockWait(timeout mm_time.Duration) {
|
|
|
+func (m *CacheMock) MinimockWait(timeout mm_time.Duration) {
|
|
|
timeoutCh := mm_time.After(timeout)
|
|
|
for {
|
|
|
if m.minimockDone() {
|
|
@@ -620,7 +620,7 @@ func (m *ICacheMock) MinimockWait(timeout mm_time.Duration) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-func (m *ICacheMock) minimockDone() bool {
|
|
|
+func (m *CacheMock) minimockDone() bool {
|
|
|
done := true
|
|
|
return done &&
|
|
|
m.MinimockFlushAllDone() &&
|