thing_notification_repository_minimock.go 48 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202
  1. package mocks
  2. // Code generated by http://github.com/gojuno/minimock (dev). DO NOT EDIT.
  3. //go:generate minimock -i git.dmitriygnatenko.ru/dima/homethings/internal/interfaces.ThingNotificationRepository -o ./mocks/thing_notification_repository_minimock.go -n ThingNotificationRepositoryMock
  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 interfaces.ThingNotificationRepository
  14. type ThingNotificationRepositoryMock struct {
  15. t minimock.Tester
  16. funcAdd func(ctx context.Context, req models.AddThingNotificationRequest, tx *sql.Tx) (err error)
  17. inspectFuncAdd func(ctx context.Context, req models.AddThingNotificationRequest, tx *sql.Tx)
  18. afterAddCounter uint64
  19. beforeAddCounter uint64
  20. AddMock mThingNotificationRepositoryMockAdd
  21. funcDelete func(ctx context.Context, thingID int, tx *sql.Tx) (err error)
  22. inspectFuncDelete func(ctx context.Context, thingID int, tx *sql.Tx)
  23. afterDeleteCounter uint64
  24. beforeDeleteCounter uint64
  25. DeleteMock mThingNotificationRepositoryMockDelete
  26. funcGet func(ctx context.Context, thingID int) (tp1 *models.ThingNotification, err error)
  27. inspectFuncGet func(ctx context.Context, thingID int)
  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, tx *sql.Tx) (err error)
  37. inspectFuncUpdate func(ctx context.Context, req models.UpdateThingNotificationRequest, tx *sql.Tx)
  38. afterUpdateCounter uint64
  39. beforeUpdateCounter uint64
  40. UpdateMock mThingNotificationRepositoryMockUpdate
  41. }
  42. // NewThingNotificationRepositoryMock returns a mock for interfaces.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. return m
  59. }
  60. type mThingNotificationRepositoryMockAdd struct {
  61. mock *ThingNotificationRepositoryMock
  62. defaultExpectation *ThingNotificationRepositoryMockAddExpectation
  63. expectations []*ThingNotificationRepositoryMockAddExpectation
  64. callArgs []*ThingNotificationRepositoryMockAddParams
  65. mutex sync.RWMutex
  66. }
  67. // ThingNotificationRepositoryMockAddExpectation specifies expectation struct of the ThingNotificationRepository.Add
  68. type ThingNotificationRepositoryMockAddExpectation struct {
  69. mock *ThingNotificationRepositoryMock
  70. params *ThingNotificationRepositoryMockAddParams
  71. results *ThingNotificationRepositoryMockAddResults
  72. Counter uint64
  73. }
  74. // ThingNotificationRepositoryMockAddParams contains parameters of the ThingNotificationRepository.Add
  75. type ThingNotificationRepositoryMockAddParams struct {
  76. ctx context.Context
  77. req models.AddThingNotificationRequest
  78. tx *sql.Tx
  79. }
  80. // ThingNotificationRepositoryMockAddResults contains results of the ThingNotificationRepository.Add
  81. type ThingNotificationRepositoryMockAddResults struct {
  82. err error
  83. }
  84. // Expect sets up expected params for ThingNotificationRepository.Add
  85. func (mmAdd *mThingNotificationRepositoryMockAdd) Expect(ctx context.Context, req models.AddThingNotificationRequest, tx *sql.Tx) *mThingNotificationRepositoryMockAdd {
  86. if mmAdd.mock.funcAdd != nil {
  87. mmAdd.mock.t.Fatalf("ThingNotificationRepositoryMock.Add mock is already set by Set")
  88. }
  89. if mmAdd.defaultExpectation == nil {
  90. mmAdd.defaultExpectation = &ThingNotificationRepositoryMockAddExpectation{}
  91. }
  92. mmAdd.defaultExpectation.params = &ThingNotificationRepositoryMockAddParams{ctx, req, tx}
  93. for _, e := range mmAdd.expectations {
  94. if minimock.Equal(e.params, mmAdd.defaultExpectation.params) {
  95. mmAdd.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmAdd.defaultExpectation.params)
  96. }
  97. }
  98. return mmAdd
  99. }
  100. // Inspect accepts an inspector function that has same arguments as the ThingNotificationRepository.Add
  101. func (mmAdd *mThingNotificationRepositoryMockAdd) Inspect(f func(ctx context.Context, req models.AddThingNotificationRequest, tx *sql.Tx)) *mThingNotificationRepositoryMockAdd {
  102. if mmAdd.mock.inspectFuncAdd != nil {
  103. mmAdd.mock.t.Fatalf("Inspect function is already set for ThingNotificationRepositoryMock.Add")
  104. }
  105. mmAdd.mock.inspectFuncAdd = f
  106. return mmAdd
  107. }
  108. // Return sets up results that will be returned by ThingNotificationRepository.Add
  109. func (mmAdd *mThingNotificationRepositoryMockAdd) Return(err error) *ThingNotificationRepositoryMock {
  110. if mmAdd.mock.funcAdd != nil {
  111. mmAdd.mock.t.Fatalf("ThingNotificationRepositoryMock.Add mock is already set by Set")
  112. }
  113. if mmAdd.defaultExpectation == nil {
  114. mmAdd.defaultExpectation = &ThingNotificationRepositoryMockAddExpectation{mock: mmAdd.mock}
  115. }
  116. mmAdd.defaultExpectation.results = &ThingNotificationRepositoryMockAddResults{err}
  117. return mmAdd.mock
  118. }
  119. //Set uses given function f to mock the ThingNotificationRepository.Add method
  120. func (mmAdd *mThingNotificationRepositoryMockAdd) Set(f func(ctx context.Context, req models.AddThingNotificationRequest, tx *sql.Tx) (err error)) *ThingNotificationRepositoryMock {
  121. if mmAdd.defaultExpectation != nil {
  122. mmAdd.mock.t.Fatalf("Default expectation is already set for the ThingNotificationRepository.Add method")
  123. }
  124. if len(mmAdd.expectations) > 0 {
  125. mmAdd.mock.t.Fatalf("Some expectations are already set for the ThingNotificationRepository.Add method")
  126. }
  127. mmAdd.mock.funcAdd = f
  128. return mmAdd.mock
  129. }
  130. // When sets expectation for the ThingNotificationRepository.Add which will trigger the result defined by the following
  131. // Then helper
  132. func (mmAdd *mThingNotificationRepositoryMockAdd) When(ctx context.Context, req models.AddThingNotificationRequest, tx *sql.Tx) *ThingNotificationRepositoryMockAddExpectation {
  133. if mmAdd.mock.funcAdd != nil {
  134. mmAdd.mock.t.Fatalf("ThingNotificationRepositoryMock.Add mock is already set by Set")
  135. }
  136. expectation := &ThingNotificationRepositoryMockAddExpectation{
  137. mock: mmAdd.mock,
  138. params: &ThingNotificationRepositoryMockAddParams{ctx, req, tx},
  139. }
  140. mmAdd.expectations = append(mmAdd.expectations, expectation)
  141. return expectation
  142. }
  143. // Then sets up ThingNotificationRepository.Add return parameters for the expectation previously defined by the When method
  144. func (e *ThingNotificationRepositoryMockAddExpectation) Then(err error) *ThingNotificationRepositoryMock {
  145. e.results = &ThingNotificationRepositoryMockAddResults{err}
  146. return e.mock
  147. }
  148. // Add implements interfaces.ThingNotificationRepository
  149. func (mmAdd *ThingNotificationRepositoryMock) Add(ctx context.Context, req models.AddThingNotificationRequest, tx *sql.Tx) (err error) {
  150. mm_atomic.AddUint64(&mmAdd.beforeAddCounter, 1)
  151. defer mm_atomic.AddUint64(&mmAdd.afterAddCounter, 1)
  152. if mmAdd.inspectFuncAdd != nil {
  153. mmAdd.inspectFuncAdd(ctx, req, tx)
  154. }
  155. mm_params := &ThingNotificationRepositoryMockAddParams{ctx, req, tx}
  156. // Record call args
  157. mmAdd.AddMock.mutex.Lock()
  158. mmAdd.AddMock.callArgs = append(mmAdd.AddMock.callArgs, mm_params)
  159. mmAdd.AddMock.mutex.Unlock()
  160. for _, e := range mmAdd.AddMock.expectations {
  161. if minimock.Equal(e.params, mm_params) {
  162. mm_atomic.AddUint64(&e.Counter, 1)
  163. return e.results.err
  164. }
  165. }
  166. if mmAdd.AddMock.defaultExpectation != nil {
  167. mm_atomic.AddUint64(&mmAdd.AddMock.defaultExpectation.Counter, 1)
  168. mm_want := mmAdd.AddMock.defaultExpectation.params
  169. mm_got := ThingNotificationRepositoryMockAddParams{ctx, req, tx}
  170. if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
  171. mmAdd.t.Errorf("ThingNotificationRepositoryMock.Add got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
  172. }
  173. mm_results := mmAdd.AddMock.defaultExpectation.results
  174. if mm_results == nil {
  175. mmAdd.t.Fatal("No results are set for the ThingNotificationRepositoryMock.Add")
  176. }
  177. return (*mm_results).err
  178. }
  179. if mmAdd.funcAdd != nil {
  180. return mmAdd.funcAdd(ctx, req, tx)
  181. }
  182. mmAdd.t.Fatalf("Unexpected call to ThingNotificationRepositoryMock.Add. %v %v %v", ctx, req, tx)
  183. return
  184. }
  185. // AddAfterCounter returns a count of finished ThingNotificationRepositoryMock.Add invocations
  186. func (mmAdd *ThingNotificationRepositoryMock) AddAfterCounter() uint64 {
  187. return mm_atomic.LoadUint64(&mmAdd.afterAddCounter)
  188. }
  189. // AddBeforeCounter returns a count of ThingNotificationRepositoryMock.Add invocations
  190. func (mmAdd *ThingNotificationRepositoryMock) AddBeforeCounter() uint64 {
  191. return mm_atomic.LoadUint64(&mmAdd.beforeAddCounter)
  192. }
  193. // Calls returns a list of arguments used in each call to ThingNotificationRepositoryMock.Add.
  194. // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
  195. func (mmAdd *mThingNotificationRepositoryMockAdd) Calls() []*ThingNotificationRepositoryMockAddParams {
  196. mmAdd.mutex.RLock()
  197. argCopy := make([]*ThingNotificationRepositoryMockAddParams, len(mmAdd.callArgs))
  198. copy(argCopy, mmAdd.callArgs)
  199. mmAdd.mutex.RUnlock()
  200. return argCopy
  201. }
  202. // MinimockAddDone returns true if the count of the Add invocations corresponds
  203. // the number of defined expectations
  204. func (m *ThingNotificationRepositoryMock) MinimockAddDone() bool {
  205. for _, e := range m.AddMock.expectations {
  206. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  207. return false
  208. }
  209. }
  210. // if default expectation was set then invocations count should be greater than zero
  211. if m.AddMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterAddCounter) < 1 {
  212. return false
  213. }
  214. // if func was set then invocations count should be greater than zero
  215. if m.funcAdd != nil && mm_atomic.LoadUint64(&m.afterAddCounter) < 1 {
  216. return false
  217. }
  218. return true
  219. }
  220. // MinimockAddInspect logs each unmet expectation
  221. func (m *ThingNotificationRepositoryMock) MinimockAddInspect() {
  222. for _, e := range m.AddMock.expectations {
  223. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  224. m.t.Errorf("Expected call to ThingNotificationRepositoryMock.Add with params: %#v", *e.params)
  225. }
  226. }
  227. // if default expectation was set then invocations count should be greater than zero
  228. if m.AddMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterAddCounter) < 1 {
  229. if m.AddMock.defaultExpectation.params == nil {
  230. m.t.Error("Expected call to ThingNotificationRepositoryMock.Add")
  231. } else {
  232. m.t.Errorf("Expected call to ThingNotificationRepositoryMock.Add with params: %#v", *m.AddMock.defaultExpectation.params)
  233. }
  234. }
  235. // if func was set then invocations count should be greater than zero
  236. if m.funcAdd != nil && mm_atomic.LoadUint64(&m.afterAddCounter) < 1 {
  237. m.t.Error("Expected call to ThingNotificationRepositoryMock.Add")
  238. }
  239. }
  240. type mThingNotificationRepositoryMockDelete struct {
  241. mock *ThingNotificationRepositoryMock
  242. defaultExpectation *ThingNotificationRepositoryMockDeleteExpectation
  243. expectations []*ThingNotificationRepositoryMockDeleteExpectation
  244. callArgs []*ThingNotificationRepositoryMockDeleteParams
  245. mutex sync.RWMutex
  246. }
  247. // ThingNotificationRepositoryMockDeleteExpectation specifies expectation struct of the ThingNotificationRepository.Delete
  248. type ThingNotificationRepositoryMockDeleteExpectation struct {
  249. mock *ThingNotificationRepositoryMock
  250. params *ThingNotificationRepositoryMockDeleteParams
  251. results *ThingNotificationRepositoryMockDeleteResults
  252. Counter uint64
  253. }
  254. // ThingNotificationRepositoryMockDeleteParams contains parameters of the ThingNotificationRepository.Delete
  255. type ThingNotificationRepositoryMockDeleteParams struct {
  256. ctx context.Context
  257. thingID int
  258. tx *sql.Tx
  259. }
  260. // ThingNotificationRepositoryMockDeleteResults contains results of the ThingNotificationRepository.Delete
  261. type ThingNotificationRepositoryMockDeleteResults struct {
  262. err error
  263. }
  264. // Expect sets up expected params for ThingNotificationRepository.Delete
  265. func (mmDelete *mThingNotificationRepositoryMockDelete) Expect(ctx context.Context, thingID int, tx *sql.Tx) *mThingNotificationRepositoryMockDelete {
  266. if mmDelete.mock.funcDelete != nil {
  267. mmDelete.mock.t.Fatalf("ThingNotificationRepositoryMock.Delete mock is already set by Set")
  268. }
  269. if mmDelete.defaultExpectation == nil {
  270. mmDelete.defaultExpectation = &ThingNotificationRepositoryMockDeleteExpectation{}
  271. }
  272. mmDelete.defaultExpectation.params = &ThingNotificationRepositoryMockDeleteParams{ctx, thingID, tx}
  273. for _, e := range mmDelete.expectations {
  274. if minimock.Equal(e.params, mmDelete.defaultExpectation.params) {
  275. mmDelete.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmDelete.defaultExpectation.params)
  276. }
  277. }
  278. return mmDelete
  279. }
  280. // Inspect accepts an inspector function that has same arguments as the ThingNotificationRepository.Delete
  281. func (mmDelete *mThingNotificationRepositoryMockDelete) Inspect(f func(ctx context.Context, thingID int, tx *sql.Tx)) *mThingNotificationRepositoryMockDelete {
  282. if mmDelete.mock.inspectFuncDelete != nil {
  283. mmDelete.mock.t.Fatalf("Inspect function is already set for ThingNotificationRepositoryMock.Delete")
  284. }
  285. mmDelete.mock.inspectFuncDelete = f
  286. return mmDelete
  287. }
  288. // Return sets up results that will be returned by ThingNotificationRepository.Delete
  289. func (mmDelete *mThingNotificationRepositoryMockDelete) Return(err error) *ThingNotificationRepositoryMock {
  290. if mmDelete.mock.funcDelete != nil {
  291. mmDelete.mock.t.Fatalf("ThingNotificationRepositoryMock.Delete mock is already set by Set")
  292. }
  293. if mmDelete.defaultExpectation == nil {
  294. mmDelete.defaultExpectation = &ThingNotificationRepositoryMockDeleteExpectation{mock: mmDelete.mock}
  295. }
  296. mmDelete.defaultExpectation.results = &ThingNotificationRepositoryMockDeleteResults{err}
  297. return mmDelete.mock
  298. }
  299. //Set uses given function f to mock the ThingNotificationRepository.Delete method
  300. func (mmDelete *mThingNotificationRepositoryMockDelete) Set(f func(ctx context.Context, thingID int, tx *sql.Tx) (err error)) *ThingNotificationRepositoryMock {
  301. if mmDelete.defaultExpectation != nil {
  302. mmDelete.mock.t.Fatalf("Default expectation is already set for the ThingNotificationRepository.Delete method")
  303. }
  304. if len(mmDelete.expectations) > 0 {
  305. mmDelete.mock.t.Fatalf("Some expectations are already set for the ThingNotificationRepository.Delete method")
  306. }
  307. mmDelete.mock.funcDelete = f
  308. return mmDelete.mock
  309. }
  310. // When sets expectation for the ThingNotificationRepository.Delete which will trigger the result defined by the following
  311. // Then helper
  312. func (mmDelete *mThingNotificationRepositoryMockDelete) When(ctx context.Context, thingID int, tx *sql.Tx) *ThingNotificationRepositoryMockDeleteExpectation {
  313. if mmDelete.mock.funcDelete != nil {
  314. mmDelete.mock.t.Fatalf("ThingNotificationRepositoryMock.Delete mock is already set by Set")
  315. }
  316. expectation := &ThingNotificationRepositoryMockDeleteExpectation{
  317. mock: mmDelete.mock,
  318. params: &ThingNotificationRepositoryMockDeleteParams{ctx, thingID, tx},
  319. }
  320. mmDelete.expectations = append(mmDelete.expectations, expectation)
  321. return expectation
  322. }
  323. // Then sets up ThingNotificationRepository.Delete return parameters for the expectation previously defined by the When method
  324. func (e *ThingNotificationRepositoryMockDeleteExpectation) Then(err error) *ThingNotificationRepositoryMock {
  325. e.results = &ThingNotificationRepositoryMockDeleteResults{err}
  326. return e.mock
  327. }
  328. // Delete implements interfaces.ThingNotificationRepository
  329. func (mmDelete *ThingNotificationRepositoryMock) Delete(ctx context.Context, thingID int, tx *sql.Tx) (err error) {
  330. mm_atomic.AddUint64(&mmDelete.beforeDeleteCounter, 1)
  331. defer mm_atomic.AddUint64(&mmDelete.afterDeleteCounter, 1)
  332. if mmDelete.inspectFuncDelete != nil {
  333. mmDelete.inspectFuncDelete(ctx, thingID, tx)
  334. }
  335. mm_params := &ThingNotificationRepositoryMockDeleteParams{ctx, thingID, tx}
  336. // Record call args
  337. mmDelete.DeleteMock.mutex.Lock()
  338. mmDelete.DeleteMock.callArgs = append(mmDelete.DeleteMock.callArgs, mm_params)
  339. mmDelete.DeleteMock.mutex.Unlock()
  340. for _, e := range mmDelete.DeleteMock.expectations {
  341. if minimock.Equal(e.params, mm_params) {
  342. mm_atomic.AddUint64(&e.Counter, 1)
  343. return e.results.err
  344. }
  345. }
  346. if mmDelete.DeleteMock.defaultExpectation != nil {
  347. mm_atomic.AddUint64(&mmDelete.DeleteMock.defaultExpectation.Counter, 1)
  348. mm_want := mmDelete.DeleteMock.defaultExpectation.params
  349. mm_got := ThingNotificationRepositoryMockDeleteParams{ctx, thingID, tx}
  350. if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
  351. mmDelete.t.Errorf("ThingNotificationRepositoryMock.Delete got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
  352. }
  353. mm_results := mmDelete.DeleteMock.defaultExpectation.results
  354. if mm_results == nil {
  355. mmDelete.t.Fatal("No results are set for the ThingNotificationRepositoryMock.Delete")
  356. }
  357. return (*mm_results).err
  358. }
  359. if mmDelete.funcDelete != nil {
  360. return mmDelete.funcDelete(ctx, thingID, tx)
  361. }
  362. mmDelete.t.Fatalf("Unexpected call to ThingNotificationRepositoryMock.Delete. %v %v %v", ctx, thingID, tx)
  363. return
  364. }
  365. // DeleteAfterCounter returns a count of finished ThingNotificationRepositoryMock.Delete invocations
  366. func (mmDelete *ThingNotificationRepositoryMock) DeleteAfterCounter() uint64 {
  367. return mm_atomic.LoadUint64(&mmDelete.afterDeleteCounter)
  368. }
  369. // DeleteBeforeCounter returns a count of ThingNotificationRepositoryMock.Delete invocations
  370. func (mmDelete *ThingNotificationRepositoryMock) DeleteBeforeCounter() uint64 {
  371. return mm_atomic.LoadUint64(&mmDelete.beforeDeleteCounter)
  372. }
  373. // Calls returns a list of arguments used in each call to ThingNotificationRepositoryMock.Delete.
  374. // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
  375. func (mmDelete *mThingNotificationRepositoryMockDelete) Calls() []*ThingNotificationRepositoryMockDeleteParams {
  376. mmDelete.mutex.RLock()
  377. argCopy := make([]*ThingNotificationRepositoryMockDeleteParams, len(mmDelete.callArgs))
  378. copy(argCopy, mmDelete.callArgs)
  379. mmDelete.mutex.RUnlock()
  380. return argCopy
  381. }
  382. // MinimockDeleteDone returns true if the count of the Delete invocations corresponds
  383. // the number of defined expectations
  384. func (m *ThingNotificationRepositoryMock) MinimockDeleteDone() bool {
  385. for _, e := range m.DeleteMock.expectations {
  386. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  387. return false
  388. }
  389. }
  390. // if default expectation was set then invocations count should be greater than zero
  391. if m.DeleteMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterDeleteCounter) < 1 {
  392. return false
  393. }
  394. // if func was set then invocations count should be greater than zero
  395. if m.funcDelete != nil && mm_atomic.LoadUint64(&m.afterDeleteCounter) < 1 {
  396. return false
  397. }
  398. return true
  399. }
  400. // MinimockDeleteInspect logs each unmet expectation
  401. func (m *ThingNotificationRepositoryMock) MinimockDeleteInspect() {
  402. for _, e := range m.DeleteMock.expectations {
  403. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  404. m.t.Errorf("Expected call to ThingNotificationRepositoryMock.Delete with params: %#v", *e.params)
  405. }
  406. }
  407. // if default expectation was set then invocations count should be greater than zero
  408. if m.DeleteMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterDeleteCounter) < 1 {
  409. if m.DeleteMock.defaultExpectation.params == nil {
  410. m.t.Error("Expected call to ThingNotificationRepositoryMock.Delete")
  411. } else {
  412. m.t.Errorf("Expected call to ThingNotificationRepositoryMock.Delete with params: %#v", *m.DeleteMock.defaultExpectation.params)
  413. }
  414. }
  415. // if func was set then invocations count should be greater than zero
  416. if m.funcDelete != nil && mm_atomic.LoadUint64(&m.afterDeleteCounter) < 1 {
  417. m.t.Error("Expected call to ThingNotificationRepositoryMock.Delete")
  418. }
  419. }
  420. type mThingNotificationRepositoryMockGet struct {
  421. mock *ThingNotificationRepositoryMock
  422. defaultExpectation *ThingNotificationRepositoryMockGetExpectation
  423. expectations []*ThingNotificationRepositoryMockGetExpectation
  424. callArgs []*ThingNotificationRepositoryMockGetParams
  425. mutex sync.RWMutex
  426. }
  427. // ThingNotificationRepositoryMockGetExpectation specifies expectation struct of the ThingNotificationRepository.Get
  428. type ThingNotificationRepositoryMockGetExpectation struct {
  429. mock *ThingNotificationRepositoryMock
  430. params *ThingNotificationRepositoryMockGetParams
  431. results *ThingNotificationRepositoryMockGetResults
  432. Counter uint64
  433. }
  434. // ThingNotificationRepositoryMockGetParams contains parameters of the ThingNotificationRepository.Get
  435. type ThingNotificationRepositoryMockGetParams struct {
  436. ctx context.Context
  437. thingID int
  438. }
  439. // ThingNotificationRepositoryMockGetResults contains results of the ThingNotificationRepository.Get
  440. type ThingNotificationRepositoryMockGetResults struct {
  441. tp1 *models.ThingNotification
  442. err error
  443. }
  444. // Expect sets up expected params for ThingNotificationRepository.Get
  445. func (mmGet *mThingNotificationRepositoryMockGet) Expect(ctx context.Context, thingID int) *mThingNotificationRepositoryMockGet {
  446. if mmGet.mock.funcGet != nil {
  447. mmGet.mock.t.Fatalf("ThingNotificationRepositoryMock.Get mock is already set by Set")
  448. }
  449. if mmGet.defaultExpectation == nil {
  450. mmGet.defaultExpectation = &ThingNotificationRepositoryMockGetExpectation{}
  451. }
  452. mmGet.defaultExpectation.params = &ThingNotificationRepositoryMockGetParams{ctx, thingID}
  453. for _, e := range mmGet.expectations {
  454. if minimock.Equal(e.params, mmGet.defaultExpectation.params) {
  455. mmGet.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGet.defaultExpectation.params)
  456. }
  457. }
  458. return mmGet
  459. }
  460. // Inspect accepts an inspector function that has same arguments as the ThingNotificationRepository.Get
  461. func (mmGet *mThingNotificationRepositoryMockGet) Inspect(f func(ctx context.Context, thingID int)) *mThingNotificationRepositoryMockGet {
  462. if mmGet.mock.inspectFuncGet != nil {
  463. mmGet.mock.t.Fatalf("Inspect function is already set for ThingNotificationRepositoryMock.Get")
  464. }
  465. mmGet.mock.inspectFuncGet = f
  466. return mmGet
  467. }
  468. // Return sets up results that will be returned by ThingNotificationRepository.Get
  469. func (mmGet *mThingNotificationRepositoryMockGet) Return(tp1 *models.ThingNotification, err error) *ThingNotificationRepositoryMock {
  470. if mmGet.mock.funcGet != nil {
  471. mmGet.mock.t.Fatalf("ThingNotificationRepositoryMock.Get mock is already set by Set")
  472. }
  473. if mmGet.defaultExpectation == nil {
  474. mmGet.defaultExpectation = &ThingNotificationRepositoryMockGetExpectation{mock: mmGet.mock}
  475. }
  476. mmGet.defaultExpectation.results = &ThingNotificationRepositoryMockGetResults{tp1, err}
  477. return mmGet.mock
  478. }
  479. //Set uses given function f to mock the ThingNotificationRepository.Get method
  480. func (mmGet *mThingNotificationRepositoryMockGet) Set(f func(ctx context.Context, thingID int) (tp1 *models.ThingNotification, err error)) *ThingNotificationRepositoryMock {
  481. if mmGet.defaultExpectation != nil {
  482. mmGet.mock.t.Fatalf("Default expectation is already set for the ThingNotificationRepository.Get method")
  483. }
  484. if len(mmGet.expectations) > 0 {
  485. mmGet.mock.t.Fatalf("Some expectations are already set for the ThingNotificationRepository.Get method")
  486. }
  487. mmGet.mock.funcGet = f
  488. return mmGet.mock
  489. }
  490. // When sets expectation for the ThingNotificationRepository.Get which will trigger the result defined by the following
  491. // Then helper
  492. func (mmGet *mThingNotificationRepositoryMockGet) When(ctx context.Context, thingID int) *ThingNotificationRepositoryMockGetExpectation {
  493. if mmGet.mock.funcGet != nil {
  494. mmGet.mock.t.Fatalf("ThingNotificationRepositoryMock.Get mock is already set by Set")
  495. }
  496. expectation := &ThingNotificationRepositoryMockGetExpectation{
  497. mock: mmGet.mock,
  498. params: &ThingNotificationRepositoryMockGetParams{ctx, thingID},
  499. }
  500. mmGet.expectations = append(mmGet.expectations, expectation)
  501. return expectation
  502. }
  503. // Then sets up ThingNotificationRepository.Get return parameters for the expectation previously defined by the When method
  504. func (e *ThingNotificationRepositoryMockGetExpectation) Then(tp1 *models.ThingNotification, err error) *ThingNotificationRepositoryMock {
  505. e.results = &ThingNotificationRepositoryMockGetResults{tp1, err}
  506. return e.mock
  507. }
  508. // Get implements interfaces.ThingNotificationRepository
  509. func (mmGet *ThingNotificationRepositoryMock) Get(ctx context.Context, thingID int) (tp1 *models.ThingNotification, err error) {
  510. mm_atomic.AddUint64(&mmGet.beforeGetCounter, 1)
  511. defer mm_atomic.AddUint64(&mmGet.afterGetCounter, 1)
  512. if mmGet.inspectFuncGet != nil {
  513. mmGet.inspectFuncGet(ctx, thingID)
  514. }
  515. mm_params := &ThingNotificationRepositoryMockGetParams{ctx, thingID}
  516. // Record call args
  517. mmGet.GetMock.mutex.Lock()
  518. mmGet.GetMock.callArgs = append(mmGet.GetMock.callArgs, mm_params)
  519. mmGet.GetMock.mutex.Unlock()
  520. for _, e := range mmGet.GetMock.expectations {
  521. if minimock.Equal(e.params, mm_params) {
  522. mm_atomic.AddUint64(&e.Counter, 1)
  523. return e.results.tp1, e.results.err
  524. }
  525. }
  526. if mmGet.GetMock.defaultExpectation != nil {
  527. mm_atomic.AddUint64(&mmGet.GetMock.defaultExpectation.Counter, 1)
  528. mm_want := mmGet.GetMock.defaultExpectation.params
  529. mm_got := ThingNotificationRepositoryMockGetParams{ctx, thingID}
  530. if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
  531. mmGet.t.Errorf("ThingNotificationRepositoryMock.Get got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
  532. }
  533. mm_results := mmGet.GetMock.defaultExpectation.results
  534. if mm_results == nil {
  535. mmGet.t.Fatal("No results are set for the ThingNotificationRepositoryMock.Get")
  536. }
  537. return (*mm_results).tp1, (*mm_results).err
  538. }
  539. if mmGet.funcGet != nil {
  540. return mmGet.funcGet(ctx, thingID)
  541. }
  542. mmGet.t.Fatalf("Unexpected call to ThingNotificationRepositoryMock.Get. %v %v", ctx, thingID)
  543. return
  544. }
  545. // GetAfterCounter returns a count of finished ThingNotificationRepositoryMock.Get invocations
  546. func (mmGet *ThingNotificationRepositoryMock) GetAfterCounter() uint64 {
  547. return mm_atomic.LoadUint64(&mmGet.afterGetCounter)
  548. }
  549. // GetBeforeCounter returns a count of ThingNotificationRepositoryMock.Get invocations
  550. func (mmGet *ThingNotificationRepositoryMock) GetBeforeCounter() uint64 {
  551. return mm_atomic.LoadUint64(&mmGet.beforeGetCounter)
  552. }
  553. // Calls returns a list of arguments used in each call to ThingNotificationRepositoryMock.Get.
  554. // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
  555. func (mmGet *mThingNotificationRepositoryMockGet) Calls() []*ThingNotificationRepositoryMockGetParams {
  556. mmGet.mutex.RLock()
  557. argCopy := make([]*ThingNotificationRepositoryMockGetParams, len(mmGet.callArgs))
  558. copy(argCopy, mmGet.callArgs)
  559. mmGet.mutex.RUnlock()
  560. return argCopy
  561. }
  562. // MinimockGetDone returns true if the count of the Get invocations corresponds
  563. // the number of defined expectations
  564. func (m *ThingNotificationRepositoryMock) MinimockGetDone() bool {
  565. for _, e := range m.GetMock.expectations {
  566. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  567. return false
  568. }
  569. }
  570. // if default expectation was set then invocations count should be greater than zero
  571. if m.GetMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetCounter) < 1 {
  572. return false
  573. }
  574. // if func was set then invocations count should be greater than zero
  575. if m.funcGet != nil && mm_atomic.LoadUint64(&m.afterGetCounter) < 1 {
  576. return false
  577. }
  578. return true
  579. }
  580. // MinimockGetInspect logs each unmet expectation
  581. func (m *ThingNotificationRepositoryMock) MinimockGetInspect() {
  582. for _, e := range m.GetMock.expectations {
  583. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  584. m.t.Errorf("Expected call to ThingNotificationRepositoryMock.Get with params: %#v", *e.params)
  585. }
  586. }
  587. // if default expectation was set then invocations count should be greater than zero
  588. if m.GetMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetCounter) < 1 {
  589. if m.GetMock.defaultExpectation.params == nil {
  590. m.t.Error("Expected call to ThingNotificationRepositoryMock.Get")
  591. } else {
  592. m.t.Errorf("Expected call to ThingNotificationRepositoryMock.Get with params: %#v", *m.GetMock.defaultExpectation.params)
  593. }
  594. }
  595. // if func was set then invocations count should be greater than zero
  596. if m.funcGet != nil && mm_atomic.LoadUint64(&m.afterGetCounter) < 1 {
  597. m.t.Error("Expected call to ThingNotificationRepositoryMock.Get")
  598. }
  599. }
  600. type mThingNotificationRepositoryMockGetExpired struct {
  601. mock *ThingNotificationRepositoryMock
  602. defaultExpectation *ThingNotificationRepositoryMockGetExpiredExpectation
  603. expectations []*ThingNotificationRepositoryMockGetExpiredExpectation
  604. callArgs []*ThingNotificationRepositoryMockGetExpiredParams
  605. mutex sync.RWMutex
  606. }
  607. // ThingNotificationRepositoryMockGetExpiredExpectation specifies expectation struct of the ThingNotificationRepository.GetExpired
  608. type ThingNotificationRepositoryMockGetExpiredExpectation struct {
  609. mock *ThingNotificationRepositoryMock
  610. params *ThingNotificationRepositoryMockGetExpiredParams
  611. results *ThingNotificationRepositoryMockGetExpiredResults
  612. Counter uint64
  613. }
  614. // ThingNotificationRepositoryMockGetExpiredParams contains parameters of the ThingNotificationRepository.GetExpired
  615. type ThingNotificationRepositoryMockGetExpiredParams struct {
  616. ctx context.Context
  617. }
  618. // ThingNotificationRepositoryMockGetExpiredResults contains results of the ThingNotificationRepository.GetExpired
  619. type ThingNotificationRepositoryMockGetExpiredResults struct {
  620. ea1 []models.ExtThingNotification
  621. err error
  622. }
  623. // Expect sets up expected params for ThingNotificationRepository.GetExpired
  624. func (mmGetExpired *mThingNotificationRepositoryMockGetExpired) Expect(ctx context.Context) *mThingNotificationRepositoryMockGetExpired {
  625. if mmGetExpired.mock.funcGetExpired != nil {
  626. mmGetExpired.mock.t.Fatalf("ThingNotificationRepositoryMock.GetExpired mock is already set by Set")
  627. }
  628. if mmGetExpired.defaultExpectation == nil {
  629. mmGetExpired.defaultExpectation = &ThingNotificationRepositoryMockGetExpiredExpectation{}
  630. }
  631. mmGetExpired.defaultExpectation.params = &ThingNotificationRepositoryMockGetExpiredParams{ctx}
  632. for _, e := range mmGetExpired.expectations {
  633. if minimock.Equal(e.params, mmGetExpired.defaultExpectation.params) {
  634. mmGetExpired.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetExpired.defaultExpectation.params)
  635. }
  636. }
  637. return mmGetExpired
  638. }
  639. // Inspect accepts an inspector function that has same arguments as the ThingNotificationRepository.GetExpired
  640. func (mmGetExpired *mThingNotificationRepositoryMockGetExpired) Inspect(f func(ctx context.Context)) *mThingNotificationRepositoryMockGetExpired {
  641. if mmGetExpired.mock.inspectFuncGetExpired != nil {
  642. mmGetExpired.mock.t.Fatalf("Inspect function is already set for ThingNotificationRepositoryMock.GetExpired")
  643. }
  644. mmGetExpired.mock.inspectFuncGetExpired = f
  645. return mmGetExpired
  646. }
  647. // Return sets up results that will be returned by ThingNotificationRepository.GetExpired
  648. func (mmGetExpired *mThingNotificationRepositoryMockGetExpired) Return(ea1 []models.ExtThingNotification, err error) *ThingNotificationRepositoryMock {
  649. if mmGetExpired.mock.funcGetExpired != nil {
  650. mmGetExpired.mock.t.Fatalf("ThingNotificationRepositoryMock.GetExpired mock is already set by Set")
  651. }
  652. if mmGetExpired.defaultExpectation == nil {
  653. mmGetExpired.defaultExpectation = &ThingNotificationRepositoryMockGetExpiredExpectation{mock: mmGetExpired.mock}
  654. }
  655. mmGetExpired.defaultExpectation.results = &ThingNotificationRepositoryMockGetExpiredResults{ea1, err}
  656. return mmGetExpired.mock
  657. }
  658. //Set uses given function f to mock the ThingNotificationRepository.GetExpired method
  659. func (mmGetExpired *mThingNotificationRepositoryMockGetExpired) Set(f func(ctx context.Context) (ea1 []models.ExtThingNotification, err error)) *ThingNotificationRepositoryMock {
  660. if mmGetExpired.defaultExpectation != nil {
  661. mmGetExpired.mock.t.Fatalf("Default expectation is already set for the ThingNotificationRepository.GetExpired method")
  662. }
  663. if len(mmGetExpired.expectations) > 0 {
  664. mmGetExpired.mock.t.Fatalf("Some expectations are already set for the ThingNotificationRepository.GetExpired method")
  665. }
  666. mmGetExpired.mock.funcGetExpired = f
  667. return mmGetExpired.mock
  668. }
  669. // When sets expectation for the ThingNotificationRepository.GetExpired which will trigger the result defined by the following
  670. // Then helper
  671. func (mmGetExpired *mThingNotificationRepositoryMockGetExpired) When(ctx context.Context) *ThingNotificationRepositoryMockGetExpiredExpectation {
  672. if mmGetExpired.mock.funcGetExpired != nil {
  673. mmGetExpired.mock.t.Fatalf("ThingNotificationRepositoryMock.GetExpired mock is already set by Set")
  674. }
  675. expectation := &ThingNotificationRepositoryMockGetExpiredExpectation{
  676. mock: mmGetExpired.mock,
  677. params: &ThingNotificationRepositoryMockGetExpiredParams{ctx},
  678. }
  679. mmGetExpired.expectations = append(mmGetExpired.expectations, expectation)
  680. return expectation
  681. }
  682. // Then sets up ThingNotificationRepository.GetExpired return parameters for the expectation previously defined by the When method
  683. func (e *ThingNotificationRepositoryMockGetExpiredExpectation) Then(ea1 []models.ExtThingNotification, err error) *ThingNotificationRepositoryMock {
  684. e.results = &ThingNotificationRepositoryMockGetExpiredResults{ea1, err}
  685. return e.mock
  686. }
  687. // GetExpired implements interfaces.ThingNotificationRepository
  688. func (mmGetExpired *ThingNotificationRepositoryMock) GetExpired(ctx context.Context) (ea1 []models.ExtThingNotification, err error) {
  689. mm_atomic.AddUint64(&mmGetExpired.beforeGetExpiredCounter, 1)
  690. defer mm_atomic.AddUint64(&mmGetExpired.afterGetExpiredCounter, 1)
  691. if mmGetExpired.inspectFuncGetExpired != nil {
  692. mmGetExpired.inspectFuncGetExpired(ctx)
  693. }
  694. mm_params := &ThingNotificationRepositoryMockGetExpiredParams{ctx}
  695. // Record call args
  696. mmGetExpired.GetExpiredMock.mutex.Lock()
  697. mmGetExpired.GetExpiredMock.callArgs = append(mmGetExpired.GetExpiredMock.callArgs, mm_params)
  698. mmGetExpired.GetExpiredMock.mutex.Unlock()
  699. for _, e := range mmGetExpired.GetExpiredMock.expectations {
  700. if minimock.Equal(e.params, mm_params) {
  701. mm_atomic.AddUint64(&e.Counter, 1)
  702. return e.results.ea1, e.results.err
  703. }
  704. }
  705. if mmGetExpired.GetExpiredMock.defaultExpectation != nil {
  706. mm_atomic.AddUint64(&mmGetExpired.GetExpiredMock.defaultExpectation.Counter, 1)
  707. mm_want := mmGetExpired.GetExpiredMock.defaultExpectation.params
  708. mm_got := ThingNotificationRepositoryMockGetExpiredParams{ctx}
  709. if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
  710. mmGetExpired.t.Errorf("ThingNotificationRepositoryMock.GetExpired got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
  711. }
  712. mm_results := mmGetExpired.GetExpiredMock.defaultExpectation.results
  713. if mm_results == nil {
  714. mmGetExpired.t.Fatal("No results are set for the ThingNotificationRepositoryMock.GetExpired")
  715. }
  716. return (*mm_results).ea1, (*mm_results).err
  717. }
  718. if mmGetExpired.funcGetExpired != nil {
  719. return mmGetExpired.funcGetExpired(ctx)
  720. }
  721. mmGetExpired.t.Fatalf("Unexpected call to ThingNotificationRepositoryMock.GetExpired. %v", ctx)
  722. return
  723. }
  724. // GetExpiredAfterCounter returns a count of finished ThingNotificationRepositoryMock.GetExpired invocations
  725. func (mmGetExpired *ThingNotificationRepositoryMock) GetExpiredAfterCounter() uint64 {
  726. return mm_atomic.LoadUint64(&mmGetExpired.afterGetExpiredCounter)
  727. }
  728. // GetExpiredBeforeCounter returns a count of ThingNotificationRepositoryMock.GetExpired invocations
  729. func (mmGetExpired *ThingNotificationRepositoryMock) GetExpiredBeforeCounter() uint64 {
  730. return mm_atomic.LoadUint64(&mmGetExpired.beforeGetExpiredCounter)
  731. }
  732. // Calls returns a list of arguments used in each call to ThingNotificationRepositoryMock.GetExpired.
  733. // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
  734. func (mmGetExpired *mThingNotificationRepositoryMockGetExpired) Calls() []*ThingNotificationRepositoryMockGetExpiredParams {
  735. mmGetExpired.mutex.RLock()
  736. argCopy := make([]*ThingNotificationRepositoryMockGetExpiredParams, len(mmGetExpired.callArgs))
  737. copy(argCopy, mmGetExpired.callArgs)
  738. mmGetExpired.mutex.RUnlock()
  739. return argCopy
  740. }
  741. // MinimockGetExpiredDone returns true if the count of the GetExpired invocations corresponds
  742. // the number of defined expectations
  743. func (m *ThingNotificationRepositoryMock) MinimockGetExpiredDone() bool {
  744. for _, e := range m.GetExpiredMock.expectations {
  745. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  746. return false
  747. }
  748. }
  749. // if default expectation was set then invocations count should be greater than zero
  750. if m.GetExpiredMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetExpiredCounter) < 1 {
  751. return false
  752. }
  753. // if func was set then invocations count should be greater than zero
  754. if m.funcGetExpired != nil && mm_atomic.LoadUint64(&m.afterGetExpiredCounter) < 1 {
  755. return false
  756. }
  757. return true
  758. }
  759. // MinimockGetExpiredInspect logs each unmet expectation
  760. func (m *ThingNotificationRepositoryMock) MinimockGetExpiredInspect() {
  761. for _, e := range m.GetExpiredMock.expectations {
  762. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  763. m.t.Errorf("Expected call to ThingNotificationRepositoryMock.GetExpired with params: %#v", *e.params)
  764. }
  765. }
  766. // if default expectation was set then invocations count should be greater than zero
  767. if m.GetExpiredMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetExpiredCounter) < 1 {
  768. if m.GetExpiredMock.defaultExpectation.params == nil {
  769. m.t.Error("Expected call to ThingNotificationRepositoryMock.GetExpired")
  770. } else {
  771. m.t.Errorf("Expected call to ThingNotificationRepositoryMock.GetExpired with params: %#v", *m.GetExpiredMock.defaultExpectation.params)
  772. }
  773. }
  774. // if func was set then invocations count should be greater than zero
  775. if m.funcGetExpired != nil && mm_atomic.LoadUint64(&m.afterGetExpiredCounter) < 1 {
  776. m.t.Error("Expected call to ThingNotificationRepositoryMock.GetExpired")
  777. }
  778. }
  779. type mThingNotificationRepositoryMockUpdate struct {
  780. mock *ThingNotificationRepositoryMock
  781. defaultExpectation *ThingNotificationRepositoryMockUpdateExpectation
  782. expectations []*ThingNotificationRepositoryMockUpdateExpectation
  783. callArgs []*ThingNotificationRepositoryMockUpdateParams
  784. mutex sync.RWMutex
  785. }
  786. // ThingNotificationRepositoryMockUpdateExpectation specifies expectation struct of the ThingNotificationRepository.Update
  787. type ThingNotificationRepositoryMockUpdateExpectation struct {
  788. mock *ThingNotificationRepositoryMock
  789. params *ThingNotificationRepositoryMockUpdateParams
  790. results *ThingNotificationRepositoryMockUpdateResults
  791. Counter uint64
  792. }
  793. // ThingNotificationRepositoryMockUpdateParams contains parameters of the ThingNotificationRepository.Update
  794. type ThingNotificationRepositoryMockUpdateParams struct {
  795. ctx context.Context
  796. req models.UpdateThingNotificationRequest
  797. tx *sql.Tx
  798. }
  799. // ThingNotificationRepositoryMockUpdateResults contains results of the ThingNotificationRepository.Update
  800. type ThingNotificationRepositoryMockUpdateResults struct {
  801. err error
  802. }
  803. // Expect sets up expected params for ThingNotificationRepository.Update
  804. func (mmUpdate *mThingNotificationRepositoryMockUpdate) Expect(ctx context.Context, req models.UpdateThingNotificationRequest, tx *sql.Tx) *mThingNotificationRepositoryMockUpdate {
  805. if mmUpdate.mock.funcUpdate != nil {
  806. mmUpdate.mock.t.Fatalf("ThingNotificationRepositoryMock.Update mock is already set by Set")
  807. }
  808. if mmUpdate.defaultExpectation == nil {
  809. mmUpdate.defaultExpectation = &ThingNotificationRepositoryMockUpdateExpectation{}
  810. }
  811. mmUpdate.defaultExpectation.params = &ThingNotificationRepositoryMockUpdateParams{ctx, req, tx}
  812. for _, e := range mmUpdate.expectations {
  813. if minimock.Equal(e.params, mmUpdate.defaultExpectation.params) {
  814. mmUpdate.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmUpdate.defaultExpectation.params)
  815. }
  816. }
  817. return mmUpdate
  818. }
  819. // Inspect accepts an inspector function that has same arguments as the ThingNotificationRepository.Update
  820. func (mmUpdate *mThingNotificationRepositoryMockUpdate) Inspect(f func(ctx context.Context, req models.UpdateThingNotificationRequest, tx *sql.Tx)) *mThingNotificationRepositoryMockUpdate {
  821. if mmUpdate.mock.inspectFuncUpdate != nil {
  822. mmUpdate.mock.t.Fatalf("Inspect function is already set for ThingNotificationRepositoryMock.Update")
  823. }
  824. mmUpdate.mock.inspectFuncUpdate = f
  825. return mmUpdate
  826. }
  827. // Return sets up results that will be returned by ThingNotificationRepository.Update
  828. func (mmUpdate *mThingNotificationRepositoryMockUpdate) Return(err error) *ThingNotificationRepositoryMock {
  829. if mmUpdate.mock.funcUpdate != nil {
  830. mmUpdate.mock.t.Fatalf("ThingNotificationRepositoryMock.Update mock is already set by Set")
  831. }
  832. if mmUpdate.defaultExpectation == nil {
  833. mmUpdate.defaultExpectation = &ThingNotificationRepositoryMockUpdateExpectation{mock: mmUpdate.mock}
  834. }
  835. mmUpdate.defaultExpectation.results = &ThingNotificationRepositoryMockUpdateResults{err}
  836. return mmUpdate.mock
  837. }
  838. //Set uses given function f to mock the ThingNotificationRepository.Update method
  839. func (mmUpdate *mThingNotificationRepositoryMockUpdate) Set(f func(ctx context.Context, req models.UpdateThingNotificationRequest, tx *sql.Tx) (err error)) *ThingNotificationRepositoryMock {
  840. if mmUpdate.defaultExpectation != nil {
  841. mmUpdate.mock.t.Fatalf("Default expectation is already set for the ThingNotificationRepository.Update method")
  842. }
  843. if len(mmUpdate.expectations) > 0 {
  844. mmUpdate.mock.t.Fatalf("Some expectations are already set for the ThingNotificationRepository.Update method")
  845. }
  846. mmUpdate.mock.funcUpdate = f
  847. return mmUpdate.mock
  848. }
  849. // When sets expectation for the ThingNotificationRepository.Update which will trigger the result defined by the following
  850. // Then helper
  851. func (mmUpdate *mThingNotificationRepositoryMockUpdate) When(ctx context.Context, req models.UpdateThingNotificationRequest, tx *sql.Tx) *ThingNotificationRepositoryMockUpdateExpectation {
  852. if mmUpdate.mock.funcUpdate != nil {
  853. mmUpdate.mock.t.Fatalf("ThingNotificationRepositoryMock.Update mock is already set by Set")
  854. }
  855. expectation := &ThingNotificationRepositoryMockUpdateExpectation{
  856. mock: mmUpdate.mock,
  857. params: &ThingNotificationRepositoryMockUpdateParams{ctx, req, tx},
  858. }
  859. mmUpdate.expectations = append(mmUpdate.expectations, expectation)
  860. return expectation
  861. }
  862. // Then sets up ThingNotificationRepository.Update return parameters for the expectation previously defined by the When method
  863. func (e *ThingNotificationRepositoryMockUpdateExpectation) Then(err error) *ThingNotificationRepositoryMock {
  864. e.results = &ThingNotificationRepositoryMockUpdateResults{err}
  865. return e.mock
  866. }
  867. // Update implements interfaces.ThingNotificationRepository
  868. func (mmUpdate *ThingNotificationRepositoryMock) Update(ctx context.Context, req models.UpdateThingNotificationRequest, tx *sql.Tx) (err error) {
  869. mm_atomic.AddUint64(&mmUpdate.beforeUpdateCounter, 1)
  870. defer mm_atomic.AddUint64(&mmUpdate.afterUpdateCounter, 1)
  871. if mmUpdate.inspectFuncUpdate != nil {
  872. mmUpdate.inspectFuncUpdate(ctx, req, tx)
  873. }
  874. mm_params := &ThingNotificationRepositoryMockUpdateParams{ctx, req, tx}
  875. // Record call args
  876. mmUpdate.UpdateMock.mutex.Lock()
  877. mmUpdate.UpdateMock.callArgs = append(mmUpdate.UpdateMock.callArgs, mm_params)
  878. mmUpdate.UpdateMock.mutex.Unlock()
  879. for _, e := range mmUpdate.UpdateMock.expectations {
  880. if minimock.Equal(e.params, mm_params) {
  881. mm_atomic.AddUint64(&e.Counter, 1)
  882. return e.results.err
  883. }
  884. }
  885. if mmUpdate.UpdateMock.defaultExpectation != nil {
  886. mm_atomic.AddUint64(&mmUpdate.UpdateMock.defaultExpectation.Counter, 1)
  887. mm_want := mmUpdate.UpdateMock.defaultExpectation.params
  888. mm_got := ThingNotificationRepositoryMockUpdateParams{ctx, req, tx}
  889. if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
  890. mmUpdate.t.Errorf("ThingNotificationRepositoryMock.Update got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
  891. }
  892. mm_results := mmUpdate.UpdateMock.defaultExpectation.results
  893. if mm_results == nil {
  894. mmUpdate.t.Fatal("No results are set for the ThingNotificationRepositoryMock.Update")
  895. }
  896. return (*mm_results).err
  897. }
  898. if mmUpdate.funcUpdate != nil {
  899. return mmUpdate.funcUpdate(ctx, req, tx)
  900. }
  901. mmUpdate.t.Fatalf("Unexpected call to ThingNotificationRepositoryMock.Update. %v %v %v", ctx, req, tx)
  902. return
  903. }
  904. // UpdateAfterCounter returns a count of finished ThingNotificationRepositoryMock.Update invocations
  905. func (mmUpdate *ThingNotificationRepositoryMock) UpdateAfterCounter() uint64 {
  906. return mm_atomic.LoadUint64(&mmUpdate.afterUpdateCounter)
  907. }
  908. // UpdateBeforeCounter returns a count of ThingNotificationRepositoryMock.Update invocations
  909. func (mmUpdate *ThingNotificationRepositoryMock) UpdateBeforeCounter() uint64 {
  910. return mm_atomic.LoadUint64(&mmUpdate.beforeUpdateCounter)
  911. }
  912. // Calls returns a list of arguments used in each call to ThingNotificationRepositoryMock.Update.
  913. // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
  914. func (mmUpdate *mThingNotificationRepositoryMockUpdate) Calls() []*ThingNotificationRepositoryMockUpdateParams {
  915. mmUpdate.mutex.RLock()
  916. argCopy := make([]*ThingNotificationRepositoryMockUpdateParams, len(mmUpdate.callArgs))
  917. copy(argCopy, mmUpdate.callArgs)
  918. mmUpdate.mutex.RUnlock()
  919. return argCopy
  920. }
  921. // MinimockUpdateDone returns true if the count of the Update invocations corresponds
  922. // the number of defined expectations
  923. func (m *ThingNotificationRepositoryMock) MinimockUpdateDone() bool {
  924. for _, e := range m.UpdateMock.expectations {
  925. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  926. return false
  927. }
  928. }
  929. // if default expectation was set then invocations count should be greater than zero
  930. if m.UpdateMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterUpdateCounter) < 1 {
  931. return false
  932. }
  933. // if func was set then invocations count should be greater than zero
  934. if m.funcUpdate != nil && mm_atomic.LoadUint64(&m.afterUpdateCounter) < 1 {
  935. return false
  936. }
  937. return true
  938. }
  939. // MinimockUpdateInspect logs each unmet expectation
  940. func (m *ThingNotificationRepositoryMock) MinimockUpdateInspect() {
  941. for _, e := range m.UpdateMock.expectations {
  942. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  943. m.t.Errorf("Expected call to ThingNotificationRepositoryMock.Update with params: %#v", *e.params)
  944. }
  945. }
  946. // if default expectation was set then invocations count should be greater than zero
  947. if m.UpdateMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterUpdateCounter) < 1 {
  948. if m.UpdateMock.defaultExpectation.params == nil {
  949. m.t.Error("Expected call to ThingNotificationRepositoryMock.Update")
  950. } else {
  951. m.t.Errorf("Expected call to ThingNotificationRepositoryMock.Update with params: %#v", *m.UpdateMock.defaultExpectation.params)
  952. }
  953. }
  954. // if func was set then invocations count should be greater than zero
  955. if m.funcUpdate != nil && mm_atomic.LoadUint64(&m.afterUpdateCounter) < 1 {
  956. m.t.Error("Expected call to ThingNotificationRepositoryMock.Update")
  957. }
  958. }
  959. // MinimockFinish checks that all mocked methods have been called the expected number of times
  960. func (m *ThingNotificationRepositoryMock) MinimockFinish() {
  961. if !m.minimockDone() {
  962. m.MinimockAddInspect()
  963. m.MinimockDeleteInspect()
  964. m.MinimockGetInspect()
  965. m.MinimockGetExpiredInspect()
  966. m.MinimockUpdateInspect()
  967. m.t.FailNow()
  968. }
  969. }
  970. // MinimockWait waits for all mocked methods to be called the expected number of times
  971. func (m *ThingNotificationRepositoryMock) MinimockWait(timeout mm_time.Duration) {
  972. timeoutCh := mm_time.After(timeout)
  973. for {
  974. if m.minimockDone() {
  975. return
  976. }
  977. select {
  978. case <-timeoutCh:
  979. m.MinimockFinish()
  980. return
  981. case <-mm_time.After(10 * mm_time.Millisecond):
  982. }
  983. }
  984. }
  985. func (m *ThingNotificationRepositoryMock) minimockDone() bool {
  986. done := true
  987. return done &&
  988. m.MinimockAddDone() &&
  989. m.MinimockDeleteDone() &&
  990. m.MinimockGetDone() &&
  991. m.MinimockGetExpiredDone() &&
  992. m.MinimockUpdateDone()
  993. }