thing_notification_repository_minimock.go 72 KB

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