cache_minimock.go 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629
  1. package mocks
  2. // Code generated by http://github.com/gojuno/minimock (dev). DO NOT EDIT.
  3. //go:generate minimock -i git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/interfaces.Cache -o ./mocks/cache_minimock.go -n CacheMock
  4. import (
  5. "sync"
  6. mm_atomic "sync/atomic"
  7. mm_time "time"
  8. "github.com/gojuno/minimock/v3"
  9. )
  10. // CacheMock implements interfaces.Cache
  11. type CacheMock struct {
  12. t minimock.Tester
  13. funcFlushAll func()
  14. inspectFuncFlushAll func()
  15. afterFlushAllCounter uint64
  16. beforeFlushAllCounter uint64
  17. FlushAllMock mCacheMockFlushAll
  18. funcGet func(key string) (p1 interface{}, b1 bool)
  19. inspectFuncGet func(key string)
  20. afterGetCounter uint64
  21. beforeGetCounter uint64
  22. GetMock mCacheMockGet
  23. funcSet func(key string, value interface{})
  24. inspectFuncSet func(key string, value interface{})
  25. afterSetCounter uint64
  26. beforeSetCounter uint64
  27. SetMock mCacheMockSet
  28. }
  29. // NewCacheMock returns a mock for interfaces.Cache
  30. func NewCacheMock(t minimock.Tester) *CacheMock {
  31. m := &CacheMock{t: t}
  32. if controller, ok := t.(minimock.MockController); ok {
  33. controller.RegisterMocker(m)
  34. }
  35. m.FlushAllMock = mCacheMockFlushAll{mock: m}
  36. m.GetMock = mCacheMockGet{mock: m}
  37. m.GetMock.callArgs = []*CacheMockGetParams{}
  38. m.SetMock = mCacheMockSet{mock: m}
  39. m.SetMock.callArgs = []*CacheMockSetParams{}
  40. return m
  41. }
  42. type mCacheMockFlushAll struct {
  43. mock *CacheMock
  44. defaultExpectation *CacheMockFlushAllExpectation
  45. expectations []*CacheMockFlushAllExpectation
  46. }
  47. // CacheMockFlushAllExpectation specifies expectation struct of the Cache.FlushAll
  48. type CacheMockFlushAllExpectation struct {
  49. mock *CacheMock
  50. Counter uint64
  51. }
  52. // Expect sets up expected params for Cache.FlushAll
  53. func (mmFlushAll *mCacheMockFlushAll) Expect() *mCacheMockFlushAll {
  54. if mmFlushAll.mock.funcFlushAll != nil {
  55. mmFlushAll.mock.t.Fatalf("CacheMock.FlushAll mock is already set by Set")
  56. }
  57. if mmFlushAll.defaultExpectation == nil {
  58. mmFlushAll.defaultExpectation = &CacheMockFlushAllExpectation{}
  59. }
  60. return mmFlushAll
  61. }
  62. // Inspect accepts an inspector function that has same arguments as the Cache.FlushAll
  63. func (mmFlushAll *mCacheMockFlushAll) Inspect(f func()) *mCacheMockFlushAll {
  64. if mmFlushAll.mock.inspectFuncFlushAll != nil {
  65. mmFlushAll.mock.t.Fatalf("Inspect function is already set for CacheMock.FlushAll")
  66. }
  67. mmFlushAll.mock.inspectFuncFlushAll = f
  68. return mmFlushAll
  69. }
  70. // Return sets up results that will be returned by Cache.FlushAll
  71. func (mmFlushAll *mCacheMockFlushAll) Return() *CacheMock {
  72. if mmFlushAll.mock.funcFlushAll != nil {
  73. mmFlushAll.mock.t.Fatalf("CacheMock.FlushAll mock is already set by Set")
  74. }
  75. if mmFlushAll.defaultExpectation == nil {
  76. mmFlushAll.defaultExpectation = &CacheMockFlushAllExpectation{mock: mmFlushAll.mock}
  77. }
  78. return mmFlushAll.mock
  79. }
  80. // Set uses given function f to mock the Cache.FlushAll method
  81. func (mmFlushAll *mCacheMockFlushAll) Set(f func()) *CacheMock {
  82. if mmFlushAll.defaultExpectation != nil {
  83. mmFlushAll.mock.t.Fatalf("Default expectation is already set for the Cache.FlushAll method")
  84. }
  85. if len(mmFlushAll.expectations) > 0 {
  86. mmFlushAll.mock.t.Fatalf("Some expectations are already set for the Cache.FlushAll method")
  87. }
  88. mmFlushAll.mock.funcFlushAll = f
  89. return mmFlushAll.mock
  90. }
  91. // FlushAll implements interfaces.Cache
  92. func (mmFlushAll *CacheMock) FlushAll() {
  93. mm_atomic.AddUint64(&mmFlushAll.beforeFlushAllCounter, 1)
  94. defer mm_atomic.AddUint64(&mmFlushAll.afterFlushAllCounter, 1)
  95. if mmFlushAll.inspectFuncFlushAll != nil {
  96. mmFlushAll.inspectFuncFlushAll()
  97. }
  98. if mmFlushAll.FlushAllMock.defaultExpectation != nil {
  99. mm_atomic.AddUint64(&mmFlushAll.FlushAllMock.defaultExpectation.Counter, 1)
  100. return
  101. }
  102. if mmFlushAll.funcFlushAll != nil {
  103. mmFlushAll.funcFlushAll()
  104. return
  105. }
  106. mmFlushAll.t.Fatalf("Unexpected call to CacheMock.FlushAll.")
  107. }
  108. // FlushAllAfterCounter returns a count of finished CacheMock.FlushAll invocations
  109. func (mmFlushAll *CacheMock) FlushAllAfterCounter() uint64 {
  110. return mm_atomic.LoadUint64(&mmFlushAll.afterFlushAllCounter)
  111. }
  112. // FlushAllBeforeCounter returns a count of CacheMock.FlushAll invocations
  113. func (mmFlushAll *CacheMock) FlushAllBeforeCounter() uint64 {
  114. return mm_atomic.LoadUint64(&mmFlushAll.beforeFlushAllCounter)
  115. }
  116. // MinimockFlushAllDone returns true if the count of the FlushAll invocations corresponds
  117. // the number of defined expectations
  118. func (m *CacheMock) MinimockFlushAllDone() bool {
  119. for _, e := range m.FlushAllMock.expectations {
  120. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  121. return false
  122. }
  123. }
  124. // if default expectation was set then invocations count should be greater than zero
  125. if m.FlushAllMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterFlushAllCounter) < 1 {
  126. return false
  127. }
  128. // if func was set then invocations count should be greater than zero
  129. if m.funcFlushAll != nil && mm_atomic.LoadUint64(&m.afterFlushAllCounter) < 1 {
  130. return false
  131. }
  132. return true
  133. }
  134. // MinimockFlushAllInspect logs each unmet expectation
  135. func (m *CacheMock) MinimockFlushAllInspect() {
  136. for _, e := range m.FlushAllMock.expectations {
  137. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  138. m.t.Error("Expected call to CacheMock.FlushAll")
  139. }
  140. }
  141. // if default expectation was set then invocations count should be greater than zero
  142. if m.FlushAllMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterFlushAllCounter) < 1 {
  143. m.t.Error("Expected call to CacheMock.FlushAll")
  144. }
  145. // if func was set then invocations count should be greater than zero
  146. if m.funcFlushAll != nil && mm_atomic.LoadUint64(&m.afterFlushAllCounter) < 1 {
  147. m.t.Error("Expected call to CacheMock.FlushAll")
  148. }
  149. }
  150. type mCacheMockGet struct {
  151. mock *CacheMock
  152. defaultExpectation *CacheMockGetExpectation
  153. expectations []*CacheMockGetExpectation
  154. callArgs []*CacheMockGetParams
  155. mutex sync.RWMutex
  156. }
  157. // CacheMockGetExpectation specifies expectation struct of the Cache.Get
  158. type CacheMockGetExpectation struct {
  159. mock *CacheMock
  160. params *CacheMockGetParams
  161. results *CacheMockGetResults
  162. Counter uint64
  163. }
  164. // CacheMockGetParams contains parameters of the Cache.Get
  165. type CacheMockGetParams struct {
  166. key string
  167. }
  168. // CacheMockGetResults contains results of the Cache.Get
  169. type CacheMockGetResults struct {
  170. p1 interface{}
  171. b1 bool
  172. }
  173. // Expect sets up expected params for Cache.Get
  174. func (mmGet *mCacheMockGet) Expect(key string) *mCacheMockGet {
  175. if mmGet.mock.funcGet != nil {
  176. mmGet.mock.t.Fatalf("CacheMock.Get mock is already set by Set")
  177. }
  178. if mmGet.defaultExpectation == nil {
  179. mmGet.defaultExpectation = &CacheMockGetExpectation{}
  180. }
  181. mmGet.defaultExpectation.params = &CacheMockGetParams{key}
  182. for _, e := range mmGet.expectations {
  183. if minimock.Equal(e.params, mmGet.defaultExpectation.params) {
  184. mmGet.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGet.defaultExpectation.params)
  185. }
  186. }
  187. return mmGet
  188. }
  189. // Inspect accepts an inspector function that has same arguments as the Cache.Get
  190. func (mmGet *mCacheMockGet) Inspect(f func(key string)) *mCacheMockGet {
  191. if mmGet.mock.inspectFuncGet != nil {
  192. mmGet.mock.t.Fatalf("Inspect function is already set for CacheMock.Get")
  193. }
  194. mmGet.mock.inspectFuncGet = f
  195. return mmGet
  196. }
  197. // Return sets up results that will be returned by Cache.Get
  198. func (mmGet *mCacheMockGet) Return(p1 interface{}, b1 bool) *CacheMock {
  199. if mmGet.mock.funcGet != nil {
  200. mmGet.mock.t.Fatalf("CacheMock.Get mock is already set by Set")
  201. }
  202. if mmGet.defaultExpectation == nil {
  203. mmGet.defaultExpectation = &CacheMockGetExpectation{mock: mmGet.mock}
  204. }
  205. mmGet.defaultExpectation.results = &CacheMockGetResults{p1, b1}
  206. return mmGet.mock
  207. }
  208. // Set uses given function f to mock the Cache.Get method
  209. func (mmGet *mCacheMockGet) Set(f func(key string) (p1 interface{}, b1 bool)) *CacheMock {
  210. if mmGet.defaultExpectation != nil {
  211. mmGet.mock.t.Fatalf("Default expectation is already set for the Cache.Get method")
  212. }
  213. if len(mmGet.expectations) > 0 {
  214. mmGet.mock.t.Fatalf("Some expectations are already set for the Cache.Get method")
  215. }
  216. mmGet.mock.funcGet = f
  217. return mmGet.mock
  218. }
  219. // When sets expectation for the Cache.Get which will trigger the result defined by the following
  220. // Then helper
  221. func (mmGet *mCacheMockGet) When(key string) *CacheMockGetExpectation {
  222. if mmGet.mock.funcGet != nil {
  223. mmGet.mock.t.Fatalf("CacheMock.Get mock is already set by Set")
  224. }
  225. expectation := &CacheMockGetExpectation{
  226. mock: mmGet.mock,
  227. params: &CacheMockGetParams{key},
  228. }
  229. mmGet.expectations = append(mmGet.expectations, expectation)
  230. return expectation
  231. }
  232. // Then sets up Cache.Get return parameters for the expectation previously defined by the When method
  233. func (e *CacheMockGetExpectation) Then(p1 interface{}, b1 bool) *CacheMock {
  234. e.results = &CacheMockGetResults{p1, b1}
  235. return e.mock
  236. }
  237. // Get implements interfaces.Cache
  238. func (mmGet *CacheMock) Get(key string) (p1 interface{}, b1 bool) {
  239. mm_atomic.AddUint64(&mmGet.beforeGetCounter, 1)
  240. defer mm_atomic.AddUint64(&mmGet.afterGetCounter, 1)
  241. if mmGet.inspectFuncGet != nil {
  242. mmGet.inspectFuncGet(key)
  243. }
  244. mm_params := &CacheMockGetParams{key}
  245. // Record call args
  246. mmGet.GetMock.mutex.Lock()
  247. mmGet.GetMock.callArgs = append(mmGet.GetMock.callArgs, mm_params)
  248. mmGet.GetMock.mutex.Unlock()
  249. for _, e := range mmGet.GetMock.expectations {
  250. if minimock.Equal(e.params, mm_params) {
  251. mm_atomic.AddUint64(&e.Counter, 1)
  252. return e.results.p1, e.results.b1
  253. }
  254. }
  255. if mmGet.GetMock.defaultExpectation != nil {
  256. mm_atomic.AddUint64(&mmGet.GetMock.defaultExpectation.Counter, 1)
  257. mm_want := mmGet.GetMock.defaultExpectation.params
  258. mm_got := CacheMockGetParams{key}
  259. if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
  260. mmGet.t.Errorf("CacheMock.Get got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
  261. }
  262. mm_results := mmGet.GetMock.defaultExpectation.results
  263. if mm_results == nil {
  264. mmGet.t.Fatal("No results are set for the CacheMock.Get")
  265. }
  266. return (*mm_results).p1, (*mm_results).b1
  267. }
  268. if mmGet.funcGet != nil {
  269. return mmGet.funcGet(key)
  270. }
  271. mmGet.t.Fatalf("Unexpected call to CacheMock.Get. %v", key)
  272. return
  273. }
  274. // GetAfterCounter returns a count of finished CacheMock.Get invocations
  275. func (mmGet *CacheMock) GetAfterCounter() uint64 {
  276. return mm_atomic.LoadUint64(&mmGet.afterGetCounter)
  277. }
  278. // GetBeforeCounter returns a count of CacheMock.Get invocations
  279. func (mmGet *CacheMock) GetBeforeCounter() uint64 {
  280. return mm_atomic.LoadUint64(&mmGet.beforeGetCounter)
  281. }
  282. // Calls returns a list of arguments used in each call to CacheMock.Get.
  283. // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
  284. func (mmGet *mCacheMockGet) Calls() []*CacheMockGetParams {
  285. mmGet.mutex.RLock()
  286. argCopy := make([]*CacheMockGetParams, len(mmGet.callArgs))
  287. copy(argCopy, mmGet.callArgs)
  288. mmGet.mutex.RUnlock()
  289. return argCopy
  290. }
  291. // MinimockGetDone returns true if the count of the Get invocations corresponds
  292. // the number of defined expectations
  293. func (m *CacheMock) MinimockGetDone() bool {
  294. for _, e := range m.GetMock.expectations {
  295. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  296. return false
  297. }
  298. }
  299. // if default expectation was set then invocations count should be greater than zero
  300. if m.GetMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetCounter) < 1 {
  301. return false
  302. }
  303. // if func was set then invocations count should be greater than zero
  304. if m.funcGet != nil && mm_atomic.LoadUint64(&m.afterGetCounter) < 1 {
  305. return false
  306. }
  307. return true
  308. }
  309. // MinimockGetInspect logs each unmet expectation
  310. func (m *CacheMock) MinimockGetInspect() {
  311. for _, e := range m.GetMock.expectations {
  312. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  313. m.t.Errorf("Expected call to CacheMock.Get with params: %#v", *e.params)
  314. }
  315. }
  316. // if default expectation was set then invocations count should be greater than zero
  317. if m.GetMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetCounter) < 1 {
  318. if m.GetMock.defaultExpectation.params == nil {
  319. m.t.Error("Expected call to CacheMock.Get")
  320. } else {
  321. m.t.Errorf("Expected call to CacheMock.Get with params: %#v", *m.GetMock.defaultExpectation.params)
  322. }
  323. }
  324. // if func was set then invocations count should be greater than zero
  325. if m.funcGet != nil && mm_atomic.LoadUint64(&m.afterGetCounter) < 1 {
  326. m.t.Error("Expected call to CacheMock.Get")
  327. }
  328. }
  329. type mCacheMockSet struct {
  330. mock *CacheMock
  331. defaultExpectation *CacheMockSetExpectation
  332. expectations []*CacheMockSetExpectation
  333. callArgs []*CacheMockSetParams
  334. mutex sync.RWMutex
  335. }
  336. // CacheMockSetExpectation specifies expectation struct of the Cache.Set
  337. type CacheMockSetExpectation struct {
  338. mock *CacheMock
  339. params *CacheMockSetParams
  340. Counter uint64
  341. }
  342. // CacheMockSetParams contains parameters of the Cache.Set
  343. type CacheMockSetParams struct {
  344. key string
  345. value interface{}
  346. }
  347. // Expect sets up expected params for Cache.Set
  348. func (mmSet *mCacheMockSet) Expect(key string, value interface{}) *mCacheMockSet {
  349. if mmSet.mock.funcSet != nil {
  350. mmSet.mock.t.Fatalf("CacheMock.Set mock is already set by Set")
  351. }
  352. if mmSet.defaultExpectation == nil {
  353. mmSet.defaultExpectation = &CacheMockSetExpectation{}
  354. }
  355. mmSet.defaultExpectation.params = &CacheMockSetParams{key, value}
  356. for _, e := range mmSet.expectations {
  357. if minimock.Equal(e.params, mmSet.defaultExpectation.params) {
  358. mmSet.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmSet.defaultExpectation.params)
  359. }
  360. }
  361. return mmSet
  362. }
  363. // Inspect accepts an inspector function that has same arguments as the Cache.Set
  364. func (mmSet *mCacheMockSet) Inspect(f func(key string, value interface{})) *mCacheMockSet {
  365. if mmSet.mock.inspectFuncSet != nil {
  366. mmSet.mock.t.Fatalf("Inspect function is already set for CacheMock.Set")
  367. }
  368. mmSet.mock.inspectFuncSet = f
  369. return mmSet
  370. }
  371. // Return sets up results that will be returned by Cache.Set
  372. func (mmSet *mCacheMockSet) Return() *CacheMock {
  373. if mmSet.mock.funcSet != nil {
  374. mmSet.mock.t.Fatalf("CacheMock.Set mock is already set by Set")
  375. }
  376. if mmSet.defaultExpectation == nil {
  377. mmSet.defaultExpectation = &CacheMockSetExpectation{mock: mmSet.mock}
  378. }
  379. return mmSet.mock
  380. }
  381. // Set uses given function f to mock the Cache.Set method
  382. func (mmSet *mCacheMockSet) Set(f func(key string, value interface{})) *CacheMock {
  383. if mmSet.defaultExpectation != nil {
  384. mmSet.mock.t.Fatalf("Default expectation is already set for the Cache.Set method")
  385. }
  386. if len(mmSet.expectations) > 0 {
  387. mmSet.mock.t.Fatalf("Some expectations are already set for the Cache.Set method")
  388. }
  389. mmSet.mock.funcSet = f
  390. return mmSet.mock
  391. }
  392. // Set implements interfaces.Cache
  393. func (mmSet *CacheMock) Set(key string, value interface{}) {
  394. mm_atomic.AddUint64(&mmSet.beforeSetCounter, 1)
  395. defer mm_atomic.AddUint64(&mmSet.afterSetCounter, 1)
  396. if mmSet.inspectFuncSet != nil {
  397. mmSet.inspectFuncSet(key, value)
  398. }
  399. mm_params := &CacheMockSetParams{key, value}
  400. // Record call args
  401. mmSet.SetMock.mutex.Lock()
  402. mmSet.SetMock.callArgs = append(mmSet.SetMock.callArgs, mm_params)
  403. mmSet.SetMock.mutex.Unlock()
  404. for _, e := range mmSet.SetMock.expectations {
  405. if minimock.Equal(e.params, mm_params) {
  406. mm_atomic.AddUint64(&e.Counter, 1)
  407. return
  408. }
  409. }
  410. if mmSet.SetMock.defaultExpectation != nil {
  411. mm_atomic.AddUint64(&mmSet.SetMock.defaultExpectation.Counter, 1)
  412. mm_want := mmSet.SetMock.defaultExpectation.params
  413. mm_got := CacheMockSetParams{key, value}
  414. if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
  415. mmSet.t.Errorf("CacheMock.Set got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
  416. }
  417. return
  418. }
  419. if mmSet.funcSet != nil {
  420. mmSet.funcSet(key, value)
  421. return
  422. }
  423. mmSet.t.Fatalf("Unexpected call to CacheMock.Set. %v %v", key, value)
  424. }
  425. // SetAfterCounter returns a count of finished CacheMock.Set invocations
  426. func (mmSet *CacheMock) SetAfterCounter() uint64 {
  427. return mm_atomic.LoadUint64(&mmSet.afterSetCounter)
  428. }
  429. // SetBeforeCounter returns a count of CacheMock.Set invocations
  430. func (mmSet *CacheMock) SetBeforeCounter() uint64 {
  431. return mm_atomic.LoadUint64(&mmSet.beforeSetCounter)
  432. }
  433. // Calls returns a list of arguments used in each call to CacheMock.Set.
  434. // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
  435. func (mmSet *mCacheMockSet) Calls() []*CacheMockSetParams {
  436. mmSet.mutex.RLock()
  437. argCopy := make([]*CacheMockSetParams, len(mmSet.callArgs))
  438. copy(argCopy, mmSet.callArgs)
  439. mmSet.mutex.RUnlock()
  440. return argCopy
  441. }
  442. // MinimockSetDone returns true if the count of the Set invocations corresponds
  443. // the number of defined expectations
  444. func (m *CacheMock) MinimockSetDone() bool {
  445. for _, e := range m.SetMock.expectations {
  446. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  447. return false
  448. }
  449. }
  450. // if default expectation was set then invocations count should be greater than zero
  451. if m.SetMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterSetCounter) < 1 {
  452. return false
  453. }
  454. // if func was set then invocations count should be greater than zero
  455. if m.funcSet != nil && mm_atomic.LoadUint64(&m.afterSetCounter) < 1 {
  456. return false
  457. }
  458. return true
  459. }
  460. // MinimockSetInspect logs each unmet expectation
  461. func (m *CacheMock) MinimockSetInspect() {
  462. for _, e := range m.SetMock.expectations {
  463. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  464. m.t.Errorf("Expected call to CacheMock.Set with params: %#v", *e.params)
  465. }
  466. }
  467. // if default expectation was set then invocations count should be greater than zero
  468. if m.SetMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterSetCounter) < 1 {
  469. if m.SetMock.defaultExpectation.params == nil {
  470. m.t.Error("Expected call to CacheMock.Set")
  471. } else {
  472. m.t.Errorf("Expected call to CacheMock.Set with params: %#v", *m.SetMock.defaultExpectation.params)
  473. }
  474. }
  475. // if func was set then invocations count should be greater than zero
  476. if m.funcSet != nil && mm_atomic.LoadUint64(&m.afterSetCounter) < 1 {
  477. m.t.Error("Expected call to CacheMock.Set")
  478. }
  479. }
  480. // MinimockFinish checks that all mocked methods have been called the expected number of times
  481. func (m *CacheMock) MinimockFinish() {
  482. if !m.minimockDone() {
  483. m.MinimockFlushAllInspect()
  484. m.MinimockGetInspect()
  485. m.MinimockSetInspect()
  486. m.t.FailNow()
  487. }
  488. }
  489. // MinimockWait waits for all mocked methods to be called the expected number of times
  490. func (m *CacheMock) MinimockWait(timeout mm_time.Duration) {
  491. timeoutCh := mm_time.After(timeout)
  492. for {
  493. if m.minimockDone() {
  494. return
  495. }
  496. select {
  497. case <-timeoutCh:
  498. m.MinimockFinish()
  499. return
  500. case <-mm_time.After(10 * mm_time.Millisecond):
  501. }
  502. }
  503. }
  504. func (m *CacheMock) minimockDone() bool {
  505. done := true
  506. return done &&
  507. m.MinimockFlushAllDone() &&
  508. m.MinimockGetDone() &&
  509. m.MinimockSetDone()
  510. }