cache_service_minimock.go 21 KB

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