article_repository_minimock.go 47 KB

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