article_repository_minimock.go 72 KB

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