i_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 github.com/dmitriygnatenko/internal/interfaces.ICache -o ./mocks/i_cache_minimock.go -n ICacheMock
  4. import (
  5. "sync"
  6. mm_atomic "sync/atomic"
  7. mm_time "time"
  8. "github.com/gojuno/minimock/v3"
  9. )
  10. // ICacheMock implements interfaces.ICache
  11. type ICacheMock struct {
  12. t minimock.Tester
  13. funcFlushAll func()
  14. inspectFuncFlushAll func()
  15. afterFlushAllCounter uint64
  16. beforeFlushAllCounter uint64
  17. FlushAllMock mICacheMockFlushAll
  18. funcGet func(key string) (p1 interface{}, b1 bool)
  19. inspectFuncGet func(key string)
  20. afterGetCounter uint64
  21. beforeGetCounter uint64
  22. GetMock mICacheMockGet
  23. funcSet func(key string, value interface{})
  24. inspectFuncSet func(key string, value interface{})
  25. afterSetCounter uint64
  26. beforeSetCounter uint64
  27. SetMock mICacheMockSet
  28. }
  29. // NewICacheMock returns a mock for interfaces.ICache
  30. func NewICacheMock(t minimock.Tester) *ICacheMock {
  31. m := &ICacheMock{t: t}
  32. if controller, ok := t.(minimock.MockController); ok {
  33. controller.RegisterMocker(m)
  34. }
  35. m.FlushAllMock = mICacheMockFlushAll{mock: m}
  36. m.GetMock = mICacheMockGet{mock: m}
  37. m.GetMock.callArgs = []*ICacheMockGetParams{}
  38. m.SetMock = mICacheMockSet{mock: m}
  39. m.SetMock.callArgs = []*ICacheMockSetParams{}
  40. return m
  41. }
  42. type mICacheMockFlushAll struct {
  43. mock *ICacheMock
  44. defaultExpectation *ICacheMockFlushAllExpectation
  45. expectations []*ICacheMockFlushAllExpectation
  46. }
  47. // ICacheMockFlushAllExpectation specifies expectation struct of the ICache.FlushAll
  48. type ICacheMockFlushAllExpectation struct {
  49. mock *ICacheMock
  50. Counter uint64
  51. }
  52. // Expect sets up expected params for ICache.FlushAll
  53. func (mmFlushAll *mICacheMockFlushAll) Expect() *mICacheMockFlushAll {
  54. if mmFlushAll.mock.funcFlushAll != nil {
  55. mmFlushAll.mock.t.Fatalf("ICacheMock.FlushAll mock is already set by Set")
  56. }
  57. if mmFlushAll.defaultExpectation == nil {
  58. mmFlushAll.defaultExpectation = &ICacheMockFlushAllExpectation{}
  59. }
  60. return mmFlushAll
  61. }
  62. // Inspect accepts an inspector function that has same arguments as the ICache.FlushAll
  63. func (mmFlushAll *mICacheMockFlushAll) Inspect(f func()) *mICacheMockFlushAll {
  64. if mmFlushAll.mock.inspectFuncFlushAll != nil {
  65. mmFlushAll.mock.t.Fatalf("Inspect function is already set for ICacheMock.FlushAll")
  66. }
  67. mmFlushAll.mock.inspectFuncFlushAll = f
  68. return mmFlushAll
  69. }
  70. // Return sets up results that will be returned by ICache.FlushAll
  71. func (mmFlushAll *mICacheMockFlushAll) Return() *ICacheMock {
  72. if mmFlushAll.mock.funcFlushAll != nil {
  73. mmFlushAll.mock.t.Fatalf("ICacheMock.FlushAll mock is already set by Set")
  74. }
  75. if mmFlushAll.defaultExpectation == nil {
  76. mmFlushAll.defaultExpectation = &ICacheMockFlushAllExpectation{mock: mmFlushAll.mock}
  77. }
  78. return mmFlushAll.mock
  79. }
  80. //Set uses given function f to mock the ICache.FlushAll method
  81. func (mmFlushAll *mICacheMockFlushAll) Set(f func()) *ICacheMock {
  82. if mmFlushAll.defaultExpectation != nil {
  83. mmFlushAll.mock.t.Fatalf("Default expectation is already set for the ICache.FlushAll method")
  84. }
  85. if len(mmFlushAll.expectations) > 0 {
  86. mmFlushAll.mock.t.Fatalf("Some expectations are already set for the ICache.FlushAll method")
  87. }
  88. mmFlushAll.mock.funcFlushAll = f
  89. return mmFlushAll.mock
  90. }
  91. // FlushAll implements interfaces.ICache
  92. func (mmFlushAll *ICacheMock) 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 ICacheMock.FlushAll.")
  107. }
  108. // FlushAllAfterCounter returns a count of finished ICacheMock.FlushAll invocations
  109. func (mmFlushAll *ICacheMock) FlushAllAfterCounter() uint64 {
  110. return mm_atomic.LoadUint64(&mmFlushAll.afterFlushAllCounter)
  111. }
  112. // FlushAllBeforeCounter returns a count of ICacheMock.FlushAll invocations
  113. func (mmFlushAll *ICacheMock) 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 *ICacheMock) 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 *ICacheMock) MinimockFlushAllInspect() {
  136. for _, e := range m.FlushAllMock.expectations {
  137. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  138. m.t.Error("Expected call to ICacheMock.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 ICacheMock.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 ICacheMock.FlushAll")
  148. }
  149. }
  150. type mICacheMockGet struct {
  151. mock *ICacheMock
  152. defaultExpectation *ICacheMockGetExpectation
  153. expectations []*ICacheMockGetExpectation
  154. callArgs []*ICacheMockGetParams
  155. mutex sync.RWMutex
  156. }
  157. // ICacheMockGetExpectation specifies expectation struct of the ICache.Get
  158. type ICacheMockGetExpectation struct {
  159. mock *ICacheMock
  160. params *ICacheMockGetParams
  161. results *ICacheMockGetResults
  162. Counter uint64
  163. }
  164. // ICacheMockGetParams contains parameters of the ICache.Get
  165. type ICacheMockGetParams struct {
  166. key string
  167. }
  168. // ICacheMockGetResults contains results of the ICache.Get
  169. type ICacheMockGetResults struct {
  170. p1 interface{}
  171. b1 bool
  172. }
  173. // Expect sets up expected params for ICache.Get
  174. func (mmGet *mICacheMockGet) Expect(key string) *mICacheMockGet {
  175. if mmGet.mock.funcGet != nil {
  176. mmGet.mock.t.Fatalf("ICacheMock.Get mock is already set by Set")
  177. }
  178. if mmGet.defaultExpectation == nil {
  179. mmGet.defaultExpectation = &ICacheMockGetExpectation{}
  180. }
  181. mmGet.defaultExpectation.params = &ICacheMockGetParams{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 ICache.Get
  190. func (mmGet *mICacheMockGet) Inspect(f func(key string)) *mICacheMockGet {
  191. if mmGet.mock.inspectFuncGet != nil {
  192. mmGet.mock.t.Fatalf("Inspect function is already set for ICacheMock.Get")
  193. }
  194. mmGet.mock.inspectFuncGet = f
  195. return mmGet
  196. }
  197. // Return sets up results that will be returned by ICache.Get
  198. func (mmGet *mICacheMockGet) Return(p1 interface{}, b1 bool) *ICacheMock {
  199. if mmGet.mock.funcGet != nil {
  200. mmGet.mock.t.Fatalf("ICacheMock.Get mock is already set by Set")
  201. }
  202. if mmGet.defaultExpectation == nil {
  203. mmGet.defaultExpectation = &ICacheMockGetExpectation{mock: mmGet.mock}
  204. }
  205. mmGet.defaultExpectation.results = &ICacheMockGetResults{p1, b1}
  206. return mmGet.mock
  207. }
  208. //Set uses given function f to mock the ICache.Get method
  209. func (mmGet *mICacheMockGet) Set(f func(key string) (p1 interface{}, b1 bool)) *ICacheMock {
  210. if mmGet.defaultExpectation != nil {
  211. mmGet.mock.t.Fatalf("Default expectation is already set for the ICache.Get method")
  212. }
  213. if len(mmGet.expectations) > 0 {
  214. mmGet.mock.t.Fatalf("Some expectations are already set for the ICache.Get method")
  215. }
  216. mmGet.mock.funcGet = f
  217. return mmGet.mock
  218. }
  219. // When sets expectation for the ICache.Get which will trigger the result defined by the following
  220. // Then helper
  221. func (mmGet *mICacheMockGet) When(key string) *ICacheMockGetExpectation {
  222. if mmGet.mock.funcGet != nil {
  223. mmGet.mock.t.Fatalf("ICacheMock.Get mock is already set by Set")
  224. }
  225. expectation := &ICacheMockGetExpectation{
  226. mock: mmGet.mock,
  227. params: &ICacheMockGetParams{key},
  228. }
  229. mmGet.expectations = append(mmGet.expectations, expectation)
  230. return expectation
  231. }
  232. // Then sets up ICache.Get return parameters for the expectation previously defined by the When method
  233. func (e *ICacheMockGetExpectation) Then(p1 interface{}, b1 bool) *ICacheMock {
  234. e.results = &ICacheMockGetResults{p1, b1}
  235. return e.mock
  236. }
  237. // Get implements interfaces.ICache
  238. func (mmGet *ICacheMock) 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 := &ICacheMockGetParams{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 := ICacheMockGetParams{key}
  259. if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
  260. mmGet.t.Errorf("ICacheMock.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 ICacheMock.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 ICacheMock.Get. %v", key)
  272. return
  273. }
  274. // GetAfterCounter returns a count of finished ICacheMock.Get invocations
  275. func (mmGet *ICacheMock) GetAfterCounter() uint64 {
  276. return mm_atomic.LoadUint64(&mmGet.afterGetCounter)
  277. }
  278. // GetBeforeCounter returns a count of ICacheMock.Get invocations
  279. func (mmGet *ICacheMock) GetBeforeCounter() uint64 {
  280. return mm_atomic.LoadUint64(&mmGet.beforeGetCounter)
  281. }
  282. // Calls returns a list of arguments used in each call to ICacheMock.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 *mICacheMockGet) Calls() []*ICacheMockGetParams {
  285. mmGet.mutex.RLock()
  286. argCopy := make([]*ICacheMockGetParams, 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 *ICacheMock) 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 *ICacheMock) MinimockGetInspect() {
  311. for _, e := range m.GetMock.expectations {
  312. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  313. m.t.Errorf("Expected call to ICacheMock.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 ICacheMock.Get")
  320. } else {
  321. m.t.Errorf("Expected call to ICacheMock.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 ICacheMock.Get")
  327. }
  328. }
  329. type mICacheMockSet struct {
  330. mock *ICacheMock
  331. defaultExpectation *ICacheMockSetExpectation
  332. expectations []*ICacheMockSetExpectation
  333. callArgs []*ICacheMockSetParams
  334. mutex sync.RWMutex
  335. }
  336. // ICacheMockSetExpectation specifies expectation struct of the ICache.Set
  337. type ICacheMockSetExpectation struct {
  338. mock *ICacheMock
  339. params *ICacheMockSetParams
  340. Counter uint64
  341. }
  342. // ICacheMockSetParams contains parameters of the ICache.Set
  343. type ICacheMockSetParams struct {
  344. key string
  345. value interface{}
  346. }
  347. // Expect sets up expected params for ICache.Set
  348. func (mmSet *mICacheMockSet) Expect(key string, value interface{}) *mICacheMockSet {
  349. if mmSet.mock.funcSet != nil {
  350. mmSet.mock.t.Fatalf("ICacheMock.Set mock is already set by Set")
  351. }
  352. if mmSet.defaultExpectation == nil {
  353. mmSet.defaultExpectation = &ICacheMockSetExpectation{}
  354. }
  355. mmSet.defaultExpectation.params = &ICacheMockSetParams{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 ICache.Set
  364. func (mmSet *mICacheMockSet) Inspect(f func(key string, value interface{})) *mICacheMockSet {
  365. if mmSet.mock.inspectFuncSet != nil {
  366. mmSet.mock.t.Fatalf("Inspect function is already set for ICacheMock.Set")
  367. }
  368. mmSet.mock.inspectFuncSet = f
  369. return mmSet
  370. }
  371. // Return sets up results that will be returned by ICache.Set
  372. func (mmSet *mICacheMockSet) Return() *ICacheMock {
  373. if mmSet.mock.funcSet != nil {
  374. mmSet.mock.t.Fatalf("ICacheMock.Set mock is already set by Set")
  375. }
  376. if mmSet.defaultExpectation == nil {
  377. mmSet.defaultExpectation = &ICacheMockSetExpectation{mock: mmSet.mock}
  378. }
  379. return mmSet.mock
  380. }
  381. //Set uses given function f to mock the ICache.Set method
  382. func (mmSet *mICacheMockSet) Set(f func(key string, value interface{})) *ICacheMock {
  383. if mmSet.defaultExpectation != nil {
  384. mmSet.mock.t.Fatalf("Default expectation is already set for the ICache.Set method")
  385. }
  386. if len(mmSet.expectations) > 0 {
  387. mmSet.mock.t.Fatalf("Some expectations are already set for the ICache.Set method")
  388. }
  389. mmSet.mock.funcSet = f
  390. return mmSet.mock
  391. }
  392. // Set implements interfaces.ICache
  393. func (mmSet *ICacheMock) 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 := &ICacheMockSetParams{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 := ICacheMockSetParams{key, value}
  414. if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
  415. mmSet.t.Errorf("ICacheMock.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 ICacheMock.Set. %v %v", key, value)
  424. }
  425. // SetAfterCounter returns a count of finished ICacheMock.Set invocations
  426. func (mmSet *ICacheMock) SetAfterCounter() uint64 {
  427. return mm_atomic.LoadUint64(&mmSet.afterSetCounter)
  428. }
  429. // SetBeforeCounter returns a count of ICacheMock.Set invocations
  430. func (mmSet *ICacheMock) SetBeforeCounter() uint64 {
  431. return mm_atomic.LoadUint64(&mmSet.beforeSetCounter)
  432. }
  433. // Calls returns a list of arguments used in each call to ICacheMock.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 *mICacheMockSet) Calls() []*ICacheMockSetParams {
  436. mmSet.mutex.RLock()
  437. argCopy := make([]*ICacheMockSetParams, 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 *ICacheMock) 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 *ICacheMock) MinimockSetInspect() {
  462. for _, e := range m.SetMock.expectations {
  463. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  464. m.t.Errorf("Expected call to ICacheMock.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 ICacheMock.Set")
  471. } else {
  472. m.t.Errorf("Expected call to ICacheMock.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 ICacheMock.Set")
  478. }
  479. }
  480. // MinimockFinish checks that all mocked methods have been called the expected number of times
  481. func (m *ICacheMock) 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 *ICacheMock) 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 *ICacheMock) minimockDone() bool {
  505. done := true
  506. return done &&
  507. m.MinimockFlushAllDone() &&
  508. m.MinimockGetDone() &&
  509. m.MinimockSetDone()
  510. }