article_repository_minimock.go 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033
  1. // Code generated by http://github.com/gojuno/minimock (v3.3.13). DO NOT EDIT.
  2. package mocks
  3. //go:generate minimock -i git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/services/handler.ArticleRepository -o article_repository_minimock.go -n ArticleRepositoryMock -p mocks
  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 handler.ArticleRepository
  13. type ArticleRepositoryMock struct {
  14. t minimock.Tester
  15. finishOnce sync.Once
  16. funcGetAllPreview func(ctx context.Context) (aa1 []models.ArticlePreview, err error)
  17. inspectFuncGetAllPreview func(ctx context.Context)
  18. afterGetAllPreviewCounter uint64
  19. beforeGetAllPreviewCounter uint64
  20. GetAllPreviewMock mArticleRepositoryMockGetAllPreview
  21. funcGetByURL func(ctx context.Context, url string) (ap1 *models.Article, err error)
  22. inspectFuncGetByURL func(ctx context.Context, url string)
  23. afterGetByURLCounter uint64
  24. beforeGetByURLCounter uint64
  25. GetByURLMock mArticleRepositoryMockGetByURL
  26. funcGetPreviewByTagID func(ctx context.Context, tagID int) (aa1 []models.ArticlePreview, err error)
  27. inspectFuncGetPreviewByTagID func(ctx context.Context, tagID int)
  28. afterGetPreviewByTagIDCounter uint64
  29. beforeGetPreviewByTagIDCounter uint64
  30. GetPreviewByTagIDMock mArticleRepositoryMockGetPreviewByTagID
  31. }
  32. // NewArticleRepositoryMock returns a mock for handler.ArticleRepository
  33. func NewArticleRepositoryMock(t minimock.Tester) *ArticleRepositoryMock {
  34. m := &ArticleRepositoryMock{t: t}
  35. if controller, ok := t.(minimock.MockController); ok {
  36. controller.RegisterMocker(m)
  37. }
  38. m.GetAllPreviewMock = mArticleRepositoryMockGetAllPreview{mock: m}
  39. m.GetAllPreviewMock.callArgs = []*ArticleRepositoryMockGetAllPreviewParams{}
  40. m.GetByURLMock = mArticleRepositoryMockGetByURL{mock: m}
  41. m.GetByURLMock.callArgs = []*ArticleRepositoryMockGetByURLParams{}
  42. m.GetPreviewByTagIDMock = mArticleRepositoryMockGetPreviewByTagID{mock: m}
  43. m.GetPreviewByTagIDMock.callArgs = []*ArticleRepositoryMockGetPreviewByTagIDParams{}
  44. t.Cleanup(m.MinimockFinish)
  45. return m
  46. }
  47. type mArticleRepositoryMockGetAllPreview struct {
  48. optional bool
  49. mock *ArticleRepositoryMock
  50. defaultExpectation *ArticleRepositoryMockGetAllPreviewExpectation
  51. expectations []*ArticleRepositoryMockGetAllPreviewExpectation
  52. callArgs []*ArticleRepositoryMockGetAllPreviewParams
  53. mutex sync.RWMutex
  54. expectedInvocations uint64
  55. }
  56. // ArticleRepositoryMockGetAllPreviewExpectation specifies expectation struct of the ArticleRepository.GetAllPreview
  57. type ArticleRepositoryMockGetAllPreviewExpectation struct {
  58. mock *ArticleRepositoryMock
  59. params *ArticleRepositoryMockGetAllPreviewParams
  60. paramPtrs *ArticleRepositoryMockGetAllPreviewParamPtrs
  61. results *ArticleRepositoryMockGetAllPreviewResults
  62. Counter uint64
  63. }
  64. // ArticleRepositoryMockGetAllPreviewParams contains parameters of the ArticleRepository.GetAllPreview
  65. type ArticleRepositoryMockGetAllPreviewParams struct {
  66. ctx context.Context
  67. }
  68. // ArticleRepositoryMockGetAllPreviewParamPtrs contains pointers to parameters of the ArticleRepository.GetAllPreview
  69. type ArticleRepositoryMockGetAllPreviewParamPtrs struct {
  70. ctx *context.Context
  71. }
  72. // ArticleRepositoryMockGetAllPreviewResults contains results of the ArticleRepository.GetAllPreview
  73. type ArticleRepositoryMockGetAllPreviewResults struct {
  74. aa1 []models.ArticlePreview
  75. err error
  76. }
  77. // Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
  78. // the test will fail minimock's automatic final call check if the mocked method was not called at least once.
  79. // Optional() makes method check to work in '0 or more' mode.
  80. // It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
  81. // catch the problems when the expected method call is totally skipped during test run.
  82. func (mmGetAllPreview *mArticleRepositoryMockGetAllPreview) Optional() *mArticleRepositoryMockGetAllPreview {
  83. mmGetAllPreview.optional = true
  84. return mmGetAllPreview
  85. }
  86. // Expect sets up expected params for ArticleRepository.GetAllPreview
  87. func (mmGetAllPreview *mArticleRepositoryMockGetAllPreview) Expect(ctx context.Context) *mArticleRepositoryMockGetAllPreview {
  88. if mmGetAllPreview.mock.funcGetAllPreview != nil {
  89. mmGetAllPreview.mock.t.Fatalf("ArticleRepositoryMock.GetAllPreview mock is already set by Set")
  90. }
  91. if mmGetAllPreview.defaultExpectation == nil {
  92. mmGetAllPreview.defaultExpectation = &ArticleRepositoryMockGetAllPreviewExpectation{}
  93. }
  94. if mmGetAllPreview.defaultExpectation.paramPtrs != nil {
  95. mmGetAllPreview.mock.t.Fatalf("ArticleRepositoryMock.GetAllPreview mock is already set by ExpectParams functions")
  96. }
  97. mmGetAllPreview.defaultExpectation.params = &ArticleRepositoryMockGetAllPreviewParams{ctx}
  98. for _, e := range mmGetAllPreview.expectations {
  99. if minimock.Equal(e.params, mmGetAllPreview.defaultExpectation.params) {
  100. mmGetAllPreview.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetAllPreview.defaultExpectation.params)
  101. }
  102. }
  103. return mmGetAllPreview
  104. }
  105. // ExpectCtxParam1 sets up expected param ctx for ArticleRepository.GetAllPreview
  106. func (mmGetAllPreview *mArticleRepositoryMockGetAllPreview) ExpectCtxParam1(ctx context.Context) *mArticleRepositoryMockGetAllPreview {
  107. if mmGetAllPreview.mock.funcGetAllPreview != nil {
  108. mmGetAllPreview.mock.t.Fatalf("ArticleRepositoryMock.GetAllPreview mock is already set by Set")
  109. }
  110. if mmGetAllPreview.defaultExpectation == nil {
  111. mmGetAllPreview.defaultExpectation = &ArticleRepositoryMockGetAllPreviewExpectation{}
  112. }
  113. if mmGetAllPreview.defaultExpectation.params != nil {
  114. mmGetAllPreview.mock.t.Fatalf("ArticleRepositoryMock.GetAllPreview mock is already set by Expect")
  115. }
  116. if mmGetAllPreview.defaultExpectation.paramPtrs == nil {
  117. mmGetAllPreview.defaultExpectation.paramPtrs = &ArticleRepositoryMockGetAllPreviewParamPtrs{}
  118. }
  119. mmGetAllPreview.defaultExpectation.paramPtrs.ctx = &ctx
  120. return mmGetAllPreview
  121. }
  122. // Inspect accepts an inspector function that has same arguments as the ArticleRepository.GetAllPreview
  123. func (mmGetAllPreview *mArticleRepositoryMockGetAllPreview) Inspect(f func(ctx context.Context)) *mArticleRepositoryMockGetAllPreview {
  124. if mmGetAllPreview.mock.inspectFuncGetAllPreview != nil {
  125. mmGetAllPreview.mock.t.Fatalf("Inspect function is already set for ArticleRepositoryMock.GetAllPreview")
  126. }
  127. mmGetAllPreview.mock.inspectFuncGetAllPreview = f
  128. return mmGetAllPreview
  129. }
  130. // Return sets up results that will be returned by ArticleRepository.GetAllPreview
  131. func (mmGetAllPreview *mArticleRepositoryMockGetAllPreview) Return(aa1 []models.ArticlePreview, err error) *ArticleRepositoryMock {
  132. if mmGetAllPreview.mock.funcGetAllPreview != nil {
  133. mmGetAllPreview.mock.t.Fatalf("ArticleRepositoryMock.GetAllPreview mock is already set by Set")
  134. }
  135. if mmGetAllPreview.defaultExpectation == nil {
  136. mmGetAllPreview.defaultExpectation = &ArticleRepositoryMockGetAllPreviewExpectation{mock: mmGetAllPreview.mock}
  137. }
  138. mmGetAllPreview.defaultExpectation.results = &ArticleRepositoryMockGetAllPreviewResults{aa1, err}
  139. return mmGetAllPreview.mock
  140. }
  141. // Set uses given function f to mock the ArticleRepository.GetAllPreview method
  142. func (mmGetAllPreview *mArticleRepositoryMockGetAllPreview) Set(f func(ctx context.Context) (aa1 []models.ArticlePreview, err error)) *ArticleRepositoryMock {
  143. if mmGetAllPreview.defaultExpectation != nil {
  144. mmGetAllPreview.mock.t.Fatalf("Default expectation is already set for the ArticleRepository.GetAllPreview method")
  145. }
  146. if len(mmGetAllPreview.expectations) > 0 {
  147. mmGetAllPreview.mock.t.Fatalf("Some expectations are already set for the ArticleRepository.GetAllPreview method")
  148. }
  149. mmGetAllPreview.mock.funcGetAllPreview = f
  150. return mmGetAllPreview.mock
  151. }
  152. // When sets expectation for the ArticleRepository.GetAllPreview which will trigger the result defined by the following
  153. // Then helper
  154. func (mmGetAllPreview *mArticleRepositoryMockGetAllPreview) When(ctx context.Context) *ArticleRepositoryMockGetAllPreviewExpectation {
  155. if mmGetAllPreview.mock.funcGetAllPreview != nil {
  156. mmGetAllPreview.mock.t.Fatalf("ArticleRepositoryMock.GetAllPreview mock is already set by Set")
  157. }
  158. expectation := &ArticleRepositoryMockGetAllPreviewExpectation{
  159. mock: mmGetAllPreview.mock,
  160. params: &ArticleRepositoryMockGetAllPreviewParams{ctx},
  161. }
  162. mmGetAllPreview.expectations = append(mmGetAllPreview.expectations, expectation)
  163. return expectation
  164. }
  165. // Then sets up ArticleRepository.GetAllPreview return parameters for the expectation previously defined by the When method
  166. func (e *ArticleRepositoryMockGetAllPreviewExpectation) Then(aa1 []models.ArticlePreview, err error) *ArticleRepositoryMock {
  167. e.results = &ArticleRepositoryMockGetAllPreviewResults{aa1, err}
  168. return e.mock
  169. }
  170. // Times sets number of times ArticleRepository.GetAllPreview should be invoked
  171. func (mmGetAllPreview *mArticleRepositoryMockGetAllPreview) Times(n uint64) *mArticleRepositoryMockGetAllPreview {
  172. if n == 0 {
  173. mmGetAllPreview.mock.t.Fatalf("Times of ArticleRepositoryMock.GetAllPreview mock can not be zero")
  174. }
  175. mm_atomic.StoreUint64(&mmGetAllPreview.expectedInvocations, n)
  176. return mmGetAllPreview
  177. }
  178. func (mmGetAllPreview *mArticleRepositoryMockGetAllPreview) invocationsDone() bool {
  179. if len(mmGetAllPreview.expectations) == 0 && mmGetAllPreview.defaultExpectation == nil && mmGetAllPreview.mock.funcGetAllPreview == nil {
  180. return true
  181. }
  182. totalInvocations := mm_atomic.LoadUint64(&mmGetAllPreview.mock.afterGetAllPreviewCounter)
  183. expectedInvocations := mm_atomic.LoadUint64(&mmGetAllPreview.expectedInvocations)
  184. return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
  185. }
  186. // GetAllPreview implements handler.ArticleRepository
  187. func (mmGetAllPreview *ArticleRepositoryMock) GetAllPreview(ctx context.Context) (aa1 []models.ArticlePreview, err error) {
  188. mm_atomic.AddUint64(&mmGetAllPreview.beforeGetAllPreviewCounter, 1)
  189. defer mm_atomic.AddUint64(&mmGetAllPreview.afterGetAllPreviewCounter, 1)
  190. if mmGetAllPreview.inspectFuncGetAllPreview != nil {
  191. mmGetAllPreview.inspectFuncGetAllPreview(ctx)
  192. }
  193. mm_params := ArticleRepositoryMockGetAllPreviewParams{ctx}
  194. // Record call args
  195. mmGetAllPreview.GetAllPreviewMock.mutex.Lock()
  196. mmGetAllPreview.GetAllPreviewMock.callArgs = append(mmGetAllPreview.GetAllPreviewMock.callArgs, &mm_params)
  197. mmGetAllPreview.GetAllPreviewMock.mutex.Unlock()
  198. for _, e := range mmGetAllPreview.GetAllPreviewMock.expectations {
  199. if minimock.Equal(*e.params, mm_params) {
  200. mm_atomic.AddUint64(&e.Counter, 1)
  201. return e.results.aa1, e.results.err
  202. }
  203. }
  204. if mmGetAllPreview.GetAllPreviewMock.defaultExpectation != nil {
  205. mm_atomic.AddUint64(&mmGetAllPreview.GetAllPreviewMock.defaultExpectation.Counter, 1)
  206. mm_want := mmGetAllPreview.GetAllPreviewMock.defaultExpectation.params
  207. mm_want_ptrs := mmGetAllPreview.GetAllPreviewMock.defaultExpectation.paramPtrs
  208. mm_got := ArticleRepositoryMockGetAllPreviewParams{ctx}
  209. if mm_want_ptrs != nil {
  210. if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
  211. mmGetAllPreview.t.Errorf("ArticleRepositoryMock.GetAllPreview got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
  212. }
  213. } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
  214. mmGetAllPreview.t.Errorf("ArticleRepositoryMock.GetAllPreview got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
  215. }
  216. mm_results := mmGetAllPreview.GetAllPreviewMock.defaultExpectation.results
  217. if mm_results == nil {
  218. mmGetAllPreview.t.Fatal("No results are set for the ArticleRepositoryMock.GetAllPreview")
  219. }
  220. return (*mm_results).aa1, (*mm_results).err
  221. }
  222. if mmGetAllPreview.funcGetAllPreview != nil {
  223. return mmGetAllPreview.funcGetAllPreview(ctx)
  224. }
  225. mmGetAllPreview.t.Fatalf("Unexpected call to ArticleRepositoryMock.GetAllPreview. %v", ctx)
  226. return
  227. }
  228. // GetAllPreviewAfterCounter returns a count of finished ArticleRepositoryMock.GetAllPreview invocations
  229. func (mmGetAllPreview *ArticleRepositoryMock) GetAllPreviewAfterCounter() uint64 {
  230. return mm_atomic.LoadUint64(&mmGetAllPreview.afterGetAllPreviewCounter)
  231. }
  232. // GetAllPreviewBeforeCounter returns a count of ArticleRepositoryMock.GetAllPreview invocations
  233. func (mmGetAllPreview *ArticleRepositoryMock) GetAllPreviewBeforeCounter() uint64 {
  234. return mm_atomic.LoadUint64(&mmGetAllPreview.beforeGetAllPreviewCounter)
  235. }
  236. // Calls returns a list of arguments used in each call to ArticleRepositoryMock.GetAllPreview.
  237. // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
  238. func (mmGetAllPreview *mArticleRepositoryMockGetAllPreview) Calls() []*ArticleRepositoryMockGetAllPreviewParams {
  239. mmGetAllPreview.mutex.RLock()
  240. argCopy := make([]*ArticleRepositoryMockGetAllPreviewParams, len(mmGetAllPreview.callArgs))
  241. copy(argCopy, mmGetAllPreview.callArgs)
  242. mmGetAllPreview.mutex.RUnlock()
  243. return argCopy
  244. }
  245. // MinimockGetAllPreviewDone returns true if the count of the GetAllPreview invocations corresponds
  246. // the number of defined expectations
  247. func (m *ArticleRepositoryMock) MinimockGetAllPreviewDone() bool {
  248. if m.GetAllPreviewMock.optional {
  249. // Optional methods provide '0 or more' call count restriction.
  250. return true
  251. }
  252. for _, e := range m.GetAllPreviewMock.expectations {
  253. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  254. return false
  255. }
  256. }
  257. return m.GetAllPreviewMock.invocationsDone()
  258. }
  259. // MinimockGetAllPreviewInspect logs each unmet expectation
  260. func (m *ArticleRepositoryMock) MinimockGetAllPreviewInspect() {
  261. for _, e := range m.GetAllPreviewMock.expectations {
  262. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  263. m.t.Errorf("Expected call to ArticleRepositoryMock.GetAllPreview with params: %#v", *e.params)
  264. }
  265. }
  266. afterGetAllPreviewCounter := mm_atomic.LoadUint64(&m.afterGetAllPreviewCounter)
  267. // if default expectation was set then invocations count should be greater than zero
  268. if m.GetAllPreviewMock.defaultExpectation != nil && afterGetAllPreviewCounter < 1 {
  269. if m.GetAllPreviewMock.defaultExpectation.params == nil {
  270. m.t.Error("Expected call to ArticleRepositoryMock.GetAllPreview")
  271. } else {
  272. m.t.Errorf("Expected call to ArticleRepositoryMock.GetAllPreview with params: %#v", *m.GetAllPreviewMock.defaultExpectation.params)
  273. }
  274. }
  275. // if func was set then invocations count should be greater than zero
  276. if m.funcGetAllPreview != nil && afterGetAllPreviewCounter < 1 {
  277. m.t.Error("Expected call to ArticleRepositoryMock.GetAllPreview")
  278. }
  279. if !m.GetAllPreviewMock.invocationsDone() && afterGetAllPreviewCounter > 0 {
  280. m.t.Errorf("Expected %d calls to ArticleRepositoryMock.GetAllPreview but found %d calls",
  281. mm_atomic.LoadUint64(&m.GetAllPreviewMock.expectedInvocations), afterGetAllPreviewCounter)
  282. }
  283. }
  284. type mArticleRepositoryMockGetByURL struct {
  285. optional bool
  286. mock *ArticleRepositoryMock
  287. defaultExpectation *ArticleRepositoryMockGetByURLExpectation
  288. expectations []*ArticleRepositoryMockGetByURLExpectation
  289. callArgs []*ArticleRepositoryMockGetByURLParams
  290. mutex sync.RWMutex
  291. expectedInvocations uint64
  292. }
  293. // ArticleRepositoryMockGetByURLExpectation specifies expectation struct of the ArticleRepository.GetByURL
  294. type ArticleRepositoryMockGetByURLExpectation struct {
  295. mock *ArticleRepositoryMock
  296. params *ArticleRepositoryMockGetByURLParams
  297. paramPtrs *ArticleRepositoryMockGetByURLParamPtrs
  298. results *ArticleRepositoryMockGetByURLResults
  299. Counter uint64
  300. }
  301. // ArticleRepositoryMockGetByURLParams contains parameters of the ArticleRepository.GetByURL
  302. type ArticleRepositoryMockGetByURLParams struct {
  303. ctx context.Context
  304. url string
  305. }
  306. // ArticleRepositoryMockGetByURLParamPtrs contains pointers to parameters of the ArticleRepository.GetByURL
  307. type ArticleRepositoryMockGetByURLParamPtrs struct {
  308. ctx *context.Context
  309. url *string
  310. }
  311. // ArticleRepositoryMockGetByURLResults contains results of the ArticleRepository.GetByURL
  312. type ArticleRepositoryMockGetByURLResults struct {
  313. ap1 *models.Article
  314. err error
  315. }
  316. // Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
  317. // the test will fail minimock's automatic final call check if the mocked method was not called at least once.
  318. // Optional() makes method check to work in '0 or more' mode.
  319. // It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
  320. // catch the problems when the expected method call is totally skipped during test run.
  321. func (mmGetByURL *mArticleRepositoryMockGetByURL) Optional() *mArticleRepositoryMockGetByURL {
  322. mmGetByURL.optional = true
  323. return mmGetByURL
  324. }
  325. // Expect sets up expected params for ArticleRepository.GetByURL
  326. func (mmGetByURL *mArticleRepositoryMockGetByURL) Expect(ctx context.Context, url string) *mArticleRepositoryMockGetByURL {
  327. if mmGetByURL.mock.funcGetByURL != nil {
  328. mmGetByURL.mock.t.Fatalf("ArticleRepositoryMock.GetByURL mock is already set by Set")
  329. }
  330. if mmGetByURL.defaultExpectation == nil {
  331. mmGetByURL.defaultExpectation = &ArticleRepositoryMockGetByURLExpectation{}
  332. }
  333. if mmGetByURL.defaultExpectation.paramPtrs != nil {
  334. mmGetByURL.mock.t.Fatalf("ArticleRepositoryMock.GetByURL mock is already set by ExpectParams functions")
  335. }
  336. mmGetByURL.defaultExpectation.params = &ArticleRepositoryMockGetByURLParams{ctx, url}
  337. for _, e := range mmGetByURL.expectations {
  338. if minimock.Equal(e.params, mmGetByURL.defaultExpectation.params) {
  339. mmGetByURL.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetByURL.defaultExpectation.params)
  340. }
  341. }
  342. return mmGetByURL
  343. }
  344. // ExpectCtxParam1 sets up expected param ctx for ArticleRepository.GetByURL
  345. func (mmGetByURL *mArticleRepositoryMockGetByURL) ExpectCtxParam1(ctx context.Context) *mArticleRepositoryMockGetByURL {
  346. if mmGetByURL.mock.funcGetByURL != nil {
  347. mmGetByURL.mock.t.Fatalf("ArticleRepositoryMock.GetByURL mock is already set by Set")
  348. }
  349. if mmGetByURL.defaultExpectation == nil {
  350. mmGetByURL.defaultExpectation = &ArticleRepositoryMockGetByURLExpectation{}
  351. }
  352. if mmGetByURL.defaultExpectation.params != nil {
  353. mmGetByURL.mock.t.Fatalf("ArticleRepositoryMock.GetByURL mock is already set by Expect")
  354. }
  355. if mmGetByURL.defaultExpectation.paramPtrs == nil {
  356. mmGetByURL.defaultExpectation.paramPtrs = &ArticleRepositoryMockGetByURLParamPtrs{}
  357. }
  358. mmGetByURL.defaultExpectation.paramPtrs.ctx = &ctx
  359. return mmGetByURL
  360. }
  361. // ExpectUrlParam2 sets up expected param url for ArticleRepository.GetByURL
  362. func (mmGetByURL *mArticleRepositoryMockGetByURL) ExpectUrlParam2(url string) *mArticleRepositoryMockGetByURL {
  363. if mmGetByURL.mock.funcGetByURL != nil {
  364. mmGetByURL.mock.t.Fatalf("ArticleRepositoryMock.GetByURL mock is already set by Set")
  365. }
  366. if mmGetByURL.defaultExpectation == nil {
  367. mmGetByURL.defaultExpectation = &ArticleRepositoryMockGetByURLExpectation{}
  368. }
  369. if mmGetByURL.defaultExpectation.params != nil {
  370. mmGetByURL.mock.t.Fatalf("ArticleRepositoryMock.GetByURL mock is already set by Expect")
  371. }
  372. if mmGetByURL.defaultExpectation.paramPtrs == nil {
  373. mmGetByURL.defaultExpectation.paramPtrs = &ArticleRepositoryMockGetByURLParamPtrs{}
  374. }
  375. mmGetByURL.defaultExpectation.paramPtrs.url = &url
  376. return mmGetByURL
  377. }
  378. // Inspect accepts an inspector function that has same arguments as the ArticleRepository.GetByURL
  379. func (mmGetByURL *mArticleRepositoryMockGetByURL) Inspect(f func(ctx context.Context, url string)) *mArticleRepositoryMockGetByURL {
  380. if mmGetByURL.mock.inspectFuncGetByURL != nil {
  381. mmGetByURL.mock.t.Fatalf("Inspect function is already set for ArticleRepositoryMock.GetByURL")
  382. }
  383. mmGetByURL.mock.inspectFuncGetByURL = f
  384. return mmGetByURL
  385. }
  386. // Return sets up results that will be returned by ArticleRepository.GetByURL
  387. func (mmGetByURL *mArticleRepositoryMockGetByURL) Return(ap1 *models.Article, err error) *ArticleRepositoryMock {
  388. if mmGetByURL.mock.funcGetByURL != nil {
  389. mmGetByURL.mock.t.Fatalf("ArticleRepositoryMock.GetByURL mock is already set by Set")
  390. }
  391. if mmGetByURL.defaultExpectation == nil {
  392. mmGetByURL.defaultExpectation = &ArticleRepositoryMockGetByURLExpectation{mock: mmGetByURL.mock}
  393. }
  394. mmGetByURL.defaultExpectation.results = &ArticleRepositoryMockGetByURLResults{ap1, err}
  395. return mmGetByURL.mock
  396. }
  397. // Set uses given function f to mock the ArticleRepository.GetByURL method
  398. func (mmGetByURL *mArticleRepositoryMockGetByURL) Set(f func(ctx context.Context, url string) (ap1 *models.Article, err error)) *ArticleRepositoryMock {
  399. if mmGetByURL.defaultExpectation != nil {
  400. mmGetByURL.mock.t.Fatalf("Default expectation is already set for the ArticleRepository.GetByURL method")
  401. }
  402. if len(mmGetByURL.expectations) > 0 {
  403. mmGetByURL.mock.t.Fatalf("Some expectations are already set for the ArticleRepository.GetByURL method")
  404. }
  405. mmGetByURL.mock.funcGetByURL = f
  406. return mmGetByURL.mock
  407. }
  408. // When sets expectation for the ArticleRepository.GetByURL which will trigger the result defined by the following
  409. // Then helper
  410. func (mmGetByURL *mArticleRepositoryMockGetByURL) When(ctx context.Context, url string) *ArticleRepositoryMockGetByURLExpectation {
  411. if mmGetByURL.mock.funcGetByURL != nil {
  412. mmGetByURL.mock.t.Fatalf("ArticleRepositoryMock.GetByURL mock is already set by Set")
  413. }
  414. expectation := &ArticleRepositoryMockGetByURLExpectation{
  415. mock: mmGetByURL.mock,
  416. params: &ArticleRepositoryMockGetByURLParams{ctx, url},
  417. }
  418. mmGetByURL.expectations = append(mmGetByURL.expectations, expectation)
  419. return expectation
  420. }
  421. // Then sets up ArticleRepository.GetByURL return parameters for the expectation previously defined by the When method
  422. func (e *ArticleRepositoryMockGetByURLExpectation) Then(ap1 *models.Article, err error) *ArticleRepositoryMock {
  423. e.results = &ArticleRepositoryMockGetByURLResults{ap1, err}
  424. return e.mock
  425. }
  426. // Times sets number of times ArticleRepository.GetByURL should be invoked
  427. func (mmGetByURL *mArticleRepositoryMockGetByURL) Times(n uint64) *mArticleRepositoryMockGetByURL {
  428. if n == 0 {
  429. mmGetByURL.mock.t.Fatalf("Times of ArticleRepositoryMock.GetByURL mock can not be zero")
  430. }
  431. mm_atomic.StoreUint64(&mmGetByURL.expectedInvocations, n)
  432. return mmGetByURL
  433. }
  434. func (mmGetByURL *mArticleRepositoryMockGetByURL) invocationsDone() bool {
  435. if len(mmGetByURL.expectations) == 0 && mmGetByURL.defaultExpectation == nil && mmGetByURL.mock.funcGetByURL == nil {
  436. return true
  437. }
  438. totalInvocations := mm_atomic.LoadUint64(&mmGetByURL.mock.afterGetByURLCounter)
  439. expectedInvocations := mm_atomic.LoadUint64(&mmGetByURL.expectedInvocations)
  440. return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
  441. }
  442. // GetByURL implements handler.ArticleRepository
  443. func (mmGetByURL *ArticleRepositoryMock) GetByURL(ctx context.Context, url string) (ap1 *models.Article, err error) {
  444. mm_atomic.AddUint64(&mmGetByURL.beforeGetByURLCounter, 1)
  445. defer mm_atomic.AddUint64(&mmGetByURL.afterGetByURLCounter, 1)
  446. if mmGetByURL.inspectFuncGetByURL != nil {
  447. mmGetByURL.inspectFuncGetByURL(ctx, url)
  448. }
  449. mm_params := ArticleRepositoryMockGetByURLParams{ctx, url}
  450. // Record call args
  451. mmGetByURL.GetByURLMock.mutex.Lock()
  452. mmGetByURL.GetByURLMock.callArgs = append(mmGetByURL.GetByURLMock.callArgs, &mm_params)
  453. mmGetByURL.GetByURLMock.mutex.Unlock()
  454. for _, e := range mmGetByURL.GetByURLMock.expectations {
  455. if minimock.Equal(*e.params, mm_params) {
  456. mm_atomic.AddUint64(&e.Counter, 1)
  457. return e.results.ap1, e.results.err
  458. }
  459. }
  460. if mmGetByURL.GetByURLMock.defaultExpectation != nil {
  461. mm_atomic.AddUint64(&mmGetByURL.GetByURLMock.defaultExpectation.Counter, 1)
  462. mm_want := mmGetByURL.GetByURLMock.defaultExpectation.params
  463. mm_want_ptrs := mmGetByURL.GetByURLMock.defaultExpectation.paramPtrs
  464. mm_got := ArticleRepositoryMockGetByURLParams{ctx, url}
  465. if mm_want_ptrs != nil {
  466. if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
  467. mmGetByURL.t.Errorf("ArticleRepositoryMock.GetByURL got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
  468. }
  469. if mm_want_ptrs.url != nil && !minimock.Equal(*mm_want_ptrs.url, mm_got.url) {
  470. mmGetByURL.t.Errorf("ArticleRepositoryMock.GetByURL got unexpected parameter url, want: %#v, got: %#v%s\n", *mm_want_ptrs.url, mm_got.url, minimock.Diff(*mm_want_ptrs.url, mm_got.url))
  471. }
  472. } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
  473. mmGetByURL.t.Errorf("ArticleRepositoryMock.GetByURL got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
  474. }
  475. mm_results := mmGetByURL.GetByURLMock.defaultExpectation.results
  476. if mm_results == nil {
  477. mmGetByURL.t.Fatal("No results are set for the ArticleRepositoryMock.GetByURL")
  478. }
  479. return (*mm_results).ap1, (*mm_results).err
  480. }
  481. if mmGetByURL.funcGetByURL != nil {
  482. return mmGetByURL.funcGetByURL(ctx, url)
  483. }
  484. mmGetByURL.t.Fatalf("Unexpected call to ArticleRepositoryMock.GetByURL. %v %v", ctx, url)
  485. return
  486. }
  487. // GetByURLAfterCounter returns a count of finished ArticleRepositoryMock.GetByURL invocations
  488. func (mmGetByURL *ArticleRepositoryMock) GetByURLAfterCounter() uint64 {
  489. return mm_atomic.LoadUint64(&mmGetByURL.afterGetByURLCounter)
  490. }
  491. // GetByURLBeforeCounter returns a count of ArticleRepositoryMock.GetByURL invocations
  492. func (mmGetByURL *ArticleRepositoryMock) GetByURLBeforeCounter() uint64 {
  493. return mm_atomic.LoadUint64(&mmGetByURL.beforeGetByURLCounter)
  494. }
  495. // Calls returns a list of arguments used in each call to ArticleRepositoryMock.GetByURL.
  496. // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
  497. func (mmGetByURL *mArticleRepositoryMockGetByURL) Calls() []*ArticleRepositoryMockGetByURLParams {
  498. mmGetByURL.mutex.RLock()
  499. argCopy := make([]*ArticleRepositoryMockGetByURLParams, len(mmGetByURL.callArgs))
  500. copy(argCopy, mmGetByURL.callArgs)
  501. mmGetByURL.mutex.RUnlock()
  502. return argCopy
  503. }
  504. // MinimockGetByURLDone returns true if the count of the GetByURL invocations corresponds
  505. // the number of defined expectations
  506. func (m *ArticleRepositoryMock) MinimockGetByURLDone() bool {
  507. if m.GetByURLMock.optional {
  508. // Optional methods provide '0 or more' call count restriction.
  509. return true
  510. }
  511. for _, e := range m.GetByURLMock.expectations {
  512. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  513. return false
  514. }
  515. }
  516. return m.GetByURLMock.invocationsDone()
  517. }
  518. // MinimockGetByURLInspect logs each unmet expectation
  519. func (m *ArticleRepositoryMock) MinimockGetByURLInspect() {
  520. for _, e := range m.GetByURLMock.expectations {
  521. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  522. m.t.Errorf("Expected call to ArticleRepositoryMock.GetByURL with params: %#v", *e.params)
  523. }
  524. }
  525. afterGetByURLCounter := mm_atomic.LoadUint64(&m.afterGetByURLCounter)
  526. // if default expectation was set then invocations count should be greater than zero
  527. if m.GetByURLMock.defaultExpectation != nil && afterGetByURLCounter < 1 {
  528. if m.GetByURLMock.defaultExpectation.params == nil {
  529. m.t.Error("Expected call to ArticleRepositoryMock.GetByURL")
  530. } else {
  531. m.t.Errorf("Expected call to ArticleRepositoryMock.GetByURL with params: %#v", *m.GetByURLMock.defaultExpectation.params)
  532. }
  533. }
  534. // if func was set then invocations count should be greater than zero
  535. if m.funcGetByURL != nil && afterGetByURLCounter < 1 {
  536. m.t.Error("Expected call to ArticleRepositoryMock.GetByURL")
  537. }
  538. if !m.GetByURLMock.invocationsDone() && afterGetByURLCounter > 0 {
  539. m.t.Errorf("Expected %d calls to ArticleRepositoryMock.GetByURL but found %d calls",
  540. mm_atomic.LoadUint64(&m.GetByURLMock.expectedInvocations), afterGetByURLCounter)
  541. }
  542. }
  543. type mArticleRepositoryMockGetPreviewByTagID struct {
  544. optional bool
  545. mock *ArticleRepositoryMock
  546. defaultExpectation *ArticleRepositoryMockGetPreviewByTagIDExpectation
  547. expectations []*ArticleRepositoryMockGetPreviewByTagIDExpectation
  548. callArgs []*ArticleRepositoryMockGetPreviewByTagIDParams
  549. mutex sync.RWMutex
  550. expectedInvocations uint64
  551. }
  552. // ArticleRepositoryMockGetPreviewByTagIDExpectation specifies expectation struct of the ArticleRepository.GetPreviewByTagID
  553. type ArticleRepositoryMockGetPreviewByTagIDExpectation struct {
  554. mock *ArticleRepositoryMock
  555. params *ArticleRepositoryMockGetPreviewByTagIDParams
  556. paramPtrs *ArticleRepositoryMockGetPreviewByTagIDParamPtrs
  557. results *ArticleRepositoryMockGetPreviewByTagIDResults
  558. Counter uint64
  559. }
  560. // ArticleRepositoryMockGetPreviewByTagIDParams contains parameters of the ArticleRepository.GetPreviewByTagID
  561. type ArticleRepositoryMockGetPreviewByTagIDParams struct {
  562. ctx context.Context
  563. tagID int
  564. }
  565. // ArticleRepositoryMockGetPreviewByTagIDParamPtrs contains pointers to parameters of the ArticleRepository.GetPreviewByTagID
  566. type ArticleRepositoryMockGetPreviewByTagIDParamPtrs struct {
  567. ctx *context.Context
  568. tagID *int
  569. }
  570. // ArticleRepositoryMockGetPreviewByTagIDResults contains results of the ArticleRepository.GetPreviewByTagID
  571. type ArticleRepositoryMockGetPreviewByTagIDResults struct {
  572. aa1 []models.ArticlePreview
  573. err error
  574. }
  575. // Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
  576. // the test will fail minimock's automatic final call check if the mocked method was not called at least once.
  577. // Optional() makes method check to work in '0 or more' mode.
  578. // It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
  579. // catch the problems when the expected method call is totally skipped during test run.
  580. func (mmGetPreviewByTagID *mArticleRepositoryMockGetPreviewByTagID) Optional() *mArticleRepositoryMockGetPreviewByTagID {
  581. mmGetPreviewByTagID.optional = true
  582. return mmGetPreviewByTagID
  583. }
  584. // Expect sets up expected params for ArticleRepository.GetPreviewByTagID
  585. func (mmGetPreviewByTagID *mArticleRepositoryMockGetPreviewByTagID) Expect(ctx context.Context, tagID int) *mArticleRepositoryMockGetPreviewByTagID {
  586. if mmGetPreviewByTagID.mock.funcGetPreviewByTagID != nil {
  587. mmGetPreviewByTagID.mock.t.Fatalf("ArticleRepositoryMock.GetPreviewByTagID mock is already set by Set")
  588. }
  589. if mmGetPreviewByTagID.defaultExpectation == nil {
  590. mmGetPreviewByTagID.defaultExpectation = &ArticleRepositoryMockGetPreviewByTagIDExpectation{}
  591. }
  592. if mmGetPreviewByTagID.defaultExpectation.paramPtrs != nil {
  593. mmGetPreviewByTagID.mock.t.Fatalf("ArticleRepositoryMock.GetPreviewByTagID mock is already set by ExpectParams functions")
  594. }
  595. mmGetPreviewByTagID.defaultExpectation.params = &ArticleRepositoryMockGetPreviewByTagIDParams{ctx, tagID}
  596. for _, e := range mmGetPreviewByTagID.expectations {
  597. if minimock.Equal(e.params, mmGetPreviewByTagID.defaultExpectation.params) {
  598. mmGetPreviewByTagID.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetPreviewByTagID.defaultExpectation.params)
  599. }
  600. }
  601. return mmGetPreviewByTagID
  602. }
  603. // ExpectCtxParam1 sets up expected param ctx for ArticleRepository.GetPreviewByTagID
  604. func (mmGetPreviewByTagID *mArticleRepositoryMockGetPreviewByTagID) ExpectCtxParam1(ctx context.Context) *mArticleRepositoryMockGetPreviewByTagID {
  605. if mmGetPreviewByTagID.mock.funcGetPreviewByTagID != nil {
  606. mmGetPreviewByTagID.mock.t.Fatalf("ArticleRepositoryMock.GetPreviewByTagID mock is already set by Set")
  607. }
  608. if mmGetPreviewByTagID.defaultExpectation == nil {
  609. mmGetPreviewByTagID.defaultExpectation = &ArticleRepositoryMockGetPreviewByTagIDExpectation{}
  610. }
  611. if mmGetPreviewByTagID.defaultExpectation.params != nil {
  612. mmGetPreviewByTagID.mock.t.Fatalf("ArticleRepositoryMock.GetPreviewByTagID mock is already set by Expect")
  613. }
  614. if mmGetPreviewByTagID.defaultExpectation.paramPtrs == nil {
  615. mmGetPreviewByTagID.defaultExpectation.paramPtrs = &ArticleRepositoryMockGetPreviewByTagIDParamPtrs{}
  616. }
  617. mmGetPreviewByTagID.defaultExpectation.paramPtrs.ctx = &ctx
  618. return mmGetPreviewByTagID
  619. }
  620. // ExpectTagIDParam2 sets up expected param tagID for ArticleRepository.GetPreviewByTagID
  621. func (mmGetPreviewByTagID *mArticleRepositoryMockGetPreviewByTagID) ExpectTagIDParam2(tagID int) *mArticleRepositoryMockGetPreviewByTagID {
  622. if mmGetPreviewByTagID.mock.funcGetPreviewByTagID != nil {
  623. mmGetPreviewByTagID.mock.t.Fatalf("ArticleRepositoryMock.GetPreviewByTagID mock is already set by Set")
  624. }
  625. if mmGetPreviewByTagID.defaultExpectation == nil {
  626. mmGetPreviewByTagID.defaultExpectation = &ArticleRepositoryMockGetPreviewByTagIDExpectation{}
  627. }
  628. if mmGetPreviewByTagID.defaultExpectation.params != nil {
  629. mmGetPreviewByTagID.mock.t.Fatalf("ArticleRepositoryMock.GetPreviewByTagID mock is already set by Expect")
  630. }
  631. if mmGetPreviewByTagID.defaultExpectation.paramPtrs == nil {
  632. mmGetPreviewByTagID.defaultExpectation.paramPtrs = &ArticleRepositoryMockGetPreviewByTagIDParamPtrs{}
  633. }
  634. mmGetPreviewByTagID.defaultExpectation.paramPtrs.tagID = &tagID
  635. return mmGetPreviewByTagID
  636. }
  637. // Inspect accepts an inspector function that has same arguments as the ArticleRepository.GetPreviewByTagID
  638. func (mmGetPreviewByTagID *mArticleRepositoryMockGetPreviewByTagID) Inspect(f func(ctx context.Context, tagID int)) *mArticleRepositoryMockGetPreviewByTagID {
  639. if mmGetPreviewByTagID.mock.inspectFuncGetPreviewByTagID != nil {
  640. mmGetPreviewByTagID.mock.t.Fatalf("Inspect function is already set for ArticleRepositoryMock.GetPreviewByTagID")
  641. }
  642. mmGetPreviewByTagID.mock.inspectFuncGetPreviewByTagID = f
  643. return mmGetPreviewByTagID
  644. }
  645. // Return sets up results that will be returned by ArticleRepository.GetPreviewByTagID
  646. func (mmGetPreviewByTagID *mArticleRepositoryMockGetPreviewByTagID) Return(aa1 []models.ArticlePreview, err error) *ArticleRepositoryMock {
  647. if mmGetPreviewByTagID.mock.funcGetPreviewByTagID != nil {
  648. mmGetPreviewByTagID.mock.t.Fatalf("ArticleRepositoryMock.GetPreviewByTagID mock is already set by Set")
  649. }
  650. if mmGetPreviewByTagID.defaultExpectation == nil {
  651. mmGetPreviewByTagID.defaultExpectation = &ArticleRepositoryMockGetPreviewByTagIDExpectation{mock: mmGetPreviewByTagID.mock}
  652. }
  653. mmGetPreviewByTagID.defaultExpectation.results = &ArticleRepositoryMockGetPreviewByTagIDResults{aa1, err}
  654. return mmGetPreviewByTagID.mock
  655. }
  656. // Set uses given function f to mock the ArticleRepository.GetPreviewByTagID method
  657. func (mmGetPreviewByTagID *mArticleRepositoryMockGetPreviewByTagID) Set(f func(ctx context.Context, tagID int) (aa1 []models.ArticlePreview, err error)) *ArticleRepositoryMock {
  658. if mmGetPreviewByTagID.defaultExpectation != nil {
  659. mmGetPreviewByTagID.mock.t.Fatalf("Default expectation is already set for the ArticleRepository.GetPreviewByTagID method")
  660. }
  661. if len(mmGetPreviewByTagID.expectations) > 0 {
  662. mmGetPreviewByTagID.mock.t.Fatalf("Some expectations are already set for the ArticleRepository.GetPreviewByTagID method")
  663. }
  664. mmGetPreviewByTagID.mock.funcGetPreviewByTagID = f
  665. return mmGetPreviewByTagID.mock
  666. }
  667. // When sets expectation for the ArticleRepository.GetPreviewByTagID which will trigger the result defined by the following
  668. // Then helper
  669. func (mmGetPreviewByTagID *mArticleRepositoryMockGetPreviewByTagID) When(ctx context.Context, tagID int) *ArticleRepositoryMockGetPreviewByTagIDExpectation {
  670. if mmGetPreviewByTagID.mock.funcGetPreviewByTagID != nil {
  671. mmGetPreviewByTagID.mock.t.Fatalf("ArticleRepositoryMock.GetPreviewByTagID mock is already set by Set")
  672. }
  673. expectation := &ArticleRepositoryMockGetPreviewByTagIDExpectation{
  674. mock: mmGetPreviewByTagID.mock,
  675. params: &ArticleRepositoryMockGetPreviewByTagIDParams{ctx, tagID},
  676. }
  677. mmGetPreviewByTagID.expectations = append(mmGetPreviewByTagID.expectations, expectation)
  678. return expectation
  679. }
  680. // Then sets up ArticleRepository.GetPreviewByTagID return parameters for the expectation previously defined by the When method
  681. func (e *ArticleRepositoryMockGetPreviewByTagIDExpectation) Then(aa1 []models.ArticlePreview, err error) *ArticleRepositoryMock {
  682. e.results = &ArticleRepositoryMockGetPreviewByTagIDResults{aa1, err}
  683. return e.mock
  684. }
  685. // Times sets number of times ArticleRepository.GetPreviewByTagID should be invoked
  686. func (mmGetPreviewByTagID *mArticleRepositoryMockGetPreviewByTagID) Times(n uint64) *mArticleRepositoryMockGetPreviewByTagID {
  687. if n == 0 {
  688. mmGetPreviewByTagID.mock.t.Fatalf("Times of ArticleRepositoryMock.GetPreviewByTagID mock can not be zero")
  689. }
  690. mm_atomic.StoreUint64(&mmGetPreviewByTagID.expectedInvocations, n)
  691. return mmGetPreviewByTagID
  692. }
  693. func (mmGetPreviewByTagID *mArticleRepositoryMockGetPreviewByTagID) invocationsDone() bool {
  694. if len(mmGetPreviewByTagID.expectations) == 0 && mmGetPreviewByTagID.defaultExpectation == nil && mmGetPreviewByTagID.mock.funcGetPreviewByTagID == nil {
  695. return true
  696. }
  697. totalInvocations := mm_atomic.LoadUint64(&mmGetPreviewByTagID.mock.afterGetPreviewByTagIDCounter)
  698. expectedInvocations := mm_atomic.LoadUint64(&mmGetPreviewByTagID.expectedInvocations)
  699. return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
  700. }
  701. // GetPreviewByTagID implements handler.ArticleRepository
  702. func (mmGetPreviewByTagID *ArticleRepositoryMock) GetPreviewByTagID(ctx context.Context, tagID int) (aa1 []models.ArticlePreview, err error) {
  703. mm_atomic.AddUint64(&mmGetPreviewByTagID.beforeGetPreviewByTagIDCounter, 1)
  704. defer mm_atomic.AddUint64(&mmGetPreviewByTagID.afterGetPreviewByTagIDCounter, 1)
  705. if mmGetPreviewByTagID.inspectFuncGetPreviewByTagID != nil {
  706. mmGetPreviewByTagID.inspectFuncGetPreviewByTagID(ctx, tagID)
  707. }
  708. mm_params := ArticleRepositoryMockGetPreviewByTagIDParams{ctx, tagID}
  709. // Record call args
  710. mmGetPreviewByTagID.GetPreviewByTagIDMock.mutex.Lock()
  711. mmGetPreviewByTagID.GetPreviewByTagIDMock.callArgs = append(mmGetPreviewByTagID.GetPreviewByTagIDMock.callArgs, &mm_params)
  712. mmGetPreviewByTagID.GetPreviewByTagIDMock.mutex.Unlock()
  713. for _, e := range mmGetPreviewByTagID.GetPreviewByTagIDMock.expectations {
  714. if minimock.Equal(*e.params, mm_params) {
  715. mm_atomic.AddUint64(&e.Counter, 1)
  716. return e.results.aa1, e.results.err
  717. }
  718. }
  719. if mmGetPreviewByTagID.GetPreviewByTagIDMock.defaultExpectation != nil {
  720. mm_atomic.AddUint64(&mmGetPreviewByTagID.GetPreviewByTagIDMock.defaultExpectation.Counter, 1)
  721. mm_want := mmGetPreviewByTagID.GetPreviewByTagIDMock.defaultExpectation.params
  722. mm_want_ptrs := mmGetPreviewByTagID.GetPreviewByTagIDMock.defaultExpectation.paramPtrs
  723. mm_got := ArticleRepositoryMockGetPreviewByTagIDParams{ctx, tagID}
  724. if mm_want_ptrs != nil {
  725. if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
  726. mmGetPreviewByTagID.t.Errorf("ArticleRepositoryMock.GetPreviewByTagID got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
  727. }
  728. if mm_want_ptrs.tagID != nil && !minimock.Equal(*mm_want_ptrs.tagID, mm_got.tagID) {
  729. mmGetPreviewByTagID.t.Errorf("ArticleRepositoryMock.GetPreviewByTagID got unexpected parameter tagID, want: %#v, got: %#v%s\n", *mm_want_ptrs.tagID, mm_got.tagID, minimock.Diff(*mm_want_ptrs.tagID, mm_got.tagID))
  730. }
  731. } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
  732. mmGetPreviewByTagID.t.Errorf("ArticleRepositoryMock.GetPreviewByTagID got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
  733. }
  734. mm_results := mmGetPreviewByTagID.GetPreviewByTagIDMock.defaultExpectation.results
  735. if mm_results == nil {
  736. mmGetPreviewByTagID.t.Fatal("No results are set for the ArticleRepositoryMock.GetPreviewByTagID")
  737. }
  738. return (*mm_results).aa1, (*mm_results).err
  739. }
  740. if mmGetPreviewByTagID.funcGetPreviewByTagID != nil {
  741. return mmGetPreviewByTagID.funcGetPreviewByTagID(ctx, tagID)
  742. }
  743. mmGetPreviewByTagID.t.Fatalf("Unexpected call to ArticleRepositoryMock.GetPreviewByTagID. %v %v", ctx, tagID)
  744. return
  745. }
  746. // GetPreviewByTagIDAfterCounter returns a count of finished ArticleRepositoryMock.GetPreviewByTagID invocations
  747. func (mmGetPreviewByTagID *ArticleRepositoryMock) GetPreviewByTagIDAfterCounter() uint64 {
  748. return mm_atomic.LoadUint64(&mmGetPreviewByTagID.afterGetPreviewByTagIDCounter)
  749. }
  750. // GetPreviewByTagIDBeforeCounter returns a count of ArticleRepositoryMock.GetPreviewByTagID invocations
  751. func (mmGetPreviewByTagID *ArticleRepositoryMock) GetPreviewByTagIDBeforeCounter() uint64 {
  752. return mm_atomic.LoadUint64(&mmGetPreviewByTagID.beforeGetPreviewByTagIDCounter)
  753. }
  754. // Calls returns a list of arguments used in each call to ArticleRepositoryMock.GetPreviewByTagID.
  755. // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
  756. func (mmGetPreviewByTagID *mArticleRepositoryMockGetPreviewByTagID) Calls() []*ArticleRepositoryMockGetPreviewByTagIDParams {
  757. mmGetPreviewByTagID.mutex.RLock()
  758. argCopy := make([]*ArticleRepositoryMockGetPreviewByTagIDParams, len(mmGetPreviewByTagID.callArgs))
  759. copy(argCopy, mmGetPreviewByTagID.callArgs)
  760. mmGetPreviewByTagID.mutex.RUnlock()
  761. return argCopy
  762. }
  763. // MinimockGetPreviewByTagIDDone returns true if the count of the GetPreviewByTagID invocations corresponds
  764. // the number of defined expectations
  765. func (m *ArticleRepositoryMock) MinimockGetPreviewByTagIDDone() bool {
  766. if m.GetPreviewByTagIDMock.optional {
  767. // Optional methods provide '0 or more' call count restriction.
  768. return true
  769. }
  770. for _, e := range m.GetPreviewByTagIDMock.expectations {
  771. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  772. return false
  773. }
  774. }
  775. return m.GetPreviewByTagIDMock.invocationsDone()
  776. }
  777. // MinimockGetPreviewByTagIDInspect logs each unmet expectation
  778. func (m *ArticleRepositoryMock) MinimockGetPreviewByTagIDInspect() {
  779. for _, e := range m.GetPreviewByTagIDMock.expectations {
  780. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  781. m.t.Errorf("Expected call to ArticleRepositoryMock.GetPreviewByTagID with params: %#v", *e.params)
  782. }
  783. }
  784. afterGetPreviewByTagIDCounter := mm_atomic.LoadUint64(&m.afterGetPreviewByTagIDCounter)
  785. // if default expectation was set then invocations count should be greater than zero
  786. if m.GetPreviewByTagIDMock.defaultExpectation != nil && afterGetPreviewByTagIDCounter < 1 {
  787. if m.GetPreviewByTagIDMock.defaultExpectation.params == nil {
  788. m.t.Error("Expected call to ArticleRepositoryMock.GetPreviewByTagID")
  789. } else {
  790. m.t.Errorf("Expected call to ArticleRepositoryMock.GetPreviewByTagID with params: %#v", *m.GetPreviewByTagIDMock.defaultExpectation.params)
  791. }
  792. }
  793. // if func was set then invocations count should be greater than zero
  794. if m.funcGetPreviewByTagID != nil && afterGetPreviewByTagIDCounter < 1 {
  795. m.t.Error("Expected call to ArticleRepositoryMock.GetPreviewByTagID")
  796. }
  797. if !m.GetPreviewByTagIDMock.invocationsDone() && afterGetPreviewByTagIDCounter > 0 {
  798. m.t.Errorf("Expected %d calls to ArticleRepositoryMock.GetPreviewByTagID but found %d calls",
  799. mm_atomic.LoadUint64(&m.GetPreviewByTagIDMock.expectedInvocations), afterGetPreviewByTagIDCounter)
  800. }
  801. }
  802. // MinimockFinish checks that all mocked methods have been called the expected number of times
  803. func (m *ArticleRepositoryMock) MinimockFinish() {
  804. m.finishOnce.Do(func() {
  805. if !m.minimockDone() {
  806. m.MinimockGetAllPreviewInspect()
  807. m.MinimockGetByURLInspect()
  808. m.MinimockGetPreviewByTagIDInspect()
  809. }
  810. })
  811. }
  812. // MinimockWait waits for all mocked methods to be called the expected number of times
  813. func (m *ArticleRepositoryMock) MinimockWait(timeout mm_time.Duration) {
  814. timeoutCh := mm_time.After(timeout)
  815. for {
  816. if m.minimockDone() {
  817. return
  818. }
  819. select {
  820. case <-timeoutCh:
  821. m.MinimockFinish()
  822. return
  823. case <-mm_time.After(10 * mm_time.Millisecond):
  824. }
  825. }
  826. }
  827. func (m *ArticleRepositoryMock) minimockDone() bool {
  828. done := true
  829. return done &&
  830. m.MinimockGetAllPreviewDone() &&
  831. m.MinimockGetByURLDone() &&
  832. m.MinimockGetPreviewByTagIDDone()
  833. }