123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669 |
- // Code generated by http://github.com/gojuno/minimock (v3.3.13). DO NOT EDIT.
- package mocks
- //go:generate minimock -i git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/services/handler.CacheService -o cache_service_minimock.go -n CacheServiceMock -p mocks
- import (
- "sync"
- mm_atomic "sync/atomic"
- mm_time "time"
- "github.com/gojuno/minimock/v3"
- )
- // CacheServiceMock implements handler.CacheService
- type CacheServiceMock struct {
- t minimock.Tester
- finishOnce sync.Once
- funcGet func(key string) (p1 interface{}, b1 bool)
- inspectFuncGet func(key string)
- afterGetCounter uint64
- beforeGetCounter uint64
- GetMock mCacheServiceMockGet
- funcSet func(key string, value interface{})
- inspectFuncSet func(key string, value interface{})
- afterSetCounter uint64
- beforeSetCounter uint64
- SetMock mCacheServiceMockSet
- }
- // NewCacheServiceMock returns a mock for handler.CacheService
- func NewCacheServiceMock(t minimock.Tester) *CacheServiceMock {
- m := &CacheServiceMock{t: t}
- if controller, ok := t.(minimock.MockController); ok {
- controller.RegisterMocker(m)
- }
- m.GetMock = mCacheServiceMockGet{mock: m}
- m.GetMock.callArgs = []*CacheServiceMockGetParams{}
- m.SetMock = mCacheServiceMockSet{mock: m}
- m.SetMock.callArgs = []*CacheServiceMockSetParams{}
- t.Cleanup(m.MinimockFinish)
- return m
- }
- type mCacheServiceMockGet struct {
- optional bool
- mock *CacheServiceMock
- defaultExpectation *CacheServiceMockGetExpectation
- expectations []*CacheServiceMockGetExpectation
- callArgs []*CacheServiceMockGetParams
- mutex sync.RWMutex
- expectedInvocations uint64
- }
- // CacheServiceMockGetExpectation specifies expectation struct of the CacheService.Get
- type CacheServiceMockGetExpectation struct {
- mock *CacheServiceMock
- params *CacheServiceMockGetParams
- paramPtrs *CacheServiceMockGetParamPtrs
- results *CacheServiceMockGetResults
- Counter uint64
- }
- // CacheServiceMockGetParams contains parameters of the CacheService.Get
- type CacheServiceMockGetParams struct {
- key string
- }
- // CacheServiceMockGetParamPtrs contains pointers to parameters of the CacheService.Get
- type CacheServiceMockGetParamPtrs struct {
- key *string
- }
- // CacheServiceMockGetResults contains results of the CacheService.Get
- type CacheServiceMockGetResults struct {
- p1 interface{}
- b1 bool
- }
- // Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
- // the test will fail minimock's automatic final call check if the mocked method was not called at least once.
- // Optional() makes method check to work in '0 or more' mode.
- // It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
- // catch the problems when the expected method call is totally skipped during test run.
- func (mmGet *mCacheServiceMockGet) Optional() *mCacheServiceMockGet {
- mmGet.optional = true
- return mmGet
- }
- // Expect sets up expected params for CacheService.Get
- func (mmGet *mCacheServiceMockGet) Expect(key string) *mCacheServiceMockGet {
- if mmGet.mock.funcGet != nil {
- mmGet.mock.t.Fatalf("CacheServiceMock.Get mock is already set by Set")
- }
- if mmGet.defaultExpectation == nil {
- mmGet.defaultExpectation = &CacheServiceMockGetExpectation{}
- }
- if mmGet.defaultExpectation.paramPtrs != nil {
- mmGet.mock.t.Fatalf("CacheServiceMock.Get mock is already set by ExpectParams functions")
- }
- mmGet.defaultExpectation.params = &CacheServiceMockGetParams{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)
- }
- }
- return mmGet
- }
- // ExpectKeyParam1 sets up expected param key for CacheService.Get
- func (mmGet *mCacheServiceMockGet) ExpectKeyParam1(key string) *mCacheServiceMockGet {
- if mmGet.mock.funcGet != nil {
- mmGet.mock.t.Fatalf("CacheServiceMock.Get mock is already set by Set")
- }
- if mmGet.defaultExpectation == nil {
- mmGet.defaultExpectation = &CacheServiceMockGetExpectation{}
- }
- if mmGet.defaultExpectation.params != nil {
- mmGet.mock.t.Fatalf("CacheServiceMock.Get mock is already set by Expect")
- }
- if mmGet.defaultExpectation.paramPtrs == nil {
- mmGet.defaultExpectation.paramPtrs = &CacheServiceMockGetParamPtrs{}
- }
- mmGet.defaultExpectation.paramPtrs.key = &key
- return mmGet
- }
- // Inspect accepts an inspector function that has same arguments as the CacheService.Get
- func (mmGet *mCacheServiceMockGet) Inspect(f func(key string)) *mCacheServiceMockGet {
- if mmGet.mock.inspectFuncGet != nil {
- mmGet.mock.t.Fatalf("Inspect function is already set for CacheServiceMock.Get")
- }
- mmGet.mock.inspectFuncGet = f
- return mmGet
- }
- // Return sets up results that will be returned by CacheService.Get
- func (mmGet *mCacheServiceMockGet) Return(p1 interface{}, b1 bool) *CacheServiceMock {
- if mmGet.mock.funcGet != nil {
- mmGet.mock.t.Fatalf("CacheServiceMock.Get mock is already set by Set")
- }
- if mmGet.defaultExpectation == nil {
- mmGet.defaultExpectation = &CacheServiceMockGetExpectation{mock: mmGet.mock}
- }
- mmGet.defaultExpectation.results = &CacheServiceMockGetResults{p1, b1}
- return mmGet.mock
- }
- // Set uses given function f to mock the CacheService.Get method
- func (mmGet *mCacheServiceMockGet) Set(f func(key string) (p1 interface{}, b1 bool)) *CacheServiceMock {
- if mmGet.defaultExpectation != nil {
- mmGet.mock.t.Fatalf("Default expectation is already set for the CacheService.Get method")
- }
- if len(mmGet.expectations) > 0 {
- mmGet.mock.t.Fatalf("Some expectations are already set for the CacheService.Get method")
- }
- mmGet.mock.funcGet = f
- return mmGet.mock
- }
- // When sets expectation for the CacheService.Get which will trigger the result defined by the following
- // Then helper
- func (mmGet *mCacheServiceMockGet) When(key string) *CacheServiceMockGetExpectation {
- if mmGet.mock.funcGet != nil {
- mmGet.mock.t.Fatalf("CacheServiceMock.Get mock is already set by Set")
- }
- expectation := &CacheServiceMockGetExpectation{
- mock: mmGet.mock,
- params: &CacheServiceMockGetParams{key},
- }
- mmGet.expectations = append(mmGet.expectations, expectation)
- return expectation
- }
- // Then sets up CacheService.Get return parameters for the expectation previously defined by the When method
- func (e *CacheServiceMockGetExpectation) Then(p1 interface{}, b1 bool) *CacheServiceMock {
- e.results = &CacheServiceMockGetResults{p1, b1}
- return e.mock
- }
- // Times sets number of times CacheService.Get should be invoked
- func (mmGet *mCacheServiceMockGet) Times(n uint64) *mCacheServiceMockGet {
- if n == 0 {
- mmGet.mock.t.Fatalf("Times of CacheServiceMock.Get mock can not be zero")
- }
- mm_atomic.StoreUint64(&mmGet.expectedInvocations, n)
- return mmGet
- }
- func (mmGet *mCacheServiceMockGet) invocationsDone() bool {
- if len(mmGet.expectations) == 0 && mmGet.defaultExpectation == nil && mmGet.mock.funcGet == nil {
- return true
- }
- totalInvocations := mm_atomic.LoadUint64(&mmGet.mock.afterGetCounter)
- expectedInvocations := mm_atomic.LoadUint64(&mmGet.expectedInvocations)
- return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
- }
- // Get implements handler.CacheService
- func (mmGet *CacheServiceMock) Get(key string) (p1 interface{}, b1 bool) {
- mm_atomic.AddUint64(&mmGet.beforeGetCounter, 1)
- defer mm_atomic.AddUint64(&mmGet.afterGetCounter, 1)
- if mmGet.inspectFuncGet != nil {
- mmGet.inspectFuncGet(key)
- }
- mm_params := CacheServiceMockGetParams{key}
- // Record call args
- mmGet.GetMock.mutex.Lock()
- mmGet.GetMock.callArgs = append(mmGet.GetMock.callArgs, &mm_params)
- mmGet.GetMock.mutex.Unlock()
- for _, e := range mmGet.GetMock.expectations {
- if minimock.Equal(*e.params, mm_params) {
- mm_atomic.AddUint64(&e.Counter, 1)
- return e.results.p1, e.results.b1
- }
- }
- if mmGet.GetMock.defaultExpectation != nil {
- mm_atomic.AddUint64(&mmGet.GetMock.defaultExpectation.Counter, 1)
- mm_want := mmGet.GetMock.defaultExpectation.params
- mm_want_ptrs := mmGet.GetMock.defaultExpectation.paramPtrs
- mm_got := CacheServiceMockGetParams{key}
- if mm_want_ptrs != nil {
- if mm_want_ptrs.key != nil && !minimock.Equal(*mm_want_ptrs.key, mm_got.key) {
- mmGet.t.Errorf("CacheServiceMock.Get got unexpected parameter key, want: %#v, got: %#v%s\n", *mm_want_ptrs.key, mm_got.key, minimock.Diff(*mm_want_ptrs.key, mm_got.key))
- }
- } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
- mmGet.t.Errorf("CacheServiceMock.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 CacheServiceMock.Get")
- }
- return (*mm_results).p1, (*mm_results).b1
- }
- if mmGet.funcGet != nil {
- return mmGet.funcGet(key)
- }
- mmGet.t.Fatalf("Unexpected call to CacheServiceMock.Get. %v", key)
- return
- }
- // GetAfterCounter returns a count of finished CacheServiceMock.Get invocations
- func (mmGet *CacheServiceMock) GetAfterCounter() uint64 {
- return mm_atomic.LoadUint64(&mmGet.afterGetCounter)
- }
- // GetBeforeCounter returns a count of CacheServiceMock.Get invocations
- func (mmGet *CacheServiceMock) GetBeforeCounter() uint64 {
- return mm_atomic.LoadUint64(&mmGet.beforeGetCounter)
- }
- // Calls returns a list of arguments used in each call to CacheServiceMock.Get.
- // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
- func (mmGet *mCacheServiceMockGet) Calls() []*CacheServiceMockGetParams {
- mmGet.mutex.RLock()
- argCopy := make([]*CacheServiceMockGetParams, len(mmGet.callArgs))
- copy(argCopy, mmGet.callArgs)
- mmGet.mutex.RUnlock()
- return argCopy
- }
- // MinimockGetDone returns true if the count of the Get invocations corresponds
- // the number of defined expectations
- func (m *CacheServiceMock) MinimockGetDone() bool {
- if m.GetMock.optional {
- // Optional methods provide '0 or more' call count restriction.
- return true
- }
- for _, e := range m.GetMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- return false
- }
- }
- return m.GetMock.invocationsDone()
- }
- // MinimockGetInspect logs each unmet expectation
- func (m *CacheServiceMock) MinimockGetInspect() {
- for _, e := range m.GetMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- m.t.Errorf("Expected call to CacheServiceMock.Get with params: %#v", *e.params)
- }
- }
- afterGetCounter := mm_atomic.LoadUint64(&m.afterGetCounter)
- // if default expectation was set then invocations count should be greater than zero
- if m.GetMock.defaultExpectation != nil && afterGetCounter < 1 {
- if m.GetMock.defaultExpectation.params == nil {
- m.t.Error("Expected call to CacheServiceMock.Get")
- } else {
- m.t.Errorf("Expected call to CacheServiceMock.Get with params: %#v", *m.GetMock.defaultExpectation.params)
- }
- }
- // if func was set then invocations count should be greater than zero
- if m.funcGet != nil && afterGetCounter < 1 {
- m.t.Error("Expected call to CacheServiceMock.Get")
- }
- if !m.GetMock.invocationsDone() && afterGetCounter > 0 {
- m.t.Errorf("Expected %d calls to CacheServiceMock.Get but found %d calls",
- mm_atomic.LoadUint64(&m.GetMock.expectedInvocations), afterGetCounter)
- }
- }
- type mCacheServiceMockSet struct {
- optional bool
- mock *CacheServiceMock
- defaultExpectation *CacheServiceMockSetExpectation
- expectations []*CacheServiceMockSetExpectation
- callArgs []*CacheServiceMockSetParams
- mutex sync.RWMutex
- expectedInvocations uint64
- }
- // CacheServiceMockSetExpectation specifies expectation struct of the CacheService.Set
- type CacheServiceMockSetExpectation struct {
- mock *CacheServiceMock
- params *CacheServiceMockSetParams
- paramPtrs *CacheServiceMockSetParamPtrs
- Counter uint64
- }
- // CacheServiceMockSetParams contains parameters of the CacheService.Set
- type CacheServiceMockSetParams struct {
- key string
- value interface{}
- }
- // CacheServiceMockSetParamPtrs contains pointers to parameters of the CacheService.Set
- type CacheServiceMockSetParamPtrs struct {
- key *string
- value *interface{}
- }
- // Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
- // the test will fail minimock's automatic final call check if the mocked method was not called at least once.
- // Optional() makes method check to work in '0 or more' mode.
- // It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
- // catch the problems when the expected method call is totally skipped during test run.
- func (mmSet *mCacheServiceMockSet) Optional() *mCacheServiceMockSet {
- mmSet.optional = true
- return mmSet
- }
- // Expect sets up expected params for CacheService.Set
- func (mmSet *mCacheServiceMockSet) Expect(key string, value interface{}) *mCacheServiceMockSet {
- if mmSet.mock.funcSet != nil {
- mmSet.mock.t.Fatalf("CacheServiceMock.Set mock is already set by Set")
- }
- if mmSet.defaultExpectation == nil {
- mmSet.defaultExpectation = &CacheServiceMockSetExpectation{}
- }
- if mmSet.defaultExpectation.paramPtrs != nil {
- mmSet.mock.t.Fatalf("CacheServiceMock.Set mock is already set by ExpectParams functions")
- }
- mmSet.defaultExpectation.params = &CacheServiceMockSetParams{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)
- }
- }
- return mmSet
- }
- // ExpectKeyParam1 sets up expected param key for CacheService.Set
- func (mmSet *mCacheServiceMockSet) ExpectKeyParam1(key string) *mCacheServiceMockSet {
- if mmSet.mock.funcSet != nil {
- mmSet.mock.t.Fatalf("CacheServiceMock.Set mock is already set by Set")
- }
- if mmSet.defaultExpectation == nil {
- mmSet.defaultExpectation = &CacheServiceMockSetExpectation{}
- }
- if mmSet.defaultExpectation.params != nil {
- mmSet.mock.t.Fatalf("CacheServiceMock.Set mock is already set by Expect")
- }
- if mmSet.defaultExpectation.paramPtrs == nil {
- mmSet.defaultExpectation.paramPtrs = &CacheServiceMockSetParamPtrs{}
- }
- mmSet.defaultExpectation.paramPtrs.key = &key
- return mmSet
- }
- // ExpectValueParam2 sets up expected param value for CacheService.Set
- func (mmSet *mCacheServiceMockSet) ExpectValueParam2(value interface{}) *mCacheServiceMockSet {
- if mmSet.mock.funcSet != nil {
- mmSet.mock.t.Fatalf("CacheServiceMock.Set mock is already set by Set")
- }
- if mmSet.defaultExpectation == nil {
- mmSet.defaultExpectation = &CacheServiceMockSetExpectation{}
- }
- if mmSet.defaultExpectation.params != nil {
- mmSet.mock.t.Fatalf("CacheServiceMock.Set mock is already set by Expect")
- }
- if mmSet.defaultExpectation.paramPtrs == nil {
- mmSet.defaultExpectation.paramPtrs = &CacheServiceMockSetParamPtrs{}
- }
- mmSet.defaultExpectation.paramPtrs.value = &value
- return mmSet
- }
- // Inspect accepts an inspector function that has same arguments as the CacheService.Set
- func (mmSet *mCacheServiceMockSet) Inspect(f func(key string, value interface{})) *mCacheServiceMockSet {
- if mmSet.mock.inspectFuncSet != nil {
- mmSet.mock.t.Fatalf("Inspect function is already set for CacheServiceMock.Set")
- }
- mmSet.mock.inspectFuncSet = f
- return mmSet
- }
- // Return sets up results that will be returned by CacheService.Set
- func (mmSet *mCacheServiceMockSet) Return() *CacheServiceMock {
- if mmSet.mock.funcSet != nil {
- mmSet.mock.t.Fatalf("CacheServiceMock.Set mock is already set by Set")
- }
- if mmSet.defaultExpectation == nil {
- mmSet.defaultExpectation = &CacheServiceMockSetExpectation{mock: mmSet.mock}
- }
- return mmSet.mock
- }
- // Set uses given function f to mock the CacheService.Set method
- func (mmSet *mCacheServiceMockSet) Set(f func(key string, value interface{})) *CacheServiceMock {
- if mmSet.defaultExpectation != nil {
- mmSet.mock.t.Fatalf("Default expectation is already set for the CacheService.Set method")
- }
- if len(mmSet.expectations) > 0 {
- mmSet.mock.t.Fatalf("Some expectations are already set for the CacheService.Set method")
- }
- mmSet.mock.funcSet = f
- return mmSet.mock
- }
- // Times sets number of times CacheService.Set should be invoked
- func (mmSet *mCacheServiceMockSet) Times(n uint64) *mCacheServiceMockSet {
- if n == 0 {
- mmSet.mock.t.Fatalf("Times of CacheServiceMock.Set mock can not be zero")
- }
- mm_atomic.StoreUint64(&mmSet.expectedInvocations, n)
- return mmSet
- }
- func (mmSet *mCacheServiceMockSet) invocationsDone() bool {
- if len(mmSet.expectations) == 0 && mmSet.defaultExpectation == nil && mmSet.mock.funcSet == nil {
- return true
- }
- totalInvocations := mm_atomic.LoadUint64(&mmSet.mock.afterSetCounter)
- expectedInvocations := mm_atomic.LoadUint64(&mmSet.expectedInvocations)
- return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
- }
- // Set implements handler.CacheService
- func (mmSet *CacheServiceMock) Set(key string, value interface{}) {
- mm_atomic.AddUint64(&mmSet.beforeSetCounter, 1)
- defer mm_atomic.AddUint64(&mmSet.afterSetCounter, 1)
- if mmSet.inspectFuncSet != nil {
- mmSet.inspectFuncSet(key, value)
- }
- mm_params := CacheServiceMockSetParams{key, value}
- // Record call args
- mmSet.SetMock.mutex.Lock()
- mmSet.SetMock.callArgs = append(mmSet.SetMock.callArgs, &mm_params)
- mmSet.SetMock.mutex.Unlock()
- for _, e := range mmSet.SetMock.expectations {
- if minimock.Equal(*e.params, mm_params) {
- mm_atomic.AddUint64(&e.Counter, 1)
- return
- }
- }
- if mmSet.SetMock.defaultExpectation != nil {
- mm_atomic.AddUint64(&mmSet.SetMock.defaultExpectation.Counter, 1)
- mm_want := mmSet.SetMock.defaultExpectation.params
- mm_want_ptrs := mmSet.SetMock.defaultExpectation.paramPtrs
- mm_got := CacheServiceMockSetParams{key, value}
- if mm_want_ptrs != nil {
- if mm_want_ptrs.key != nil && !minimock.Equal(*mm_want_ptrs.key, mm_got.key) {
- mmSet.t.Errorf("CacheServiceMock.Set got unexpected parameter key, want: %#v, got: %#v%s\n", *mm_want_ptrs.key, mm_got.key, minimock.Diff(*mm_want_ptrs.key, mm_got.key))
- }
- if mm_want_ptrs.value != nil && !minimock.Equal(*mm_want_ptrs.value, mm_got.value) {
- mmSet.t.Errorf("CacheServiceMock.Set got unexpected parameter value, want: %#v, got: %#v%s\n", *mm_want_ptrs.value, mm_got.value, minimock.Diff(*mm_want_ptrs.value, mm_got.value))
- }
- } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
- mmSet.t.Errorf("CacheServiceMock.Set got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
- }
- return
- }
- if mmSet.funcSet != nil {
- mmSet.funcSet(key, value)
- return
- }
- mmSet.t.Fatalf("Unexpected call to CacheServiceMock.Set. %v %v", key, value)
- }
- // SetAfterCounter returns a count of finished CacheServiceMock.Set invocations
- func (mmSet *CacheServiceMock) SetAfterCounter() uint64 {
- return mm_atomic.LoadUint64(&mmSet.afterSetCounter)
- }
- // SetBeforeCounter returns a count of CacheServiceMock.Set invocations
- func (mmSet *CacheServiceMock) SetBeforeCounter() uint64 {
- return mm_atomic.LoadUint64(&mmSet.beforeSetCounter)
- }
- // Calls returns a list of arguments used in each call to CacheServiceMock.Set.
- // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
- func (mmSet *mCacheServiceMockSet) Calls() []*CacheServiceMockSetParams {
- mmSet.mutex.RLock()
- argCopy := make([]*CacheServiceMockSetParams, len(mmSet.callArgs))
- copy(argCopy, mmSet.callArgs)
- mmSet.mutex.RUnlock()
- return argCopy
- }
- // MinimockSetDone returns true if the count of the Set invocations corresponds
- // the number of defined expectations
- func (m *CacheServiceMock) MinimockSetDone() bool {
- if m.SetMock.optional {
- // Optional methods provide '0 or more' call count restriction.
- return true
- }
- for _, e := range m.SetMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- return false
- }
- }
- return m.SetMock.invocationsDone()
- }
- // MinimockSetInspect logs each unmet expectation
- func (m *CacheServiceMock) MinimockSetInspect() {
- for _, e := range m.SetMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- m.t.Errorf("Expected call to CacheServiceMock.Set with params: %#v", *e.params)
- }
- }
- afterSetCounter := mm_atomic.LoadUint64(&m.afterSetCounter)
- // if default expectation was set then invocations count should be greater than zero
- if m.SetMock.defaultExpectation != nil && afterSetCounter < 1 {
- if m.SetMock.defaultExpectation.params == nil {
- m.t.Error("Expected call to CacheServiceMock.Set")
- } else {
- m.t.Errorf("Expected call to CacheServiceMock.Set with params: %#v", *m.SetMock.defaultExpectation.params)
- }
- }
- // if func was set then invocations count should be greater than zero
- if m.funcSet != nil && afterSetCounter < 1 {
- m.t.Error("Expected call to CacheServiceMock.Set")
- }
- if !m.SetMock.invocationsDone() && afterSetCounter > 0 {
- m.t.Errorf("Expected %d calls to CacheServiceMock.Set but found %d calls",
- mm_atomic.LoadUint64(&m.SetMock.expectedInvocations), afterSetCounter)
- }
- }
- // MinimockFinish checks that all mocked methods have been called the expected number of times
- func (m *CacheServiceMock) MinimockFinish() {
- m.finishOnce.Do(func() {
- if !m.minimockDone() {
- m.MinimockGetInspect()
- m.MinimockSetInspect()
- }
- })
- }
- // MinimockWait waits for all mocked methods to be called the expected number of times
- func (m *CacheServiceMock) MinimockWait(timeout mm_time.Duration) {
- timeoutCh := mm_time.After(timeout)
- for {
- if m.minimockDone() {
- return
- }
- select {
- case <-timeoutCh:
- m.MinimockFinish()
- return
- case <-mm_time.After(10 * mm_time.Millisecond):
- }
- }
- }
- func (m *CacheServiceMock) minimockDone() bool {
- done := true
- return done &&
- m.MinimockGetDone() &&
- m.MinimockSetDone()
- }
|