thing_notification_repository_minimock.go 68 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696
  1. // Code generated by http://github.com/gojuno/minimock (v3.3.14). DO NOT EDIT.
  2. package mocks
  3. //go:generate minimock -i git.dmitriygnatenko.ru/dima/homethings/internal/api/v1/notification.ThingNotificationRepository -o thing_notification_repository_minimock.go -n ThingNotificationRepositoryMock -p mocks
  4. import (
  5. "context"
  6. "sync"
  7. mm_atomic "sync/atomic"
  8. mm_time "time"
  9. "git.dmitriygnatenko.ru/dima/homethings/internal/models"
  10. "github.com/gojuno/minimock/v3"
  11. )
  12. // ThingNotificationRepositoryMock implements notification.ThingNotificationRepository
  13. type ThingNotificationRepositoryMock struct {
  14. t minimock.Tester
  15. finishOnce sync.Once
  16. funcAdd func(ctx context.Context, req models.AddThingNotificationRequest) (err error)
  17. inspectFuncAdd func(ctx context.Context, req models.AddThingNotificationRequest)
  18. afterAddCounter uint64
  19. beforeAddCounter uint64
  20. AddMock mThingNotificationRepositoryMockAdd
  21. funcDelete func(ctx context.Context, id uint64) (err error)
  22. inspectFuncDelete func(ctx context.Context, id uint64)
  23. afterDeleteCounter uint64
  24. beforeDeleteCounter uint64
  25. DeleteMock mThingNotificationRepositoryMockDelete
  26. funcGet func(ctx context.Context, id uint64) (tp1 *models.ThingNotification, err error)
  27. inspectFuncGet func(ctx context.Context, id uint64)
  28. afterGetCounter uint64
  29. beforeGetCounter uint64
  30. GetMock mThingNotificationRepositoryMockGet
  31. funcGetExpired func(ctx context.Context) (ea1 []models.ExtThingNotification, err error)
  32. inspectFuncGetExpired func(ctx context.Context)
  33. afterGetExpiredCounter uint64
  34. beforeGetExpiredCounter uint64
  35. GetExpiredMock mThingNotificationRepositoryMockGetExpired
  36. funcUpdate func(ctx context.Context, req models.UpdateThingNotificationRequest) (err error)
  37. inspectFuncUpdate func(ctx context.Context, req models.UpdateThingNotificationRequest)
  38. afterUpdateCounter uint64
  39. beforeUpdateCounter uint64
  40. UpdateMock mThingNotificationRepositoryMockUpdate
  41. }
  42. // NewThingNotificationRepositoryMock returns a mock for notification.ThingNotificationRepository
  43. func NewThingNotificationRepositoryMock(t minimock.Tester) *ThingNotificationRepositoryMock {
  44. m := &ThingNotificationRepositoryMock{t: t}
  45. if controller, ok := t.(minimock.MockController); ok {
  46. controller.RegisterMocker(m)
  47. }
  48. m.AddMock = mThingNotificationRepositoryMockAdd{mock: m}
  49. m.AddMock.callArgs = []*ThingNotificationRepositoryMockAddParams{}
  50. m.DeleteMock = mThingNotificationRepositoryMockDelete{mock: m}
  51. m.DeleteMock.callArgs = []*ThingNotificationRepositoryMockDeleteParams{}
  52. m.GetMock = mThingNotificationRepositoryMockGet{mock: m}
  53. m.GetMock.callArgs = []*ThingNotificationRepositoryMockGetParams{}
  54. m.GetExpiredMock = mThingNotificationRepositoryMockGetExpired{mock: m}
  55. m.GetExpiredMock.callArgs = []*ThingNotificationRepositoryMockGetExpiredParams{}
  56. m.UpdateMock = mThingNotificationRepositoryMockUpdate{mock: m}
  57. m.UpdateMock.callArgs = []*ThingNotificationRepositoryMockUpdateParams{}
  58. t.Cleanup(m.MinimockFinish)
  59. return m
  60. }
  61. type mThingNotificationRepositoryMockAdd struct {
  62. optional bool
  63. mock *ThingNotificationRepositoryMock
  64. defaultExpectation *ThingNotificationRepositoryMockAddExpectation
  65. expectations []*ThingNotificationRepositoryMockAddExpectation
  66. callArgs []*ThingNotificationRepositoryMockAddParams
  67. mutex sync.RWMutex
  68. expectedInvocations uint64
  69. }
  70. // ThingNotificationRepositoryMockAddExpectation specifies expectation struct of the ThingNotificationRepository.Add
  71. type ThingNotificationRepositoryMockAddExpectation struct {
  72. mock *ThingNotificationRepositoryMock
  73. params *ThingNotificationRepositoryMockAddParams
  74. paramPtrs *ThingNotificationRepositoryMockAddParamPtrs
  75. results *ThingNotificationRepositoryMockAddResults
  76. Counter uint64
  77. }
  78. // ThingNotificationRepositoryMockAddParams contains parameters of the ThingNotificationRepository.Add
  79. type ThingNotificationRepositoryMockAddParams struct {
  80. ctx context.Context
  81. req models.AddThingNotificationRequest
  82. }
  83. // ThingNotificationRepositoryMockAddParamPtrs contains pointers to parameters of the ThingNotificationRepository.Add
  84. type ThingNotificationRepositoryMockAddParamPtrs struct {
  85. ctx *context.Context
  86. req *models.AddThingNotificationRequest
  87. }
  88. // ThingNotificationRepositoryMockAddResults contains results of the ThingNotificationRepository.Add
  89. type ThingNotificationRepositoryMockAddResults struct {
  90. err error
  91. }
  92. // Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
  93. // the test will fail minimock's automatic final call check if the mocked method was not called at least once.
  94. // Optional() makes method check to work in '0 or more' mode.
  95. // It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
  96. // catch the problems when the expected method call is totally skipped during test run.
  97. func (mmAdd *mThingNotificationRepositoryMockAdd) Optional() *mThingNotificationRepositoryMockAdd {
  98. mmAdd.optional = true
  99. return mmAdd
  100. }
  101. // Expect sets up expected params for ThingNotificationRepository.Add
  102. func (mmAdd *mThingNotificationRepositoryMockAdd) Expect(ctx context.Context, req models.AddThingNotificationRequest) *mThingNotificationRepositoryMockAdd {
  103. if mmAdd.mock.funcAdd != nil {
  104. mmAdd.mock.t.Fatalf("ThingNotificationRepositoryMock.Add mock is already set by Set")
  105. }
  106. if mmAdd.defaultExpectation == nil {
  107. mmAdd.defaultExpectation = &ThingNotificationRepositoryMockAddExpectation{}
  108. }
  109. if mmAdd.defaultExpectation.paramPtrs != nil {
  110. mmAdd.mock.t.Fatalf("ThingNotificationRepositoryMock.Add mock is already set by ExpectParams functions")
  111. }
  112. mmAdd.defaultExpectation.params = &ThingNotificationRepositoryMockAddParams{ctx, req}
  113. for _, e := range mmAdd.expectations {
  114. if minimock.Equal(e.params, mmAdd.defaultExpectation.params) {
  115. mmAdd.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmAdd.defaultExpectation.params)
  116. }
  117. }
  118. return mmAdd
  119. }
  120. // ExpectCtxParam1 sets up expected param ctx for ThingNotificationRepository.Add
  121. func (mmAdd *mThingNotificationRepositoryMockAdd) ExpectCtxParam1(ctx context.Context) *mThingNotificationRepositoryMockAdd {
  122. if mmAdd.mock.funcAdd != nil {
  123. mmAdd.mock.t.Fatalf("ThingNotificationRepositoryMock.Add mock is already set by Set")
  124. }
  125. if mmAdd.defaultExpectation == nil {
  126. mmAdd.defaultExpectation = &ThingNotificationRepositoryMockAddExpectation{}
  127. }
  128. if mmAdd.defaultExpectation.params != nil {
  129. mmAdd.mock.t.Fatalf("ThingNotificationRepositoryMock.Add mock is already set by Expect")
  130. }
  131. if mmAdd.defaultExpectation.paramPtrs == nil {
  132. mmAdd.defaultExpectation.paramPtrs = &ThingNotificationRepositoryMockAddParamPtrs{}
  133. }
  134. mmAdd.defaultExpectation.paramPtrs.ctx = &ctx
  135. return mmAdd
  136. }
  137. // ExpectReqParam2 sets up expected param req for ThingNotificationRepository.Add
  138. func (mmAdd *mThingNotificationRepositoryMockAdd) ExpectReqParam2(req models.AddThingNotificationRequest) *mThingNotificationRepositoryMockAdd {
  139. if mmAdd.mock.funcAdd != nil {
  140. mmAdd.mock.t.Fatalf("ThingNotificationRepositoryMock.Add mock is already set by Set")
  141. }
  142. if mmAdd.defaultExpectation == nil {
  143. mmAdd.defaultExpectation = &ThingNotificationRepositoryMockAddExpectation{}
  144. }
  145. if mmAdd.defaultExpectation.params != nil {
  146. mmAdd.mock.t.Fatalf("ThingNotificationRepositoryMock.Add mock is already set by Expect")
  147. }
  148. if mmAdd.defaultExpectation.paramPtrs == nil {
  149. mmAdd.defaultExpectation.paramPtrs = &ThingNotificationRepositoryMockAddParamPtrs{}
  150. }
  151. mmAdd.defaultExpectation.paramPtrs.req = &req
  152. return mmAdd
  153. }
  154. // Inspect accepts an inspector function that has same arguments as the ThingNotificationRepository.Add
  155. func (mmAdd *mThingNotificationRepositoryMockAdd) Inspect(f func(ctx context.Context, req models.AddThingNotificationRequest)) *mThingNotificationRepositoryMockAdd {
  156. if mmAdd.mock.inspectFuncAdd != nil {
  157. mmAdd.mock.t.Fatalf("Inspect function is already set for ThingNotificationRepositoryMock.Add")
  158. }
  159. mmAdd.mock.inspectFuncAdd = f
  160. return mmAdd
  161. }
  162. // Return sets up results that will be returned by ThingNotificationRepository.Add
  163. func (mmAdd *mThingNotificationRepositoryMockAdd) Return(err error) *ThingNotificationRepositoryMock {
  164. if mmAdd.mock.funcAdd != nil {
  165. mmAdd.mock.t.Fatalf("ThingNotificationRepositoryMock.Add mock is already set by Set")
  166. }
  167. if mmAdd.defaultExpectation == nil {
  168. mmAdd.defaultExpectation = &ThingNotificationRepositoryMockAddExpectation{mock: mmAdd.mock}
  169. }
  170. mmAdd.defaultExpectation.results = &ThingNotificationRepositoryMockAddResults{err}
  171. return mmAdd.mock
  172. }
  173. // Set uses given function f to mock the ThingNotificationRepository.Add method
  174. func (mmAdd *mThingNotificationRepositoryMockAdd) Set(f func(ctx context.Context, req models.AddThingNotificationRequest) (err error)) *ThingNotificationRepositoryMock {
  175. if mmAdd.defaultExpectation != nil {
  176. mmAdd.mock.t.Fatalf("Default expectation is already set for the ThingNotificationRepository.Add method")
  177. }
  178. if len(mmAdd.expectations) > 0 {
  179. mmAdd.mock.t.Fatalf("Some expectations are already set for the ThingNotificationRepository.Add method")
  180. }
  181. mmAdd.mock.funcAdd = f
  182. return mmAdd.mock
  183. }
  184. // When sets expectation for the ThingNotificationRepository.Add which will trigger the result defined by the following
  185. // Then helper
  186. func (mmAdd *mThingNotificationRepositoryMockAdd) When(ctx context.Context, req models.AddThingNotificationRequest) *ThingNotificationRepositoryMockAddExpectation {
  187. if mmAdd.mock.funcAdd != nil {
  188. mmAdd.mock.t.Fatalf("ThingNotificationRepositoryMock.Add mock is already set by Set")
  189. }
  190. expectation := &ThingNotificationRepositoryMockAddExpectation{
  191. mock: mmAdd.mock,
  192. params: &ThingNotificationRepositoryMockAddParams{ctx, req},
  193. }
  194. mmAdd.expectations = append(mmAdd.expectations, expectation)
  195. return expectation
  196. }
  197. // Then sets up ThingNotificationRepository.Add return parameters for the expectation previously defined by the When method
  198. func (e *ThingNotificationRepositoryMockAddExpectation) Then(err error) *ThingNotificationRepositoryMock {
  199. e.results = &ThingNotificationRepositoryMockAddResults{err}
  200. return e.mock
  201. }
  202. // Times sets number of times ThingNotificationRepository.Add should be invoked
  203. func (mmAdd *mThingNotificationRepositoryMockAdd) Times(n uint64) *mThingNotificationRepositoryMockAdd {
  204. if n == 0 {
  205. mmAdd.mock.t.Fatalf("Times of ThingNotificationRepositoryMock.Add mock can not be zero")
  206. }
  207. mm_atomic.StoreUint64(&mmAdd.expectedInvocations, n)
  208. return mmAdd
  209. }
  210. func (mmAdd *mThingNotificationRepositoryMockAdd) invocationsDone() bool {
  211. if len(mmAdd.expectations) == 0 && mmAdd.defaultExpectation == nil && mmAdd.mock.funcAdd == nil {
  212. return true
  213. }
  214. totalInvocations := mm_atomic.LoadUint64(&mmAdd.mock.afterAddCounter)
  215. expectedInvocations := mm_atomic.LoadUint64(&mmAdd.expectedInvocations)
  216. return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
  217. }
  218. // Add implements notification.ThingNotificationRepository
  219. func (mmAdd *ThingNotificationRepositoryMock) Add(ctx context.Context, req models.AddThingNotificationRequest) (err error) {
  220. mm_atomic.AddUint64(&mmAdd.beforeAddCounter, 1)
  221. defer mm_atomic.AddUint64(&mmAdd.afterAddCounter, 1)
  222. if mmAdd.inspectFuncAdd != nil {
  223. mmAdd.inspectFuncAdd(ctx, req)
  224. }
  225. mm_params := ThingNotificationRepositoryMockAddParams{ctx, req}
  226. // Record call args
  227. mmAdd.AddMock.mutex.Lock()
  228. mmAdd.AddMock.callArgs = append(mmAdd.AddMock.callArgs, &mm_params)
  229. mmAdd.AddMock.mutex.Unlock()
  230. for _, e := range mmAdd.AddMock.expectations {
  231. if minimock.Equal(*e.params, mm_params) {
  232. mm_atomic.AddUint64(&e.Counter, 1)
  233. return e.results.err
  234. }
  235. }
  236. if mmAdd.AddMock.defaultExpectation != nil {
  237. mm_atomic.AddUint64(&mmAdd.AddMock.defaultExpectation.Counter, 1)
  238. mm_want := mmAdd.AddMock.defaultExpectation.params
  239. mm_want_ptrs := mmAdd.AddMock.defaultExpectation.paramPtrs
  240. mm_got := ThingNotificationRepositoryMockAddParams{ctx, req}
  241. if mm_want_ptrs != nil {
  242. if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
  243. mmAdd.t.Errorf("ThingNotificationRepositoryMock.Add got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
  244. }
  245. if mm_want_ptrs.req != nil && !minimock.Equal(*mm_want_ptrs.req, mm_got.req) {
  246. mmAdd.t.Errorf("ThingNotificationRepositoryMock.Add got unexpected parameter req, want: %#v, got: %#v%s\n", *mm_want_ptrs.req, mm_got.req, minimock.Diff(*mm_want_ptrs.req, mm_got.req))
  247. }
  248. } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
  249. mmAdd.t.Errorf("ThingNotificationRepositoryMock.Add got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
  250. }
  251. mm_results := mmAdd.AddMock.defaultExpectation.results
  252. if mm_results == nil {
  253. mmAdd.t.Fatal("No results are set for the ThingNotificationRepositoryMock.Add")
  254. }
  255. return (*mm_results).err
  256. }
  257. if mmAdd.funcAdd != nil {
  258. return mmAdd.funcAdd(ctx, req)
  259. }
  260. mmAdd.t.Fatalf("Unexpected call to ThingNotificationRepositoryMock.Add. %v %v", ctx, req)
  261. return
  262. }
  263. // AddAfterCounter returns a count of finished ThingNotificationRepositoryMock.Add invocations
  264. func (mmAdd *ThingNotificationRepositoryMock) AddAfterCounter() uint64 {
  265. return mm_atomic.LoadUint64(&mmAdd.afterAddCounter)
  266. }
  267. // AddBeforeCounter returns a count of ThingNotificationRepositoryMock.Add invocations
  268. func (mmAdd *ThingNotificationRepositoryMock) AddBeforeCounter() uint64 {
  269. return mm_atomic.LoadUint64(&mmAdd.beforeAddCounter)
  270. }
  271. // Calls returns a list of arguments used in each call to ThingNotificationRepositoryMock.Add.
  272. // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
  273. func (mmAdd *mThingNotificationRepositoryMockAdd) Calls() []*ThingNotificationRepositoryMockAddParams {
  274. mmAdd.mutex.RLock()
  275. argCopy := make([]*ThingNotificationRepositoryMockAddParams, len(mmAdd.callArgs))
  276. copy(argCopy, mmAdd.callArgs)
  277. mmAdd.mutex.RUnlock()
  278. return argCopy
  279. }
  280. // MinimockAddDone returns true if the count of the Add invocations corresponds
  281. // the number of defined expectations
  282. func (m *ThingNotificationRepositoryMock) MinimockAddDone() bool {
  283. if m.AddMock.optional {
  284. // Optional methods provide '0 or more' call count restriction.
  285. return true
  286. }
  287. for _, e := range m.AddMock.expectations {
  288. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  289. return false
  290. }
  291. }
  292. return m.AddMock.invocationsDone()
  293. }
  294. // MinimockAddInspect logs each unmet expectation
  295. func (m *ThingNotificationRepositoryMock) MinimockAddInspect() {
  296. for _, e := range m.AddMock.expectations {
  297. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  298. m.t.Errorf("Expected call to ThingNotificationRepositoryMock.Add with params: %#v", *e.params)
  299. }
  300. }
  301. afterAddCounter := mm_atomic.LoadUint64(&m.afterAddCounter)
  302. // if default expectation was set then invocations count should be greater than zero
  303. if m.AddMock.defaultExpectation != nil && afterAddCounter < 1 {
  304. if m.AddMock.defaultExpectation.params == nil {
  305. m.t.Error("Expected call to ThingNotificationRepositoryMock.Add")
  306. } else {
  307. m.t.Errorf("Expected call to ThingNotificationRepositoryMock.Add with params: %#v", *m.AddMock.defaultExpectation.params)
  308. }
  309. }
  310. // if func was set then invocations count should be greater than zero
  311. if m.funcAdd != nil && afterAddCounter < 1 {
  312. m.t.Error("Expected call to ThingNotificationRepositoryMock.Add")
  313. }
  314. if !m.AddMock.invocationsDone() && afterAddCounter > 0 {
  315. m.t.Errorf("Expected %d calls to ThingNotificationRepositoryMock.Add but found %d calls",
  316. mm_atomic.LoadUint64(&m.AddMock.expectedInvocations), afterAddCounter)
  317. }
  318. }
  319. type mThingNotificationRepositoryMockDelete struct {
  320. optional bool
  321. mock *ThingNotificationRepositoryMock
  322. defaultExpectation *ThingNotificationRepositoryMockDeleteExpectation
  323. expectations []*ThingNotificationRepositoryMockDeleteExpectation
  324. callArgs []*ThingNotificationRepositoryMockDeleteParams
  325. mutex sync.RWMutex
  326. expectedInvocations uint64
  327. }
  328. // ThingNotificationRepositoryMockDeleteExpectation specifies expectation struct of the ThingNotificationRepository.Delete
  329. type ThingNotificationRepositoryMockDeleteExpectation struct {
  330. mock *ThingNotificationRepositoryMock
  331. params *ThingNotificationRepositoryMockDeleteParams
  332. paramPtrs *ThingNotificationRepositoryMockDeleteParamPtrs
  333. results *ThingNotificationRepositoryMockDeleteResults
  334. Counter uint64
  335. }
  336. // ThingNotificationRepositoryMockDeleteParams contains parameters of the ThingNotificationRepository.Delete
  337. type ThingNotificationRepositoryMockDeleteParams struct {
  338. ctx context.Context
  339. id uint64
  340. }
  341. // ThingNotificationRepositoryMockDeleteParamPtrs contains pointers to parameters of the ThingNotificationRepository.Delete
  342. type ThingNotificationRepositoryMockDeleteParamPtrs struct {
  343. ctx *context.Context
  344. id *uint64
  345. }
  346. // ThingNotificationRepositoryMockDeleteResults contains results of the ThingNotificationRepository.Delete
  347. type ThingNotificationRepositoryMockDeleteResults struct {
  348. err error
  349. }
  350. // Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
  351. // the test will fail minimock's automatic final call check if the mocked method was not called at least once.
  352. // Optional() makes method check to work in '0 or more' mode.
  353. // It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
  354. // catch the problems when the expected method call is totally skipped during test run.
  355. func (mmDelete *mThingNotificationRepositoryMockDelete) Optional() *mThingNotificationRepositoryMockDelete {
  356. mmDelete.optional = true
  357. return mmDelete
  358. }
  359. // Expect sets up expected params for ThingNotificationRepository.Delete
  360. func (mmDelete *mThingNotificationRepositoryMockDelete) Expect(ctx context.Context, id uint64) *mThingNotificationRepositoryMockDelete {
  361. if mmDelete.mock.funcDelete != nil {
  362. mmDelete.mock.t.Fatalf("ThingNotificationRepositoryMock.Delete mock is already set by Set")
  363. }
  364. if mmDelete.defaultExpectation == nil {
  365. mmDelete.defaultExpectation = &ThingNotificationRepositoryMockDeleteExpectation{}
  366. }
  367. if mmDelete.defaultExpectation.paramPtrs != nil {
  368. mmDelete.mock.t.Fatalf("ThingNotificationRepositoryMock.Delete mock is already set by ExpectParams functions")
  369. }
  370. mmDelete.defaultExpectation.params = &ThingNotificationRepositoryMockDeleteParams{ctx, id}
  371. for _, e := range mmDelete.expectations {
  372. if minimock.Equal(e.params, mmDelete.defaultExpectation.params) {
  373. mmDelete.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmDelete.defaultExpectation.params)
  374. }
  375. }
  376. return mmDelete
  377. }
  378. // ExpectCtxParam1 sets up expected param ctx for ThingNotificationRepository.Delete
  379. func (mmDelete *mThingNotificationRepositoryMockDelete) ExpectCtxParam1(ctx context.Context) *mThingNotificationRepositoryMockDelete {
  380. if mmDelete.mock.funcDelete != nil {
  381. mmDelete.mock.t.Fatalf("ThingNotificationRepositoryMock.Delete mock is already set by Set")
  382. }
  383. if mmDelete.defaultExpectation == nil {
  384. mmDelete.defaultExpectation = &ThingNotificationRepositoryMockDeleteExpectation{}
  385. }
  386. if mmDelete.defaultExpectation.params != nil {
  387. mmDelete.mock.t.Fatalf("ThingNotificationRepositoryMock.Delete mock is already set by Expect")
  388. }
  389. if mmDelete.defaultExpectation.paramPtrs == nil {
  390. mmDelete.defaultExpectation.paramPtrs = &ThingNotificationRepositoryMockDeleteParamPtrs{}
  391. }
  392. mmDelete.defaultExpectation.paramPtrs.ctx = &ctx
  393. return mmDelete
  394. }
  395. // ExpectIdParam2 sets up expected param id for ThingNotificationRepository.Delete
  396. func (mmDelete *mThingNotificationRepositoryMockDelete) ExpectIdParam2(id uint64) *mThingNotificationRepositoryMockDelete {
  397. if mmDelete.mock.funcDelete != nil {
  398. mmDelete.mock.t.Fatalf("ThingNotificationRepositoryMock.Delete mock is already set by Set")
  399. }
  400. if mmDelete.defaultExpectation == nil {
  401. mmDelete.defaultExpectation = &ThingNotificationRepositoryMockDeleteExpectation{}
  402. }
  403. if mmDelete.defaultExpectation.params != nil {
  404. mmDelete.mock.t.Fatalf("ThingNotificationRepositoryMock.Delete mock is already set by Expect")
  405. }
  406. if mmDelete.defaultExpectation.paramPtrs == nil {
  407. mmDelete.defaultExpectation.paramPtrs = &ThingNotificationRepositoryMockDeleteParamPtrs{}
  408. }
  409. mmDelete.defaultExpectation.paramPtrs.id = &id
  410. return mmDelete
  411. }
  412. // Inspect accepts an inspector function that has same arguments as the ThingNotificationRepository.Delete
  413. func (mmDelete *mThingNotificationRepositoryMockDelete) Inspect(f func(ctx context.Context, id uint64)) *mThingNotificationRepositoryMockDelete {
  414. if mmDelete.mock.inspectFuncDelete != nil {
  415. mmDelete.mock.t.Fatalf("Inspect function is already set for ThingNotificationRepositoryMock.Delete")
  416. }
  417. mmDelete.mock.inspectFuncDelete = f
  418. return mmDelete
  419. }
  420. // Return sets up results that will be returned by ThingNotificationRepository.Delete
  421. func (mmDelete *mThingNotificationRepositoryMockDelete) Return(err error) *ThingNotificationRepositoryMock {
  422. if mmDelete.mock.funcDelete != nil {
  423. mmDelete.mock.t.Fatalf("ThingNotificationRepositoryMock.Delete mock is already set by Set")
  424. }
  425. if mmDelete.defaultExpectation == nil {
  426. mmDelete.defaultExpectation = &ThingNotificationRepositoryMockDeleteExpectation{mock: mmDelete.mock}
  427. }
  428. mmDelete.defaultExpectation.results = &ThingNotificationRepositoryMockDeleteResults{err}
  429. return mmDelete.mock
  430. }
  431. // Set uses given function f to mock the ThingNotificationRepository.Delete method
  432. func (mmDelete *mThingNotificationRepositoryMockDelete) Set(f func(ctx context.Context, id uint64) (err error)) *ThingNotificationRepositoryMock {
  433. if mmDelete.defaultExpectation != nil {
  434. mmDelete.mock.t.Fatalf("Default expectation is already set for the ThingNotificationRepository.Delete method")
  435. }
  436. if len(mmDelete.expectations) > 0 {
  437. mmDelete.mock.t.Fatalf("Some expectations are already set for the ThingNotificationRepository.Delete method")
  438. }
  439. mmDelete.mock.funcDelete = f
  440. return mmDelete.mock
  441. }
  442. // When sets expectation for the ThingNotificationRepository.Delete which will trigger the result defined by the following
  443. // Then helper
  444. func (mmDelete *mThingNotificationRepositoryMockDelete) When(ctx context.Context, id uint64) *ThingNotificationRepositoryMockDeleteExpectation {
  445. if mmDelete.mock.funcDelete != nil {
  446. mmDelete.mock.t.Fatalf("ThingNotificationRepositoryMock.Delete mock is already set by Set")
  447. }
  448. expectation := &ThingNotificationRepositoryMockDeleteExpectation{
  449. mock: mmDelete.mock,
  450. params: &ThingNotificationRepositoryMockDeleteParams{ctx, id},
  451. }
  452. mmDelete.expectations = append(mmDelete.expectations, expectation)
  453. return expectation
  454. }
  455. // Then sets up ThingNotificationRepository.Delete return parameters for the expectation previously defined by the When method
  456. func (e *ThingNotificationRepositoryMockDeleteExpectation) Then(err error) *ThingNotificationRepositoryMock {
  457. e.results = &ThingNotificationRepositoryMockDeleteResults{err}
  458. return e.mock
  459. }
  460. // Times sets number of times ThingNotificationRepository.Delete should be invoked
  461. func (mmDelete *mThingNotificationRepositoryMockDelete) Times(n uint64) *mThingNotificationRepositoryMockDelete {
  462. if n == 0 {
  463. mmDelete.mock.t.Fatalf("Times of ThingNotificationRepositoryMock.Delete mock can not be zero")
  464. }
  465. mm_atomic.StoreUint64(&mmDelete.expectedInvocations, n)
  466. return mmDelete
  467. }
  468. func (mmDelete *mThingNotificationRepositoryMockDelete) invocationsDone() bool {
  469. if len(mmDelete.expectations) == 0 && mmDelete.defaultExpectation == nil && mmDelete.mock.funcDelete == nil {
  470. return true
  471. }
  472. totalInvocations := mm_atomic.LoadUint64(&mmDelete.mock.afterDeleteCounter)
  473. expectedInvocations := mm_atomic.LoadUint64(&mmDelete.expectedInvocations)
  474. return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
  475. }
  476. // Delete implements notification.ThingNotificationRepository
  477. func (mmDelete *ThingNotificationRepositoryMock) Delete(ctx context.Context, id uint64) (err error) {
  478. mm_atomic.AddUint64(&mmDelete.beforeDeleteCounter, 1)
  479. defer mm_atomic.AddUint64(&mmDelete.afterDeleteCounter, 1)
  480. if mmDelete.inspectFuncDelete != nil {
  481. mmDelete.inspectFuncDelete(ctx, id)
  482. }
  483. mm_params := ThingNotificationRepositoryMockDeleteParams{ctx, id}
  484. // Record call args
  485. mmDelete.DeleteMock.mutex.Lock()
  486. mmDelete.DeleteMock.callArgs = append(mmDelete.DeleteMock.callArgs, &mm_params)
  487. mmDelete.DeleteMock.mutex.Unlock()
  488. for _, e := range mmDelete.DeleteMock.expectations {
  489. if minimock.Equal(*e.params, mm_params) {
  490. mm_atomic.AddUint64(&e.Counter, 1)
  491. return e.results.err
  492. }
  493. }
  494. if mmDelete.DeleteMock.defaultExpectation != nil {
  495. mm_atomic.AddUint64(&mmDelete.DeleteMock.defaultExpectation.Counter, 1)
  496. mm_want := mmDelete.DeleteMock.defaultExpectation.params
  497. mm_want_ptrs := mmDelete.DeleteMock.defaultExpectation.paramPtrs
  498. mm_got := ThingNotificationRepositoryMockDeleteParams{ctx, id}
  499. if mm_want_ptrs != nil {
  500. if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
  501. mmDelete.t.Errorf("ThingNotificationRepositoryMock.Delete got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
  502. }
  503. if mm_want_ptrs.id != nil && !minimock.Equal(*mm_want_ptrs.id, mm_got.id) {
  504. mmDelete.t.Errorf("ThingNotificationRepositoryMock.Delete got unexpected parameter id, want: %#v, got: %#v%s\n", *mm_want_ptrs.id, mm_got.id, minimock.Diff(*mm_want_ptrs.id, mm_got.id))
  505. }
  506. } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
  507. mmDelete.t.Errorf("ThingNotificationRepositoryMock.Delete got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
  508. }
  509. mm_results := mmDelete.DeleteMock.defaultExpectation.results
  510. if mm_results == nil {
  511. mmDelete.t.Fatal("No results are set for the ThingNotificationRepositoryMock.Delete")
  512. }
  513. return (*mm_results).err
  514. }
  515. if mmDelete.funcDelete != nil {
  516. return mmDelete.funcDelete(ctx, id)
  517. }
  518. mmDelete.t.Fatalf("Unexpected call to ThingNotificationRepositoryMock.Delete. %v %v", ctx, id)
  519. return
  520. }
  521. // DeleteAfterCounter returns a count of finished ThingNotificationRepositoryMock.Delete invocations
  522. func (mmDelete *ThingNotificationRepositoryMock) DeleteAfterCounter() uint64 {
  523. return mm_atomic.LoadUint64(&mmDelete.afterDeleteCounter)
  524. }
  525. // DeleteBeforeCounter returns a count of ThingNotificationRepositoryMock.Delete invocations
  526. func (mmDelete *ThingNotificationRepositoryMock) DeleteBeforeCounter() uint64 {
  527. return mm_atomic.LoadUint64(&mmDelete.beforeDeleteCounter)
  528. }
  529. // Calls returns a list of arguments used in each call to ThingNotificationRepositoryMock.Delete.
  530. // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
  531. func (mmDelete *mThingNotificationRepositoryMockDelete) Calls() []*ThingNotificationRepositoryMockDeleteParams {
  532. mmDelete.mutex.RLock()
  533. argCopy := make([]*ThingNotificationRepositoryMockDeleteParams, len(mmDelete.callArgs))
  534. copy(argCopy, mmDelete.callArgs)
  535. mmDelete.mutex.RUnlock()
  536. return argCopy
  537. }
  538. // MinimockDeleteDone returns true if the count of the Delete invocations corresponds
  539. // the number of defined expectations
  540. func (m *ThingNotificationRepositoryMock) MinimockDeleteDone() bool {
  541. if m.DeleteMock.optional {
  542. // Optional methods provide '0 or more' call count restriction.
  543. return true
  544. }
  545. for _, e := range m.DeleteMock.expectations {
  546. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  547. return false
  548. }
  549. }
  550. return m.DeleteMock.invocationsDone()
  551. }
  552. // MinimockDeleteInspect logs each unmet expectation
  553. func (m *ThingNotificationRepositoryMock) MinimockDeleteInspect() {
  554. for _, e := range m.DeleteMock.expectations {
  555. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  556. m.t.Errorf("Expected call to ThingNotificationRepositoryMock.Delete with params: %#v", *e.params)
  557. }
  558. }
  559. afterDeleteCounter := mm_atomic.LoadUint64(&m.afterDeleteCounter)
  560. // if default expectation was set then invocations count should be greater than zero
  561. if m.DeleteMock.defaultExpectation != nil && afterDeleteCounter < 1 {
  562. if m.DeleteMock.defaultExpectation.params == nil {
  563. m.t.Error("Expected call to ThingNotificationRepositoryMock.Delete")
  564. } else {
  565. m.t.Errorf("Expected call to ThingNotificationRepositoryMock.Delete with params: %#v", *m.DeleteMock.defaultExpectation.params)
  566. }
  567. }
  568. // if func was set then invocations count should be greater than zero
  569. if m.funcDelete != nil && afterDeleteCounter < 1 {
  570. m.t.Error("Expected call to ThingNotificationRepositoryMock.Delete")
  571. }
  572. if !m.DeleteMock.invocationsDone() && afterDeleteCounter > 0 {
  573. m.t.Errorf("Expected %d calls to ThingNotificationRepositoryMock.Delete but found %d calls",
  574. mm_atomic.LoadUint64(&m.DeleteMock.expectedInvocations), afterDeleteCounter)
  575. }
  576. }
  577. type mThingNotificationRepositoryMockGet struct {
  578. optional bool
  579. mock *ThingNotificationRepositoryMock
  580. defaultExpectation *ThingNotificationRepositoryMockGetExpectation
  581. expectations []*ThingNotificationRepositoryMockGetExpectation
  582. callArgs []*ThingNotificationRepositoryMockGetParams
  583. mutex sync.RWMutex
  584. expectedInvocations uint64
  585. }
  586. // ThingNotificationRepositoryMockGetExpectation specifies expectation struct of the ThingNotificationRepository.Get
  587. type ThingNotificationRepositoryMockGetExpectation struct {
  588. mock *ThingNotificationRepositoryMock
  589. params *ThingNotificationRepositoryMockGetParams
  590. paramPtrs *ThingNotificationRepositoryMockGetParamPtrs
  591. results *ThingNotificationRepositoryMockGetResults
  592. Counter uint64
  593. }
  594. // ThingNotificationRepositoryMockGetParams contains parameters of the ThingNotificationRepository.Get
  595. type ThingNotificationRepositoryMockGetParams struct {
  596. ctx context.Context
  597. id uint64
  598. }
  599. // ThingNotificationRepositoryMockGetParamPtrs contains pointers to parameters of the ThingNotificationRepository.Get
  600. type ThingNotificationRepositoryMockGetParamPtrs struct {
  601. ctx *context.Context
  602. id *uint64
  603. }
  604. // ThingNotificationRepositoryMockGetResults contains results of the ThingNotificationRepository.Get
  605. type ThingNotificationRepositoryMockGetResults struct {
  606. tp1 *models.ThingNotification
  607. err error
  608. }
  609. // Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
  610. // the test will fail minimock's automatic final call check if the mocked method was not called at least once.
  611. // Optional() makes method check to work in '0 or more' mode.
  612. // It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
  613. // catch the problems when the expected method call is totally skipped during test run.
  614. func (mmGet *mThingNotificationRepositoryMockGet) Optional() *mThingNotificationRepositoryMockGet {
  615. mmGet.optional = true
  616. return mmGet
  617. }
  618. // Expect sets up expected params for ThingNotificationRepository.Get
  619. func (mmGet *mThingNotificationRepositoryMockGet) Expect(ctx context.Context, id uint64) *mThingNotificationRepositoryMockGet {
  620. if mmGet.mock.funcGet != nil {
  621. mmGet.mock.t.Fatalf("ThingNotificationRepositoryMock.Get mock is already set by Set")
  622. }
  623. if mmGet.defaultExpectation == nil {
  624. mmGet.defaultExpectation = &ThingNotificationRepositoryMockGetExpectation{}
  625. }
  626. if mmGet.defaultExpectation.paramPtrs != nil {
  627. mmGet.mock.t.Fatalf("ThingNotificationRepositoryMock.Get mock is already set by ExpectParams functions")
  628. }
  629. mmGet.defaultExpectation.params = &ThingNotificationRepositoryMockGetParams{ctx, id}
  630. for _, e := range mmGet.expectations {
  631. if minimock.Equal(e.params, mmGet.defaultExpectation.params) {
  632. mmGet.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGet.defaultExpectation.params)
  633. }
  634. }
  635. return mmGet
  636. }
  637. // ExpectCtxParam1 sets up expected param ctx for ThingNotificationRepository.Get
  638. func (mmGet *mThingNotificationRepositoryMockGet) ExpectCtxParam1(ctx context.Context) *mThingNotificationRepositoryMockGet {
  639. if mmGet.mock.funcGet != nil {
  640. mmGet.mock.t.Fatalf("ThingNotificationRepositoryMock.Get mock is already set by Set")
  641. }
  642. if mmGet.defaultExpectation == nil {
  643. mmGet.defaultExpectation = &ThingNotificationRepositoryMockGetExpectation{}
  644. }
  645. if mmGet.defaultExpectation.params != nil {
  646. mmGet.mock.t.Fatalf("ThingNotificationRepositoryMock.Get mock is already set by Expect")
  647. }
  648. if mmGet.defaultExpectation.paramPtrs == nil {
  649. mmGet.defaultExpectation.paramPtrs = &ThingNotificationRepositoryMockGetParamPtrs{}
  650. }
  651. mmGet.defaultExpectation.paramPtrs.ctx = &ctx
  652. return mmGet
  653. }
  654. // ExpectIdParam2 sets up expected param id for ThingNotificationRepository.Get
  655. func (mmGet *mThingNotificationRepositoryMockGet) ExpectIdParam2(id uint64) *mThingNotificationRepositoryMockGet {
  656. if mmGet.mock.funcGet != nil {
  657. mmGet.mock.t.Fatalf("ThingNotificationRepositoryMock.Get mock is already set by Set")
  658. }
  659. if mmGet.defaultExpectation == nil {
  660. mmGet.defaultExpectation = &ThingNotificationRepositoryMockGetExpectation{}
  661. }
  662. if mmGet.defaultExpectation.params != nil {
  663. mmGet.mock.t.Fatalf("ThingNotificationRepositoryMock.Get mock is already set by Expect")
  664. }
  665. if mmGet.defaultExpectation.paramPtrs == nil {
  666. mmGet.defaultExpectation.paramPtrs = &ThingNotificationRepositoryMockGetParamPtrs{}
  667. }
  668. mmGet.defaultExpectation.paramPtrs.id = &id
  669. return mmGet
  670. }
  671. // Inspect accepts an inspector function that has same arguments as the ThingNotificationRepository.Get
  672. func (mmGet *mThingNotificationRepositoryMockGet) Inspect(f func(ctx context.Context, id uint64)) *mThingNotificationRepositoryMockGet {
  673. if mmGet.mock.inspectFuncGet != nil {
  674. mmGet.mock.t.Fatalf("Inspect function is already set for ThingNotificationRepositoryMock.Get")
  675. }
  676. mmGet.mock.inspectFuncGet = f
  677. return mmGet
  678. }
  679. // Return sets up results that will be returned by ThingNotificationRepository.Get
  680. func (mmGet *mThingNotificationRepositoryMockGet) Return(tp1 *models.ThingNotification, err error) *ThingNotificationRepositoryMock {
  681. if mmGet.mock.funcGet != nil {
  682. mmGet.mock.t.Fatalf("ThingNotificationRepositoryMock.Get mock is already set by Set")
  683. }
  684. if mmGet.defaultExpectation == nil {
  685. mmGet.defaultExpectation = &ThingNotificationRepositoryMockGetExpectation{mock: mmGet.mock}
  686. }
  687. mmGet.defaultExpectation.results = &ThingNotificationRepositoryMockGetResults{tp1, err}
  688. return mmGet.mock
  689. }
  690. // Set uses given function f to mock the ThingNotificationRepository.Get method
  691. func (mmGet *mThingNotificationRepositoryMockGet) Set(f func(ctx context.Context, id uint64) (tp1 *models.ThingNotification, err error)) *ThingNotificationRepositoryMock {
  692. if mmGet.defaultExpectation != nil {
  693. mmGet.mock.t.Fatalf("Default expectation is already set for the ThingNotificationRepository.Get method")
  694. }
  695. if len(mmGet.expectations) > 0 {
  696. mmGet.mock.t.Fatalf("Some expectations are already set for the ThingNotificationRepository.Get method")
  697. }
  698. mmGet.mock.funcGet = f
  699. return mmGet.mock
  700. }
  701. // When sets expectation for the ThingNotificationRepository.Get which will trigger the result defined by the following
  702. // Then helper
  703. func (mmGet *mThingNotificationRepositoryMockGet) When(ctx context.Context, id uint64) *ThingNotificationRepositoryMockGetExpectation {
  704. if mmGet.mock.funcGet != nil {
  705. mmGet.mock.t.Fatalf("ThingNotificationRepositoryMock.Get mock is already set by Set")
  706. }
  707. expectation := &ThingNotificationRepositoryMockGetExpectation{
  708. mock: mmGet.mock,
  709. params: &ThingNotificationRepositoryMockGetParams{ctx, id},
  710. }
  711. mmGet.expectations = append(mmGet.expectations, expectation)
  712. return expectation
  713. }
  714. // Then sets up ThingNotificationRepository.Get return parameters for the expectation previously defined by the When method
  715. func (e *ThingNotificationRepositoryMockGetExpectation) Then(tp1 *models.ThingNotification, err error) *ThingNotificationRepositoryMock {
  716. e.results = &ThingNotificationRepositoryMockGetResults{tp1, err}
  717. return e.mock
  718. }
  719. // Times sets number of times ThingNotificationRepository.Get should be invoked
  720. func (mmGet *mThingNotificationRepositoryMockGet) Times(n uint64) *mThingNotificationRepositoryMockGet {
  721. if n == 0 {
  722. mmGet.mock.t.Fatalf("Times of ThingNotificationRepositoryMock.Get mock can not be zero")
  723. }
  724. mm_atomic.StoreUint64(&mmGet.expectedInvocations, n)
  725. return mmGet
  726. }
  727. func (mmGet *mThingNotificationRepositoryMockGet) invocationsDone() bool {
  728. if len(mmGet.expectations) == 0 && mmGet.defaultExpectation == nil && mmGet.mock.funcGet == nil {
  729. return true
  730. }
  731. totalInvocations := mm_atomic.LoadUint64(&mmGet.mock.afterGetCounter)
  732. expectedInvocations := mm_atomic.LoadUint64(&mmGet.expectedInvocations)
  733. return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
  734. }
  735. // Get implements notification.ThingNotificationRepository
  736. func (mmGet *ThingNotificationRepositoryMock) Get(ctx context.Context, id uint64) (tp1 *models.ThingNotification, err error) {
  737. mm_atomic.AddUint64(&mmGet.beforeGetCounter, 1)
  738. defer mm_atomic.AddUint64(&mmGet.afterGetCounter, 1)
  739. if mmGet.inspectFuncGet != nil {
  740. mmGet.inspectFuncGet(ctx, id)
  741. }
  742. mm_params := ThingNotificationRepositoryMockGetParams{ctx, id}
  743. // Record call args
  744. mmGet.GetMock.mutex.Lock()
  745. mmGet.GetMock.callArgs = append(mmGet.GetMock.callArgs, &mm_params)
  746. mmGet.GetMock.mutex.Unlock()
  747. for _, e := range mmGet.GetMock.expectations {
  748. if minimock.Equal(*e.params, mm_params) {
  749. mm_atomic.AddUint64(&e.Counter, 1)
  750. return e.results.tp1, e.results.err
  751. }
  752. }
  753. if mmGet.GetMock.defaultExpectation != nil {
  754. mm_atomic.AddUint64(&mmGet.GetMock.defaultExpectation.Counter, 1)
  755. mm_want := mmGet.GetMock.defaultExpectation.params
  756. mm_want_ptrs := mmGet.GetMock.defaultExpectation.paramPtrs
  757. mm_got := ThingNotificationRepositoryMockGetParams{ctx, id}
  758. if mm_want_ptrs != nil {
  759. if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
  760. mmGet.t.Errorf("ThingNotificationRepositoryMock.Get got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
  761. }
  762. if mm_want_ptrs.id != nil && !minimock.Equal(*mm_want_ptrs.id, mm_got.id) {
  763. mmGet.t.Errorf("ThingNotificationRepositoryMock.Get got unexpected parameter id, want: %#v, got: %#v%s\n", *mm_want_ptrs.id, mm_got.id, minimock.Diff(*mm_want_ptrs.id, mm_got.id))
  764. }
  765. } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
  766. mmGet.t.Errorf("ThingNotificationRepositoryMock.Get got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
  767. }
  768. mm_results := mmGet.GetMock.defaultExpectation.results
  769. if mm_results == nil {
  770. mmGet.t.Fatal("No results are set for the ThingNotificationRepositoryMock.Get")
  771. }
  772. return (*mm_results).tp1, (*mm_results).err
  773. }
  774. if mmGet.funcGet != nil {
  775. return mmGet.funcGet(ctx, id)
  776. }
  777. mmGet.t.Fatalf("Unexpected call to ThingNotificationRepositoryMock.Get. %v %v", ctx, id)
  778. return
  779. }
  780. // GetAfterCounter returns a count of finished ThingNotificationRepositoryMock.Get invocations
  781. func (mmGet *ThingNotificationRepositoryMock) GetAfterCounter() uint64 {
  782. return mm_atomic.LoadUint64(&mmGet.afterGetCounter)
  783. }
  784. // GetBeforeCounter returns a count of ThingNotificationRepositoryMock.Get invocations
  785. func (mmGet *ThingNotificationRepositoryMock) GetBeforeCounter() uint64 {
  786. return mm_atomic.LoadUint64(&mmGet.beforeGetCounter)
  787. }
  788. // Calls returns a list of arguments used in each call to ThingNotificationRepositoryMock.Get.
  789. // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
  790. func (mmGet *mThingNotificationRepositoryMockGet) Calls() []*ThingNotificationRepositoryMockGetParams {
  791. mmGet.mutex.RLock()
  792. argCopy := make([]*ThingNotificationRepositoryMockGetParams, len(mmGet.callArgs))
  793. copy(argCopy, mmGet.callArgs)
  794. mmGet.mutex.RUnlock()
  795. return argCopy
  796. }
  797. // MinimockGetDone returns true if the count of the Get invocations corresponds
  798. // the number of defined expectations
  799. func (m *ThingNotificationRepositoryMock) MinimockGetDone() bool {
  800. if m.GetMock.optional {
  801. // Optional methods provide '0 or more' call count restriction.
  802. return true
  803. }
  804. for _, e := range m.GetMock.expectations {
  805. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  806. return false
  807. }
  808. }
  809. return m.GetMock.invocationsDone()
  810. }
  811. // MinimockGetInspect logs each unmet expectation
  812. func (m *ThingNotificationRepositoryMock) MinimockGetInspect() {
  813. for _, e := range m.GetMock.expectations {
  814. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  815. m.t.Errorf("Expected call to ThingNotificationRepositoryMock.Get with params: %#v", *e.params)
  816. }
  817. }
  818. afterGetCounter := mm_atomic.LoadUint64(&m.afterGetCounter)
  819. // if default expectation was set then invocations count should be greater than zero
  820. if m.GetMock.defaultExpectation != nil && afterGetCounter < 1 {
  821. if m.GetMock.defaultExpectation.params == nil {
  822. m.t.Error("Expected call to ThingNotificationRepositoryMock.Get")
  823. } else {
  824. m.t.Errorf("Expected call to ThingNotificationRepositoryMock.Get with params: %#v", *m.GetMock.defaultExpectation.params)
  825. }
  826. }
  827. // if func was set then invocations count should be greater than zero
  828. if m.funcGet != nil && afterGetCounter < 1 {
  829. m.t.Error("Expected call to ThingNotificationRepositoryMock.Get")
  830. }
  831. if !m.GetMock.invocationsDone() && afterGetCounter > 0 {
  832. m.t.Errorf("Expected %d calls to ThingNotificationRepositoryMock.Get but found %d calls",
  833. mm_atomic.LoadUint64(&m.GetMock.expectedInvocations), afterGetCounter)
  834. }
  835. }
  836. type mThingNotificationRepositoryMockGetExpired struct {
  837. optional bool
  838. mock *ThingNotificationRepositoryMock
  839. defaultExpectation *ThingNotificationRepositoryMockGetExpiredExpectation
  840. expectations []*ThingNotificationRepositoryMockGetExpiredExpectation
  841. callArgs []*ThingNotificationRepositoryMockGetExpiredParams
  842. mutex sync.RWMutex
  843. expectedInvocations uint64
  844. }
  845. // ThingNotificationRepositoryMockGetExpiredExpectation specifies expectation struct of the ThingNotificationRepository.GetExpired
  846. type ThingNotificationRepositoryMockGetExpiredExpectation struct {
  847. mock *ThingNotificationRepositoryMock
  848. params *ThingNotificationRepositoryMockGetExpiredParams
  849. paramPtrs *ThingNotificationRepositoryMockGetExpiredParamPtrs
  850. results *ThingNotificationRepositoryMockGetExpiredResults
  851. Counter uint64
  852. }
  853. // ThingNotificationRepositoryMockGetExpiredParams contains parameters of the ThingNotificationRepository.GetExpired
  854. type ThingNotificationRepositoryMockGetExpiredParams struct {
  855. ctx context.Context
  856. }
  857. // ThingNotificationRepositoryMockGetExpiredParamPtrs contains pointers to parameters of the ThingNotificationRepository.GetExpired
  858. type ThingNotificationRepositoryMockGetExpiredParamPtrs struct {
  859. ctx *context.Context
  860. }
  861. // ThingNotificationRepositoryMockGetExpiredResults contains results of the ThingNotificationRepository.GetExpired
  862. type ThingNotificationRepositoryMockGetExpiredResults struct {
  863. ea1 []models.ExtThingNotification
  864. err error
  865. }
  866. // Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
  867. // the test will fail minimock's automatic final call check if the mocked method was not called at least once.
  868. // Optional() makes method check to work in '0 or more' mode.
  869. // It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
  870. // catch the problems when the expected method call is totally skipped during test run.
  871. func (mmGetExpired *mThingNotificationRepositoryMockGetExpired) Optional() *mThingNotificationRepositoryMockGetExpired {
  872. mmGetExpired.optional = true
  873. return mmGetExpired
  874. }
  875. // Expect sets up expected params for ThingNotificationRepository.GetExpired
  876. func (mmGetExpired *mThingNotificationRepositoryMockGetExpired) Expect(ctx context.Context) *mThingNotificationRepositoryMockGetExpired {
  877. if mmGetExpired.mock.funcGetExpired != nil {
  878. mmGetExpired.mock.t.Fatalf("ThingNotificationRepositoryMock.GetExpired mock is already set by Set")
  879. }
  880. if mmGetExpired.defaultExpectation == nil {
  881. mmGetExpired.defaultExpectation = &ThingNotificationRepositoryMockGetExpiredExpectation{}
  882. }
  883. if mmGetExpired.defaultExpectation.paramPtrs != nil {
  884. mmGetExpired.mock.t.Fatalf("ThingNotificationRepositoryMock.GetExpired mock is already set by ExpectParams functions")
  885. }
  886. mmGetExpired.defaultExpectation.params = &ThingNotificationRepositoryMockGetExpiredParams{ctx}
  887. for _, e := range mmGetExpired.expectations {
  888. if minimock.Equal(e.params, mmGetExpired.defaultExpectation.params) {
  889. mmGetExpired.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetExpired.defaultExpectation.params)
  890. }
  891. }
  892. return mmGetExpired
  893. }
  894. // ExpectCtxParam1 sets up expected param ctx for ThingNotificationRepository.GetExpired
  895. func (mmGetExpired *mThingNotificationRepositoryMockGetExpired) ExpectCtxParam1(ctx context.Context) *mThingNotificationRepositoryMockGetExpired {
  896. if mmGetExpired.mock.funcGetExpired != nil {
  897. mmGetExpired.mock.t.Fatalf("ThingNotificationRepositoryMock.GetExpired mock is already set by Set")
  898. }
  899. if mmGetExpired.defaultExpectation == nil {
  900. mmGetExpired.defaultExpectation = &ThingNotificationRepositoryMockGetExpiredExpectation{}
  901. }
  902. if mmGetExpired.defaultExpectation.params != nil {
  903. mmGetExpired.mock.t.Fatalf("ThingNotificationRepositoryMock.GetExpired mock is already set by Expect")
  904. }
  905. if mmGetExpired.defaultExpectation.paramPtrs == nil {
  906. mmGetExpired.defaultExpectation.paramPtrs = &ThingNotificationRepositoryMockGetExpiredParamPtrs{}
  907. }
  908. mmGetExpired.defaultExpectation.paramPtrs.ctx = &ctx
  909. return mmGetExpired
  910. }
  911. // Inspect accepts an inspector function that has same arguments as the ThingNotificationRepository.GetExpired
  912. func (mmGetExpired *mThingNotificationRepositoryMockGetExpired) Inspect(f func(ctx context.Context)) *mThingNotificationRepositoryMockGetExpired {
  913. if mmGetExpired.mock.inspectFuncGetExpired != nil {
  914. mmGetExpired.mock.t.Fatalf("Inspect function is already set for ThingNotificationRepositoryMock.GetExpired")
  915. }
  916. mmGetExpired.mock.inspectFuncGetExpired = f
  917. return mmGetExpired
  918. }
  919. // Return sets up results that will be returned by ThingNotificationRepository.GetExpired
  920. func (mmGetExpired *mThingNotificationRepositoryMockGetExpired) Return(ea1 []models.ExtThingNotification, err error) *ThingNotificationRepositoryMock {
  921. if mmGetExpired.mock.funcGetExpired != nil {
  922. mmGetExpired.mock.t.Fatalf("ThingNotificationRepositoryMock.GetExpired mock is already set by Set")
  923. }
  924. if mmGetExpired.defaultExpectation == nil {
  925. mmGetExpired.defaultExpectation = &ThingNotificationRepositoryMockGetExpiredExpectation{mock: mmGetExpired.mock}
  926. }
  927. mmGetExpired.defaultExpectation.results = &ThingNotificationRepositoryMockGetExpiredResults{ea1, err}
  928. return mmGetExpired.mock
  929. }
  930. // Set uses given function f to mock the ThingNotificationRepository.GetExpired method
  931. func (mmGetExpired *mThingNotificationRepositoryMockGetExpired) Set(f func(ctx context.Context) (ea1 []models.ExtThingNotification, err error)) *ThingNotificationRepositoryMock {
  932. if mmGetExpired.defaultExpectation != nil {
  933. mmGetExpired.mock.t.Fatalf("Default expectation is already set for the ThingNotificationRepository.GetExpired method")
  934. }
  935. if len(mmGetExpired.expectations) > 0 {
  936. mmGetExpired.mock.t.Fatalf("Some expectations are already set for the ThingNotificationRepository.GetExpired method")
  937. }
  938. mmGetExpired.mock.funcGetExpired = f
  939. return mmGetExpired.mock
  940. }
  941. // When sets expectation for the ThingNotificationRepository.GetExpired which will trigger the result defined by the following
  942. // Then helper
  943. func (mmGetExpired *mThingNotificationRepositoryMockGetExpired) When(ctx context.Context) *ThingNotificationRepositoryMockGetExpiredExpectation {
  944. if mmGetExpired.mock.funcGetExpired != nil {
  945. mmGetExpired.mock.t.Fatalf("ThingNotificationRepositoryMock.GetExpired mock is already set by Set")
  946. }
  947. expectation := &ThingNotificationRepositoryMockGetExpiredExpectation{
  948. mock: mmGetExpired.mock,
  949. params: &ThingNotificationRepositoryMockGetExpiredParams{ctx},
  950. }
  951. mmGetExpired.expectations = append(mmGetExpired.expectations, expectation)
  952. return expectation
  953. }
  954. // Then sets up ThingNotificationRepository.GetExpired return parameters for the expectation previously defined by the When method
  955. func (e *ThingNotificationRepositoryMockGetExpiredExpectation) Then(ea1 []models.ExtThingNotification, err error) *ThingNotificationRepositoryMock {
  956. e.results = &ThingNotificationRepositoryMockGetExpiredResults{ea1, err}
  957. return e.mock
  958. }
  959. // Times sets number of times ThingNotificationRepository.GetExpired should be invoked
  960. func (mmGetExpired *mThingNotificationRepositoryMockGetExpired) Times(n uint64) *mThingNotificationRepositoryMockGetExpired {
  961. if n == 0 {
  962. mmGetExpired.mock.t.Fatalf("Times of ThingNotificationRepositoryMock.GetExpired mock can not be zero")
  963. }
  964. mm_atomic.StoreUint64(&mmGetExpired.expectedInvocations, n)
  965. return mmGetExpired
  966. }
  967. func (mmGetExpired *mThingNotificationRepositoryMockGetExpired) invocationsDone() bool {
  968. if len(mmGetExpired.expectations) == 0 && mmGetExpired.defaultExpectation == nil && mmGetExpired.mock.funcGetExpired == nil {
  969. return true
  970. }
  971. totalInvocations := mm_atomic.LoadUint64(&mmGetExpired.mock.afterGetExpiredCounter)
  972. expectedInvocations := mm_atomic.LoadUint64(&mmGetExpired.expectedInvocations)
  973. return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
  974. }
  975. // GetExpired implements notification.ThingNotificationRepository
  976. func (mmGetExpired *ThingNotificationRepositoryMock) GetExpired(ctx context.Context) (ea1 []models.ExtThingNotification, err error) {
  977. mm_atomic.AddUint64(&mmGetExpired.beforeGetExpiredCounter, 1)
  978. defer mm_atomic.AddUint64(&mmGetExpired.afterGetExpiredCounter, 1)
  979. if mmGetExpired.inspectFuncGetExpired != nil {
  980. mmGetExpired.inspectFuncGetExpired(ctx)
  981. }
  982. mm_params := ThingNotificationRepositoryMockGetExpiredParams{ctx}
  983. // Record call args
  984. mmGetExpired.GetExpiredMock.mutex.Lock()
  985. mmGetExpired.GetExpiredMock.callArgs = append(mmGetExpired.GetExpiredMock.callArgs, &mm_params)
  986. mmGetExpired.GetExpiredMock.mutex.Unlock()
  987. for _, e := range mmGetExpired.GetExpiredMock.expectations {
  988. if minimock.Equal(*e.params, mm_params) {
  989. mm_atomic.AddUint64(&e.Counter, 1)
  990. return e.results.ea1, e.results.err
  991. }
  992. }
  993. if mmGetExpired.GetExpiredMock.defaultExpectation != nil {
  994. mm_atomic.AddUint64(&mmGetExpired.GetExpiredMock.defaultExpectation.Counter, 1)
  995. mm_want := mmGetExpired.GetExpiredMock.defaultExpectation.params
  996. mm_want_ptrs := mmGetExpired.GetExpiredMock.defaultExpectation.paramPtrs
  997. mm_got := ThingNotificationRepositoryMockGetExpiredParams{ctx}
  998. if mm_want_ptrs != nil {
  999. if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
  1000. mmGetExpired.t.Errorf("ThingNotificationRepositoryMock.GetExpired got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
  1001. }
  1002. } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
  1003. mmGetExpired.t.Errorf("ThingNotificationRepositoryMock.GetExpired got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
  1004. }
  1005. mm_results := mmGetExpired.GetExpiredMock.defaultExpectation.results
  1006. if mm_results == nil {
  1007. mmGetExpired.t.Fatal("No results are set for the ThingNotificationRepositoryMock.GetExpired")
  1008. }
  1009. return (*mm_results).ea1, (*mm_results).err
  1010. }
  1011. if mmGetExpired.funcGetExpired != nil {
  1012. return mmGetExpired.funcGetExpired(ctx)
  1013. }
  1014. mmGetExpired.t.Fatalf("Unexpected call to ThingNotificationRepositoryMock.GetExpired. %v", ctx)
  1015. return
  1016. }
  1017. // GetExpiredAfterCounter returns a count of finished ThingNotificationRepositoryMock.GetExpired invocations
  1018. func (mmGetExpired *ThingNotificationRepositoryMock) GetExpiredAfterCounter() uint64 {
  1019. return mm_atomic.LoadUint64(&mmGetExpired.afterGetExpiredCounter)
  1020. }
  1021. // GetExpiredBeforeCounter returns a count of ThingNotificationRepositoryMock.GetExpired invocations
  1022. func (mmGetExpired *ThingNotificationRepositoryMock) GetExpiredBeforeCounter() uint64 {
  1023. return mm_atomic.LoadUint64(&mmGetExpired.beforeGetExpiredCounter)
  1024. }
  1025. // Calls returns a list of arguments used in each call to ThingNotificationRepositoryMock.GetExpired.
  1026. // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
  1027. func (mmGetExpired *mThingNotificationRepositoryMockGetExpired) Calls() []*ThingNotificationRepositoryMockGetExpiredParams {
  1028. mmGetExpired.mutex.RLock()
  1029. argCopy := make([]*ThingNotificationRepositoryMockGetExpiredParams, len(mmGetExpired.callArgs))
  1030. copy(argCopy, mmGetExpired.callArgs)
  1031. mmGetExpired.mutex.RUnlock()
  1032. return argCopy
  1033. }
  1034. // MinimockGetExpiredDone returns true if the count of the GetExpired invocations corresponds
  1035. // the number of defined expectations
  1036. func (m *ThingNotificationRepositoryMock) MinimockGetExpiredDone() bool {
  1037. if m.GetExpiredMock.optional {
  1038. // Optional methods provide '0 or more' call count restriction.
  1039. return true
  1040. }
  1041. for _, e := range m.GetExpiredMock.expectations {
  1042. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  1043. return false
  1044. }
  1045. }
  1046. return m.GetExpiredMock.invocationsDone()
  1047. }
  1048. // MinimockGetExpiredInspect logs each unmet expectation
  1049. func (m *ThingNotificationRepositoryMock) MinimockGetExpiredInspect() {
  1050. for _, e := range m.GetExpiredMock.expectations {
  1051. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  1052. m.t.Errorf("Expected call to ThingNotificationRepositoryMock.GetExpired with params: %#v", *e.params)
  1053. }
  1054. }
  1055. afterGetExpiredCounter := mm_atomic.LoadUint64(&m.afterGetExpiredCounter)
  1056. // if default expectation was set then invocations count should be greater than zero
  1057. if m.GetExpiredMock.defaultExpectation != nil && afterGetExpiredCounter < 1 {
  1058. if m.GetExpiredMock.defaultExpectation.params == nil {
  1059. m.t.Error("Expected call to ThingNotificationRepositoryMock.GetExpired")
  1060. } else {
  1061. m.t.Errorf("Expected call to ThingNotificationRepositoryMock.GetExpired with params: %#v", *m.GetExpiredMock.defaultExpectation.params)
  1062. }
  1063. }
  1064. // if func was set then invocations count should be greater than zero
  1065. if m.funcGetExpired != nil && afterGetExpiredCounter < 1 {
  1066. m.t.Error("Expected call to ThingNotificationRepositoryMock.GetExpired")
  1067. }
  1068. if !m.GetExpiredMock.invocationsDone() && afterGetExpiredCounter > 0 {
  1069. m.t.Errorf("Expected %d calls to ThingNotificationRepositoryMock.GetExpired but found %d calls",
  1070. mm_atomic.LoadUint64(&m.GetExpiredMock.expectedInvocations), afterGetExpiredCounter)
  1071. }
  1072. }
  1073. type mThingNotificationRepositoryMockUpdate struct {
  1074. optional bool
  1075. mock *ThingNotificationRepositoryMock
  1076. defaultExpectation *ThingNotificationRepositoryMockUpdateExpectation
  1077. expectations []*ThingNotificationRepositoryMockUpdateExpectation
  1078. callArgs []*ThingNotificationRepositoryMockUpdateParams
  1079. mutex sync.RWMutex
  1080. expectedInvocations uint64
  1081. }
  1082. // ThingNotificationRepositoryMockUpdateExpectation specifies expectation struct of the ThingNotificationRepository.Update
  1083. type ThingNotificationRepositoryMockUpdateExpectation struct {
  1084. mock *ThingNotificationRepositoryMock
  1085. params *ThingNotificationRepositoryMockUpdateParams
  1086. paramPtrs *ThingNotificationRepositoryMockUpdateParamPtrs
  1087. results *ThingNotificationRepositoryMockUpdateResults
  1088. Counter uint64
  1089. }
  1090. // ThingNotificationRepositoryMockUpdateParams contains parameters of the ThingNotificationRepository.Update
  1091. type ThingNotificationRepositoryMockUpdateParams struct {
  1092. ctx context.Context
  1093. req models.UpdateThingNotificationRequest
  1094. }
  1095. // ThingNotificationRepositoryMockUpdateParamPtrs contains pointers to parameters of the ThingNotificationRepository.Update
  1096. type ThingNotificationRepositoryMockUpdateParamPtrs struct {
  1097. ctx *context.Context
  1098. req *models.UpdateThingNotificationRequest
  1099. }
  1100. // ThingNotificationRepositoryMockUpdateResults contains results of the ThingNotificationRepository.Update
  1101. type ThingNotificationRepositoryMockUpdateResults struct {
  1102. err error
  1103. }
  1104. // Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
  1105. // the test will fail minimock's automatic final call check if the mocked method was not called at least once.
  1106. // Optional() makes method check to work in '0 or more' mode.
  1107. // It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
  1108. // catch the problems when the expected method call is totally skipped during test run.
  1109. func (mmUpdate *mThingNotificationRepositoryMockUpdate) Optional() *mThingNotificationRepositoryMockUpdate {
  1110. mmUpdate.optional = true
  1111. return mmUpdate
  1112. }
  1113. // Expect sets up expected params for ThingNotificationRepository.Update
  1114. func (mmUpdate *mThingNotificationRepositoryMockUpdate) Expect(ctx context.Context, req models.UpdateThingNotificationRequest) *mThingNotificationRepositoryMockUpdate {
  1115. if mmUpdate.mock.funcUpdate != nil {
  1116. mmUpdate.mock.t.Fatalf("ThingNotificationRepositoryMock.Update mock is already set by Set")
  1117. }
  1118. if mmUpdate.defaultExpectation == nil {
  1119. mmUpdate.defaultExpectation = &ThingNotificationRepositoryMockUpdateExpectation{}
  1120. }
  1121. if mmUpdate.defaultExpectation.paramPtrs != nil {
  1122. mmUpdate.mock.t.Fatalf("ThingNotificationRepositoryMock.Update mock is already set by ExpectParams functions")
  1123. }
  1124. mmUpdate.defaultExpectation.params = &ThingNotificationRepositoryMockUpdateParams{ctx, req}
  1125. for _, e := range mmUpdate.expectations {
  1126. if minimock.Equal(e.params, mmUpdate.defaultExpectation.params) {
  1127. mmUpdate.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmUpdate.defaultExpectation.params)
  1128. }
  1129. }
  1130. return mmUpdate
  1131. }
  1132. // ExpectCtxParam1 sets up expected param ctx for ThingNotificationRepository.Update
  1133. func (mmUpdate *mThingNotificationRepositoryMockUpdate) ExpectCtxParam1(ctx context.Context) *mThingNotificationRepositoryMockUpdate {
  1134. if mmUpdate.mock.funcUpdate != nil {
  1135. mmUpdate.mock.t.Fatalf("ThingNotificationRepositoryMock.Update mock is already set by Set")
  1136. }
  1137. if mmUpdate.defaultExpectation == nil {
  1138. mmUpdate.defaultExpectation = &ThingNotificationRepositoryMockUpdateExpectation{}
  1139. }
  1140. if mmUpdate.defaultExpectation.params != nil {
  1141. mmUpdate.mock.t.Fatalf("ThingNotificationRepositoryMock.Update mock is already set by Expect")
  1142. }
  1143. if mmUpdate.defaultExpectation.paramPtrs == nil {
  1144. mmUpdate.defaultExpectation.paramPtrs = &ThingNotificationRepositoryMockUpdateParamPtrs{}
  1145. }
  1146. mmUpdate.defaultExpectation.paramPtrs.ctx = &ctx
  1147. return mmUpdate
  1148. }
  1149. // ExpectReqParam2 sets up expected param req for ThingNotificationRepository.Update
  1150. func (mmUpdate *mThingNotificationRepositoryMockUpdate) ExpectReqParam2(req models.UpdateThingNotificationRequest) *mThingNotificationRepositoryMockUpdate {
  1151. if mmUpdate.mock.funcUpdate != nil {
  1152. mmUpdate.mock.t.Fatalf("ThingNotificationRepositoryMock.Update mock is already set by Set")
  1153. }
  1154. if mmUpdate.defaultExpectation == nil {
  1155. mmUpdate.defaultExpectation = &ThingNotificationRepositoryMockUpdateExpectation{}
  1156. }
  1157. if mmUpdate.defaultExpectation.params != nil {
  1158. mmUpdate.mock.t.Fatalf("ThingNotificationRepositoryMock.Update mock is already set by Expect")
  1159. }
  1160. if mmUpdate.defaultExpectation.paramPtrs == nil {
  1161. mmUpdate.defaultExpectation.paramPtrs = &ThingNotificationRepositoryMockUpdateParamPtrs{}
  1162. }
  1163. mmUpdate.defaultExpectation.paramPtrs.req = &req
  1164. return mmUpdate
  1165. }
  1166. // Inspect accepts an inspector function that has same arguments as the ThingNotificationRepository.Update
  1167. func (mmUpdate *mThingNotificationRepositoryMockUpdate) Inspect(f func(ctx context.Context, req models.UpdateThingNotificationRequest)) *mThingNotificationRepositoryMockUpdate {
  1168. if mmUpdate.mock.inspectFuncUpdate != nil {
  1169. mmUpdate.mock.t.Fatalf("Inspect function is already set for ThingNotificationRepositoryMock.Update")
  1170. }
  1171. mmUpdate.mock.inspectFuncUpdate = f
  1172. return mmUpdate
  1173. }
  1174. // Return sets up results that will be returned by ThingNotificationRepository.Update
  1175. func (mmUpdate *mThingNotificationRepositoryMockUpdate) Return(err error) *ThingNotificationRepositoryMock {
  1176. if mmUpdate.mock.funcUpdate != nil {
  1177. mmUpdate.mock.t.Fatalf("ThingNotificationRepositoryMock.Update mock is already set by Set")
  1178. }
  1179. if mmUpdate.defaultExpectation == nil {
  1180. mmUpdate.defaultExpectation = &ThingNotificationRepositoryMockUpdateExpectation{mock: mmUpdate.mock}
  1181. }
  1182. mmUpdate.defaultExpectation.results = &ThingNotificationRepositoryMockUpdateResults{err}
  1183. return mmUpdate.mock
  1184. }
  1185. // Set uses given function f to mock the ThingNotificationRepository.Update method
  1186. func (mmUpdate *mThingNotificationRepositoryMockUpdate) Set(f func(ctx context.Context, req models.UpdateThingNotificationRequest) (err error)) *ThingNotificationRepositoryMock {
  1187. if mmUpdate.defaultExpectation != nil {
  1188. mmUpdate.mock.t.Fatalf("Default expectation is already set for the ThingNotificationRepository.Update method")
  1189. }
  1190. if len(mmUpdate.expectations) > 0 {
  1191. mmUpdate.mock.t.Fatalf("Some expectations are already set for the ThingNotificationRepository.Update method")
  1192. }
  1193. mmUpdate.mock.funcUpdate = f
  1194. return mmUpdate.mock
  1195. }
  1196. // When sets expectation for the ThingNotificationRepository.Update which will trigger the result defined by the following
  1197. // Then helper
  1198. func (mmUpdate *mThingNotificationRepositoryMockUpdate) When(ctx context.Context, req models.UpdateThingNotificationRequest) *ThingNotificationRepositoryMockUpdateExpectation {
  1199. if mmUpdate.mock.funcUpdate != nil {
  1200. mmUpdate.mock.t.Fatalf("ThingNotificationRepositoryMock.Update mock is already set by Set")
  1201. }
  1202. expectation := &ThingNotificationRepositoryMockUpdateExpectation{
  1203. mock: mmUpdate.mock,
  1204. params: &ThingNotificationRepositoryMockUpdateParams{ctx, req},
  1205. }
  1206. mmUpdate.expectations = append(mmUpdate.expectations, expectation)
  1207. return expectation
  1208. }
  1209. // Then sets up ThingNotificationRepository.Update return parameters for the expectation previously defined by the When method
  1210. func (e *ThingNotificationRepositoryMockUpdateExpectation) Then(err error) *ThingNotificationRepositoryMock {
  1211. e.results = &ThingNotificationRepositoryMockUpdateResults{err}
  1212. return e.mock
  1213. }
  1214. // Times sets number of times ThingNotificationRepository.Update should be invoked
  1215. func (mmUpdate *mThingNotificationRepositoryMockUpdate) Times(n uint64) *mThingNotificationRepositoryMockUpdate {
  1216. if n == 0 {
  1217. mmUpdate.mock.t.Fatalf("Times of ThingNotificationRepositoryMock.Update mock can not be zero")
  1218. }
  1219. mm_atomic.StoreUint64(&mmUpdate.expectedInvocations, n)
  1220. return mmUpdate
  1221. }
  1222. func (mmUpdate *mThingNotificationRepositoryMockUpdate) invocationsDone() bool {
  1223. if len(mmUpdate.expectations) == 0 && mmUpdate.defaultExpectation == nil && mmUpdate.mock.funcUpdate == nil {
  1224. return true
  1225. }
  1226. totalInvocations := mm_atomic.LoadUint64(&mmUpdate.mock.afterUpdateCounter)
  1227. expectedInvocations := mm_atomic.LoadUint64(&mmUpdate.expectedInvocations)
  1228. return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
  1229. }
  1230. // Update implements notification.ThingNotificationRepository
  1231. func (mmUpdate *ThingNotificationRepositoryMock) Update(ctx context.Context, req models.UpdateThingNotificationRequest) (err error) {
  1232. mm_atomic.AddUint64(&mmUpdate.beforeUpdateCounter, 1)
  1233. defer mm_atomic.AddUint64(&mmUpdate.afterUpdateCounter, 1)
  1234. if mmUpdate.inspectFuncUpdate != nil {
  1235. mmUpdate.inspectFuncUpdate(ctx, req)
  1236. }
  1237. mm_params := ThingNotificationRepositoryMockUpdateParams{ctx, req}
  1238. // Record call args
  1239. mmUpdate.UpdateMock.mutex.Lock()
  1240. mmUpdate.UpdateMock.callArgs = append(mmUpdate.UpdateMock.callArgs, &mm_params)
  1241. mmUpdate.UpdateMock.mutex.Unlock()
  1242. for _, e := range mmUpdate.UpdateMock.expectations {
  1243. if minimock.Equal(*e.params, mm_params) {
  1244. mm_atomic.AddUint64(&e.Counter, 1)
  1245. return e.results.err
  1246. }
  1247. }
  1248. if mmUpdate.UpdateMock.defaultExpectation != nil {
  1249. mm_atomic.AddUint64(&mmUpdate.UpdateMock.defaultExpectation.Counter, 1)
  1250. mm_want := mmUpdate.UpdateMock.defaultExpectation.params
  1251. mm_want_ptrs := mmUpdate.UpdateMock.defaultExpectation.paramPtrs
  1252. mm_got := ThingNotificationRepositoryMockUpdateParams{ctx, req}
  1253. if mm_want_ptrs != nil {
  1254. if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
  1255. mmUpdate.t.Errorf("ThingNotificationRepositoryMock.Update got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
  1256. }
  1257. if mm_want_ptrs.req != nil && !minimock.Equal(*mm_want_ptrs.req, mm_got.req) {
  1258. mmUpdate.t.Errorf("ThingNotificationRepositoryMock.Update got unexpected parameter req, want: %#v, got: %#v%s\n", *mm_want_ptrs.req, mm_got.req, minimock.Diff(*mm_want_ptrs.req, mm_got.req))
  1259. }
  1260. } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
  1261. mmUpdate.t.Errorf("ThingNotificationRepositoryMock.Update got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
  1262. }
  1263. mm_results := mmUpdate.UpdateMock.defaultExpectation.results
  1264. if mm_results == nil {
  1265. mmUpdate.t.Fatal("No results are set for the ThingNotificationRepositoryMock.Update")
  1266. }
  1267. return (*mm_results).err
  1268. }
  1269. if mmUpdate.funcUpdate != nil {
  1270. return mmUpdate.funcUpdate(ctx, req)
  1271. }
  1272. mmUpdate.t.Fatalf("Unexpected call to ThingNotificationRepositoryMock.Update. %v %v", ctx, req)
  1273. return
  1274. }
  1275. // UpdateAfterCounter returns a count of finished ThingNotificationRepositoryMock.Update invocations
  1276. func (mmUpdate *ThingNotificationRepositoryMock) UpdateAfterCounter() uint64 {
  1277. return mm_atomic.LoadUint64(&mmUpdate.afterUpdateCounter)
  1278. }
  1279. // UpdateBeforeCounter returns a count of ThingNotificationRepositoryMock.Update invocations
  1280. func (mmUpdate *ThingNotificationRepositoryMock) UpdateBeforeCounter() uint64 {
  1281. return mm_atomic.LoadUint64(&mmUpdate.beforeUpdateCounter)
  1282. }
  1283. // Calls returns a list of arguments used in each call to ThingNotificationRepositoryMock.Update.
  1284. // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
  1285. func (mmUpdate *mThingNotificationRepositoryMockUpdate) Calls() []*ThingNotificationRepositoryMockUpdateParams {
  1286. mmUpdate.mutex.RLock()
  1287. argCopy := make([]*ThingNotificationRepositoryMockUpdateParams, len(mmUpdate.callArgs))
  1288. copy(argCopy, mmUpdate.callArgs)
  1289. mmUpdate.mutex.RUnlock()
  1290. return argCopy
  1291. }
  1292. // MinimockUpdateDone returns true if the count of the Update invocations corresponds
  1293. // the number of defined expectations
  1294. func (m *ThingNotificationRepositoryMock) MinimockUpdateDone() bool {
  1295. if m.UpdateMock.optional {
  1296. // Optional methods provide '0 or more' call count restriction.
  1297. return true
  1298. }
  1299. for _, e := range m.UpdateMock.expectations {
  1300. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  1301. return false
  1302. }
  1303. }
  1304. return m.UpdateMock.invocationsDone()
  1305. }
  1306. // MinimockUpdateInspect logs each unmet expectation
  1307. func (m *ThingNotificationRepositoryMock) MinimockUpdateInspect() {
  1308. for _, e := range m.UpdateMock.expectations {
  1309. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  1310. m.t.Errorf("Expected call to ThingNotificationRepositoryMock.Update with params: %#v", *e.params)
  1311. }
  1312. }
  1313. afterUpdateCounter := mm_atomic.LoadUint64(&m.afterUpdateCounter)
  1314. // if default expectation was set then invocations count should be greater than zero
  1315. if m.UpdateMock.defaultExpectation != nil && afterUpdateCounter < 1 {
  1316. if m.UpdateMock.defaultExpectation.params == nil {
  1317. m.t.Error("Expected call to ThingNotificationRepositoryMock.Update")
  1318. } else {
  1319. m.t.Errorf("Expected call to ThingNotificationRepositoryMock.Update with params: %#v", *m.UpdateMock.defaultExpectation.params)
  1320. }
  1321. }
  1322. // if func was set then invocations count should be greater than zero
  1323. if m.funcUpdate != nil && afterUpdateCounter < 1 {
  1324. m.t.Error("Expected call to ThingNotificationRepositoryMock.Update")
  1325. }
  1326. if !m.UpdateMock.invocationsDone() && afterUpdateCounter > 0 {
  1327. m.t.Errorf("Expected %d calls to ThingNotificationRepositoryMock.Update but found %d calls",
  1328. mm_atomic.LoadUint64(&m.UpdateMock.expectedInvocations), afterUpdateCounter)
  1329. }
  1330. }
  1331. // MinimockFinish checks that all mocked methods have been called the expected number of times
  1332. func (m *ThingNotificationRepositoryMock) MinimockFinish() {
  1333. m.finishOnce.Do(func() {
  1334. if !m.minimockDone() {
  1335. m.MinimockAddInspect()
  1336. m.MinimockDeleteInspect()
  1337. m.MinimockGetInspect()
  1338. m.MinimockGetExpiredInspect()
  1339. m.MinimockUpdateInspect()
  1340. }
  1341. })
  1342. }
  1343. // MinimockWait waits for all mocked methods to be called the expected number of times
  1344. func (m *ThingNotificationRepositoryMock) MinimockWait(timeout mm_time.Duration) {
  1345. timeoutCh := mm_time.After(timeout)
  1346. for {
  1347. if m.minimockDone() {
  1348. return
  1349. }
  1350. select {
  1351. case <-timeoutCh:
  1352. m.MinimockFinish()
  1353. return
  1354. case <-mm_time.After(10 * mm_time.Millisecond):
  1355. }
  1356. }
  1357. }
  1358. func (m *ThingNotificationRepositoryMock) minimockDone() bool {
  1359. done := true
  1360. return done &&
  1361. m.MinimockAddDone() &&
  1362. m.MinimockDeleteDone() &&
  1363. m.MinimockGetDone() &&
  1364. m.MinimockGetExpiredDone() &&
  1365. m.MinimockUpdateDone()
  1366. }