article_repository_minimock.go 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089
  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, lang models.LanguageID) (aa1 []models.ArticlePreview, err error)
  17. inspectFuncGetAllPreview func(ctx context.Context, lang models.LanguageID)
  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 uint64, lang models.LanguageID) (aa1 []models.ArticlePreview, err error)
  27. inspectFuncGetPreviewByTagID func(ctx context.Context, tagID uint64, lang models.LanguageID)
  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.LanguageID
  68. }
  69. // ArticleRepositoryMockGetAllPreviewParamPtrs contains pointers to parameters of the ArticleRepository.GetAllPreview
  70. type ArticleRepositoryMockGetAllPreviewParamPtrs struct {
  71. ctx *context.Context
  72. lang *models.LanguageID
  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.LanguageID) *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.LanguageID) *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.LanguageID)) *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.LanguageID) (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.LanguageID) *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.LanguageID) (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. }
  328. // ArticleRepositoryMockGetByURLParamPtrs contains pointers to parameters of the ArticleRepository.GetByURL
  329. type ArticleRepositoryMockGetByURLParamPtrs struct {
  330. ctx *context.Context
  331. url *string
  332. }
  333. // ArticleRepositoryMockGetByURLResults contains results of the ArticleRepository.GetByURL
  334. type ArticleRepositoryMockGetByURLResults struct {
  335. ap1 *models.Article
  336. err error
  337. }
  338. // Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
  339. // the test will fail minimock's automatic final call check if the mocked method was not called at least once.
  340. // Optional() makes method check to work in '0 or more' mode.
  341. // It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
  342. // catch the problems when the expected method call is totally skipped during test run.
  343. func (mmGetByURL *mArticleRepositoryMockGetByURL) Optional() *mArticleRepositoryMockGetByURL {
  344. mmGetByURL.optional = true
  345. return mmGetByURL
  346. }
  347. // Expect sets up expected params for ArticleRepository.GetByURL
  348. func (mmGetByURL *mArticleRepositoryMockGetByURL) Expect(ctx context.Context, url string) *mArticleRepositoryMockGetByURL {
  349. if mmGetByURL.mock.funcGetByURL != nil {
  350. mmGetByURL.mock.t.Fatalf("ArticleRepositoryMock.GetByURL mock is already set by Set")
  351. }
  352. if mmGetByURL.defaultExpectation == nil {
  353. mmGetByURL.defaultExpectation = &ArticleRepositoryMockGetByURLExpectation{}
  354. }
  355. if mmGetByURL.defaultExpectation.paramPtrs != nil {
  356. mmGetByURL.mock.t.Fatalf("ArticleRepositoryMock.GetByURL mock is already set by ExpectParams functions")
  357. }
  358. mmGetByURL.defaultExpectation.params = &ArticleRepositoryMockGetByURLParams{ctx, url}
  359. for _, e := range mmGetByURL.expectations {
  360. if minimock.Equal(e.params, mmGetByURL.defaultExpectation.params) {
  361. mmGetByURL.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetByURL.defaultExpectation.params)
  362. }
  363. }
  364. return mmGetByURL
  365. }
  366. // ExpectCtxParam1 sets up expected param ctx for ArticleRepository.GetByURL
  367. func (mmGetByURL *mArticleRepositoryMockGetByURL) ExpectCtxParam1(ctx context.Context) *mArticleRepositoryMockGetByURL {
  368. if mmGetByURL.mock.funcGetByURL != nil {
  369. mmGetByURL.mock.t.Fatalf("ArticleRepositoryMock.GetByURL mock is already set by Set")
  370. }
  371. if mmGetByURL.defaultExpectation == nil {
  372. mmGetByURL.defaultExpectation = &ArticleRepositoryMockGetByURLExpectation{}
  373. }
  374. if mmGetByURL.defaultExpectation.params != nil {
  375. mmGetByURL.mock.t.Fatalf("ArticleRepositoryMock.GetByURL mock is already set by Expect")
  376. }
  377. if mmGetByURL.defaultExpectation.paramPtrs == nil {
  378. mmGetByURL.defaultExpectation.paramPtrs = &ArticleRepositoryMockGetByURLParamPtrs{}
  379. }
  380. mmGetByURL.defaultExpectation.paramPtrs.ctx = &ctx
  381. return mmGetByURL
  382. }
  383. // ExpectUrlParam2 sets up expected param url for ArticleRepository.GetByURL
  384. func (mmGetByURL *mArticleRepositoryMockGetByURL) ExpectUrlParam2(url string) *mArticleRepositoryMockGetByURL {
  385. if mmGetByURL.mock.funcGetByURL != nil {
  386. mmGetByURL.mock.t.Fatalf("ArticleRepositoryMock.GetByURL mock is already set by Set")
  387. }
  388. if mmGetByURL.defaultExpectation == nil {
  389. mmGetByURL.defaultExpectation = &ArticleRepositoryMockGetByURLExpectation{}
  390. }
  391. if mmGetByURL.defaultExpectation.params != nil {
  392. mmGetByURL.mock.t.Fatalf("ArticleRepositoryMock.GetByURL mock is already set by Expect")
  393. }
  394. if mmGetByURL.defaultExpectation.paramPtrs == nil {
  395. mmGetByURL.defaultExpectation.paramPtrs = &ArticleRepositoryMockGetByURLParamPtrs{}
  396. }
  397. mmGetByURL.defaultExpectation.paramPtrs.url = &url
  398. return mmGetByURL
  399. }
  400. // Inspect accepts an inspector function that has same arguments as the ArticleRepository.GetByURL
  401. func (mmGetByURL *mArticleRepositoryMockGetByURL) Inspect(f func(ctx context.Context, url string)) *mArticleRepositoryMockGetByURL {
  402. if mmGetByURL.mock.inspectFuncGetByURL != nil {
  403. mmGetByURL.mock.t.Fatalf("Inspect function is already set for ArticleRepositoryMock.GetByURL")
  404. }
  405. mmGetByURL.mock.inspectFuncGetByURL = f
  406. return mmGetByURL
  407. }
  408. // Return sets up results that will be returned by ArticleRepository.GetByURL
  409. func (mmGetByURL *mArticleRepositoryMockGetByURL) Return(ap1 *models.Article, err error) *ArticleRepositoryMock {
  410. if mmGetByURL.mock.funcGetByURL != nil {
  411. mmGetByURL.mock.t.Fatalf("ArticleRepositoryMock.GetByURL mock is already set by Set")
  412. }
  413. if mmGetByURL.defaultExpectation == nil {
  414. mmGetByURL.defaultExpectation = &ArticleRepositoryMockGetByURLExpectation{mock: mmGetByURL.mock}
  415. }
  416. mmGetByURL.defaultExpectation.results = &ArticleRepositoryMockGetByURLResults{ap1, err}
  417. return mmGetByURL.mock
  418. }
  419. // Set uses given function f to mock the ArticleRepository.GetByURL method
  420. func (mmGetByURL *mArticleRepositoryMockGetByURL) Set(f func(ctx context.Context, url string) (ap1 *models.Article, err error)) *ArticleRepositoryMock {
  421. if mmGetByURL.defaultExpectation != nil {
  422. mmGetByURL.mock.t.Fatalf("Default expectation is already set for the ArticleRepository.GetByURL method")
  423. }
  424. if len(mmGetByURL.expectations) > 0 {
  425. mmGetByURL.mock.t.Fatalf("Some expectations are already set for the ArticleRepository.GetByURL method")
  426. }
  427. mmGetByURL.mock.funcGetByURL = f
  428. return mmGetByURL.mock
  429. }
  430. // When sets expectation for the ArticleRepository.GetByURL which will trigger the result defined by the following
  431. // Then helper
  432. func (mmGetByURL *mArticleRepositoryMockGetByURL) When(ctx context.Context, url string) *ArticleRepositoryMockGetByURLExpectation {
  433. if mmGetByURL.mock.funcGetByURL != nil {
  434. mmGetByURL.mock.t.Fatalf("ArticleRepositoryMock.GetByURL mock is already set by Set")
  435. }
  436. expectation := &ArticleRepositoryMockGetByURLExpectation{
  437. mock: mmGetByURL.mock,
  438. params: &ArticleRepositoryMockGetByURLParams{ctx, url},
  439. }
  440. mmGetByURL.expectations = append(mmGetByURL.expectations, expectation)
  441. return expectation
  442. }
  443. // Then sets up ArticleRepository.GetByURL return parameters for the expectation previously defined by the When method
  444. func (e *ArticleRepositoryMockGetByURLExpectation) Then(ap1 *models.Article, err error) *ArticleRepositoryMock {
  445. e.results = &ArticleRepositoryMockGetByURLResults{ap1, err}
  446. return e.mock
  447. }
  448. // Times sets number of times ArticleRepository.GetByURL should be invoked
  449. func (mmGetByURL *mArticleRepositoryMockGetByURL) Times(n uint64) *mArticleRepositoryMockGetByURL {
  450. if n == 0 {
  451. mmGetByURL.mock.t.Fatalf("Times of ArticleRepositoryMock.GetByURL mock can not be zero")
  452. }
  453. mm_atomic.StoreUint64(&mmGetByURL.expectedInvocations, n)
  454. return mmGetByURL
  455. }
  456. func (mmGetByURL *mArticleRepositoryMockGetByURL) invocationsDone() bool {
  457. if len(mmGetByURL.expectations) == 0 && mmGetByURL.defaultExpectation == nil && mmGetByURL.mock.funcGetByURL == nil {
  458. return true
  459. }
  460. totalInvocations := mm_atomic.LoadUint64(&mmGetByURL.mock.afterGetByURLCounter)
  461. expectedInvocations := mm_atomic.LoadUint64(&mmGetByURL.expectedInvocations)
  462. return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
  463. }
  464. // GetByURL implements handler.ArticleRepository
  465. func (mmGetByURL *ArticleRepositoryMock) GetByURL(ctx context.Context, url string) (ap1 *models.Article, err error) {
  466. mm_atomic.AddUint64(&mmGetByURL.beforeGetByURLCounter, 1)
  467. defer mm_atomic.AddUint64(&mmGetByURL.afterGetByURLCounter, 1)
  468. if mmGetByURL.inspectFuncGetByURL != nil {
  469. mmGetByURL.inspectFuncGetByURL(ctx, url)
  470. }
  471. mm_params := ArticleRepositoryMockGetByURLParams{ctx, url}
  472. // Record call args
  473. mmGetByURL.GetByURLMock.mutex.Lock()
  474. mmGetByURL.GetByURLMock.callArgs = append(mmGetByURL.GetByURLMock.callArgs, &mm_params)
  475. mmGetByURL.GetByURLMock.mutex.Unlock()
  476. for _, e := range mmGetByURL.GetByURLMock.expectations {
  477. if minimock.Equal(*e.params, mm_params) {
  478. mm_atomic.AddUint64(&e.Counter, 1)
  479. return e.results.ap1, e.results.err
  480. }
  481. }
  482. if mmGetByURL.GetByURLMock.defaultExpectation != nil {
  483. mm_atomic.AddUint64(&mmGetByURL.GetByURLMock.defaultExpectation.Counter, 1)
  484. mm_want := mmGetByURL.GetByURLMock.defaultExpectation.params
  485. mm_want_ptrs := mmGetByURL.GetByURLMock.defaultExpectation.paramPtrs
  486. mm_got := ArticleRepositoryMockGetByURLParams{ctx, url}
  487. if mm_want_ptrs != nil {
  488. if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
  489. 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))
  490. }
  491. if mm_want_ptrs.url != nil && !minimock.Equal(*mm_want_ptrs.url, mm_got.url) {
  492. 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))
  493. }
  494. } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
  495. mmGetByURL.t.Errorf("ArticleRepositoryMock.GetByURL got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
  496. }
  497. mm_results := mmGetByURL.GetByURLMock.defaultExpectation.results
  498. if mm_results == nil {
  499. mmGetByURL.t.Fatal("No results are set for the ArticleRepositoryMock.GetByURL")
  500. }
  501. return (*mm_results).ap1, (*mm_results).err
  502. }
  503. if mmGetByURL.funcGetByURL != nil {
  504. return mmGetByURL.funcGetByURL(ctx, url)
  505. }
  506. mmGetByURL.t.Fatalf("Unexpected call to ArticleRepositoryMock.GetByURL. %v %v", ctx, url)
  507. return
  508. }
  509. // GetByURLAfterCounter returns a count of finished ArticleRepositoryMock.GetByURL invocations
  510. func (mmGetByURL *ArticleRepositoryMock) GetByURLAfterCounter() uint64 {
  511. return mm_atomic.LoadUint64(&mmGetByURL.afterGetByURLCounter)
  512. }
  513. // GetByURLBeforeCounter returns a count of ArticleRepositoryMock.GetByURL invocations
  514. func (mmGetByURL *ArticleRepositoryMock) GetByURLBeforeCounter() uint64 {
  515. return mm_atomic.LoadUint64(&mmGetByURL.beforeGetByURLCounter)
  516. }
  517. // Calls returns a list of arguments used in each call to ArticleRepositoryMock.GetByURL.
  518. // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
  519. func (mmGetByURL *mArticleRepositoryMockGetByURL) Calls() []*ArticleRepositoryMockGetByURLParams {
  520. mmGetByURL.mutex.RLock()
  521. argCopy := make([]*ArticleRepositoryMockGetByURLParams, len(mmGetByURL.callArgs))
  522. copy(argCopy, mmGetByURL.callArgs)
  523. mmGetByURL.mutex.RUnlock()
  524. return argCopy
  525. }
  526. // MinimockGetByURLDone returns true if the count of the GetByURL invocations corresponds
  527. // the number of defined expectations
  528. func (m *ArticleRepositoryMock) MinimockGetByURLDone() bool {
  529. if m.GetByURLMock.optional {
  530. // Optional methods provide '0 or more' call count restriction.
  531. return true
  532. }
  533. for _, e := range m.GetByURLMock.expectations {
  534. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  535. return false
  536. }
  537. }
  538. return m.GetByURLMock.invocationsDone()
  539. }
  540. // MinimockGetByURLInspect logs each unmet expectation
  541. func (m *ArticleRepositoryMock) MinimockGetByURLInspect() {
  542. for _, e := range m.GetByURLMock.expectations {
  543. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  544. m.t.Errorf("Expected call to ArticleRepositoryMock.GetByURL with params: %#v", *e.params)
  545. }
  546. }
  547. afterGetByURLCounter := mm_atomic.LoadUint64(&m.afterGetByURLCounter)
  548. // if default expectation was set then invocations count should be greater than zero
  549. if m.GetByURLMock.defaultExpectation != nil && afterGetByURLCounter < 1 {
  550. if m.GetByURLMock.defaultExpectation.params == nil {
  551. m.t.Error("Expected call to ArticleRepositoryMock.GetByURL")
  552. } else {
  553. m.t.Errorf("Expected call to ArticleRepositoryMock.GetByURL with params: %#v", *m.GetByURLMock.defaultExpectation.params)
  554. }
  555. }
  556. // if func was set then invocations count should be greater than zero
  557. if m.funcGetByURL != nil && afterGetByURLCounter < 1 {
  558. m.t.Error("Expected call to ArticleRepositoryMock.GetByURL")
  559. }
  560. if !m.GetByURLMock.invocationsDone() && afterGetByURLCounter > 0 {
  561. m.t.Errorf("Expected %d calls to ArticleRepositoryMock.GetByURL but found %d calls",
  562. mm_atomic.LoadUint64(&m.GetByURLMock.expectedInvocations), afterGetByURLCounter)
  563. }
  564. }
  565. type mArticleRepositoryMockGetPreviewByTagID struct {
  566. optional bool
  567. mock *ArticleRepositoryMock
  568. defaultExpectation *ArticleRepositoryMockGetPreviewByTagIDExpectation
  569. expectations []*ArticleRepositoryMockGetPreviewByTagIDExpectation
  570. callArgs []*ArticleRepositoryMockGetPreviewByTagIDParams
  571. mutex sync.RWMutex
  572. expectedInvocations uint64
  573. }
  574. // ArticleRepositoryMockGetPreviewByTagIDExpectation specifies expectation struct of the ArticleRepository.GetPreviewByTagID
  575. type ArticleRepositoryMockGetPreviewByTagIDExpectation struct {
  576. mock *ArticleRepositoryMock
  577. params *ArticleRepositoryMockGetPreviewByTagIDParams
  578. paramPtrs *ArticleRepositoryMockGetPreviewByTagIDParamPtrs
  579. results *ArticleRepositoryMockGetPreviewByTagIDResults
  580. Counter uint64
  581. }
  582. // ArticleRepositoryMockGetPreviewByTagIDParams contains parameters of the ArticleRepository.GetPreviewByTagID
  583. type ArticleRepositoryMockGetPreviewByTagIDParams struct {
  584. ctx context.Context
  585. tagID uint64
  586. lang models.LanguageID
  587. }
  588. // ArticleRepositoryMockGetPreviewByTagIDParamPtrs contains pointers to parameters of the ArticleRepository.GetPreviewByTagID
  589. type ArticleRepositoryMockGetPreviewByTagIDParamPtrs struct {
  590. ctx *context.Context
  591. tagID *uint64
  592. lang *models.LanguageID
  593. }
  594. // ArticleRepositoryMockGetPreviewByTagIDResults contains results of the ArticleRepository.GetPreviewByTagID
  595. type ArticleRepositoryMockGetPreviewByTagIDResults struct {
  596. aa1 []models.ArticlePreview
  597. err error
  598. }
  599. // Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
  600. // the test will fail minimock's automatic final call check if the mocked method was not called at least once.
  601. // Optional() makes method check to work in '0 or more' mode.
  602. // It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
  603. // catch the problems when the expected method call is totally skipped during test run.
  604. func (mmGetPreviewByTagID *mArticleRepositoryMockGetPreviewByTagID) Optional() *mArticleRepositoryMockGetPreviewByTagID {
  605. mmGetPreviewByTagID.optional = true
  606. return mmGetPreviewByTagID
  607. }
  608. // Expect sets up expected params for ArticleRepository.GetPreviewByTagID
  609. func (mmGetPreviewByTagID *mArticleRepositoryMockGetPreviewByTagID) Expect(ctx context.Context, tagID uint64, lang models.LanguageID) *mArticleRepositoryMockGetPreviewByTagID {
  610. if mmGetPreviewByTagID.mock.funcGetPreviewByTagID != nil {
  611. mmGetPreviewByTagID.mock.t.Fatalf("ArticleRepositoryMock.GetPreviewByTagID mock is already set by Set")
  612. }
  613. if mmGetPreviewByTagID.defaultExpectation == nil {
  614. mmGetPreviewByTagID.defaultExpectation = &ArticleRepositoryMockGetPreviewByTagIDExpectation{}
  615. }
  616. if mmGetPreviewByTagID.defaultExpectation.paramPtrs != nil {
  617. mmGetPreviewByTagID.mock.t.Fatalf("ArticleRepositoryMock.GetPreviewByTagID mock is already set by ExpectParams functions")
  618. }
  619. mmGetPreviewByTagID.defaultExpectation.params = &ArticleRepositoryMockGetPreviewByTagIDParams{ctx, tagID, lang}
  620. for _, e := range mmGetPreviewByTagID.expectations {
  621. if minimock.Equal(e.params, mmGetPreviewByTagID.defaultExpectation.params) {
  622. mmGetPreviewByTagID.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetPreviewByTagID.defaultExpectation.params)
  623. }
  624. }
  625. return mmGetPreviewByTagID
  626. }
  627. // ExpectCtxParam1 sets up expected param ctx for ArticleRepository.GetPreviewByTagID
  628. func (mmGetPreviewByTagID *mArticleRepositoryMockGetPreviewByTagID) ExpectCtxParam1(ctx context.Context) *mArticleRepositoryMockGetPreviewByTagID {
  629. if mmGetPreviewByTagID.mock.funcGetPreviewByTagID != nil {
  630. mmGetPreviewByTagID.mock.t.Fatalf("ArticleRepositoryMock.GetPreviewByTagID mock is already set by Set")
  631. }
  632. if mmGetPreviewByTagID.defaultExpectation == nil {
  633. mmGetPreviewByTagID.defaultExpectation = &ArticleRepositoryMockGetPreviewByTagIDExpectation{}
  634. }
  635. if mmGetPreviewByTagID.defaultExpectation.params != nil {
  636. mmGetPreviewByTagID.mock.t.Fatalf("ArticleRepositoryMock.GetPreviewByTagID mock is already set by Expect")
  637. }
  638. if mmGetPreviewByTagID.defaultExpectation.paramPtrs == nil {
  639. mmGetPreviewByTagID.defaultExpectation.paramPtrs = &ArticleRepositoryMockGetPreviewByTagIDParamPtrs{}
  640. }
  641. mmGetPreviewByTagID.defaultExpectation.paramPtrs.ctx = &ctx
  642. return mmGetPreviewByTagID
  643. }
  644. // ExpectTagIDParam2 sets up expected param tagID for ArticleRepository.GetPreviewByTagID
  645. func (mmGetPreviewByTagID *mArticleRepositoryMockGetPreviewByTagID) ExpectTagIDParam2(tagID uint64) *mArticleRepositoryMockGetPreviewByTagID {
  646. if mmGetPreviewByTagID.mock.funcGetPreviewByTagID != nil {
  647. mmGetPreviewByTagID.mock.t.Fatalf("ArticleRepositoryMock.GetPreviewByTagID mock is already set by Set")
  648. }
  649. if mmGetPreviewByTagID.defaultExpectation == nil {
  650. mmGetPreviewByTagID.defaultExpectation = &ArticleRepositoryMockGetPreviewByTagIDExpectation{}
  651. }
  652. if mmGetPreviewByTagID.defaultExpectation.params != nil {
  653. mmGetPreviewByTagID.mock.t.Fatalf("ArticleRepositoryMock.GetPreviewByTagID mock is already set by Expect")
  654. }
  655. if mmGetPreviewByTagID.defaultExpectation.paramPtrs == nil {
  656. mmGetPreviewByTagID.defaultExpectation.paramPtrs = &ArticleRepositoryMockGetPreviewByTagIDParamPtrs{}
  657. }
  658. mmGetPreviewByTagID.defaultExpectation.paramPtrs.tagID = &tagID
  659. return mmGetPreviewByTagID
  660. }
  661. // ExpectLangParam3 sets up expected param lang for ArticleRepository.GetPreviewByTagID
  662. func (mmGetPreviewByTagID *mArticleRepositoryMockGetPreviewByTagID) ExpectLangParam3(lang models.LanguageID) *mArticleRepositoryMockGetPreviewByTagID {
  663. if mmGetPreviewByTagID.mock.funcGetPreviewByTagID != nil {
  664. mmGetPreviewByTagID.mock.t.Fatalf("ArticleRepositoryMock.GetPreviewByTagID mock is already set by Set")
  665. }
  666. if mmGetPreviewByTagID.defaultExpectation == nil {
  667. mmGetPreviewByTagID.defaultExpectation = &ArticleRepositoryMockGetPreviewByTagIDExpectation{}
  668. }
  669. if mmGetPreviewByTagID.defaultExpectation.params != nil {
  670. mmGetPreviewByTagID.mock.t.Fatalf("ArticleRepositoryMock.GetPreviewByTagID mock is already set by Expect")
  671. }
  672. if mmGetPreviewByTagID.defaultExpectation.paramPtrs == nil {
  673. mmGetPreviewByTagID.defaultExpectation.paramPtrs = &ArticleRepositoryMockGetPreviewByTagIDParamPtrs{}
  674. }
  675. mmGetPreviewByTagID.defaultExpectation.paramPtrs.lang = &lang
  676. return mmGetPreviewByTagID
  677. }
  678. // Inspect accepts an inspector function that has same arguments as the ArticleRepository.GetPreviewByTagID
  679. func (mmGetPreviewByTagID *mArticleRepositoryMockGetPreviewByTagID) Inspect(f func(ctx context.Context, tagID uint64, lang models.LanguageID)) *mArticleRepositoryMockGetPreviewByTagID {
  680. if mmGetPreviewByTagID.mock.inspectFuncGetPreviewByTagID != nil {
  681. mmGetPreviewByTagID.mock.t.Fatalf("Inspect function is already set for ArticleRepositoryMock.GetPreviewByTagID")
  682. }
  683. mmGetPreviewByTagID.mock.inspectFuncGetPreviewByTagID = f
  684. return mmGetPreviewByTagID
  685. }
  686. // Return sets up results that will be returned by ArticleRepository.GetPreviewByTagID
  687. func (mmGetPreviewByTagID *mArticleRepositoryMockGetPreviewByTagID) Return(aa1 []models.ArticlePreview, err error) *ArticleRepositoryMock {
  688. if mmGetPreviewByTagID.mock.funcGetPreviewByTagID != nil {
  689. mmGetPreviewByTagID.mock.t.Fatalf("ArticleRepositoryMock.GetPreviewByTagID mock is already set by Set")
  690. }
  691. if mmGetPreviewByTagID.defaultExpectation == nil {
  692. mmGetPreviewByTagID.defaultExpectation = &ArticleRepositoryMockGetPreviewByTagIDExpectation{mock: mmGetPreviewByTagID.mock}
  693. }
  694. mmGetPreviewByTagID.defaultExpectation.results = &ArticleRepositoryMockGetPreviewByTagIDResults{aa1, err}
  695. return mmGetPreviewByTagID.mock
  696. }
  697. // Set uses given function f to mock the ArticleRepository.GetPreviewByTagID method
  698. func (mmGetPreviewByTagID *mArticleRepositoryMockGetPreviewByTagID) Set(f func(ctx context.Context, tagID uint64, lang models.LanguageID) (aa1 []models.ArticlePreview, err error)) *ArticleRepositoryMock {
  699. if mmGetPreviewByTagID.defaultExpectation != nil {
  700. mmGetPreviewByTagID.mock.t.Fatalf("Default expectation is already set for the ArticleRepository.GetPreviewByTagID method")
  701. }
  702. if len(mmGetPreviewByTagID.expectations) > 0 {
  703. mmGetPreviewByTagID.mock.t.Fatalf("Some expectations are already set for the ArticleRepository.GetPreviewByTagID method")
  704. }
  705. mmGetPreviewByTagID.mock.funcGetPreviewByTagID = f
  706. return mmGetPreviewByTagID.mock
  707. }
  708. // When sets expectation for the ArticleRepository.GetPreviewByTagID which will trigger the result defined by the following
  709. // Then helper
  710. func (mmGetPreviewByTagID *mArticleRepositoryMockGetPreviewByTagID) When(ctx context.Context, tagID uint64, lang models.LanguageID) *ArticleRepositoryMockGetPreviewByTagIDExpectation {
  711. if mmGetPreviewByTagID.mock.funcGetPreviewByTagID != nil {
  712. mmGetPreviewByTagID.mock.t.Fatalf("ArticleRepositoryMock.GetPreviewByTagID mock is already set by Set")
  713. }
  714. expectation := &ArticleRepositoryMockGetPreviewByTagIDExpectation{
  715. mock: mmGetPreviewByTagID.mock,
  716. params: &ArticleRepositoryMockGetPreviewByTagIDParams{ctx, tagID, lang},
  717. }
  718. mmGetPreviewByTagID.expectations = append(mmGetPreviewByTagID.expectations, expectation)
  719. return expectation
  720. }
  721. // Then sets up ArticleRepository.GetPreviewByTagID return parameters for the expectation previously defined by the When method
  722. func (e *ArticleRepositoryMockGetPreviewByTagIDExpectation) Then(aa1 []models.ArticlePreview, err error) *ArticleRepositoryMock {
  723. e.results = &ArticleRepositoryMockGetPreviewByTagIDResults{aa1, err}
  724. return e.mock
  725. }
  726. // Times sets number of times ArticleRepository.GetPreviewByTagID should be invoked
  727. func (mmGetPreviewByTagID *mArticleRepositoryMockGetPreviewByTagID) Times(n uint64) *mArticleRepositoryMockGetPreviewByTagID {
  728. if n == 0 {
  729. mmGetPreviewByTagID.mock.t.Fatalf("Times of ArticleRepositoryMock.GetPreviewByTagID mock can not be zero")
  730. }
  731. mm_atomic.StoreUint64(&mmGetPreviewByTagID.expectedInvocations, n)
  732. return mmGetPreviewByTagID
  733. }
  734. func (mmGetPreviewByTagID *mArticleRepositoryMockGetPreviewByTagID) invocationsDone() bool {
  735. if len(mmGetPreviewByTagID.expectations) == 0 && mmGetPreviewByTagID.defaultExpectation == nil && mmGetPreviewByTagID.mock.funcGetPreviewByTagID == nil {
  736. return true
  737. }
  738. totalInvocations := mm_atomic.LoadUint64(&mmGetPreviewByTagID.mock.afterGetPreviewByTagIDCounter)
  739. expectedInvocations := mm_atomic.LoadUint64(&mmGetPreviewByTagID.expectedInvocations)
  740. return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
  741. }
  742. // GetPreviewByTagID implements handler.ArticleRepository
  743. func (mmGetPreviewByTagID *ArticleRepositoryMock) GetPreviewByTagID(ctx context.Context, tagID uint64, lang models.LanguageID) (aa1 []models.ArticlePreview, err error) {
  744. mm_atomic.AddUint64(&mmGetPreviewByTagID.beforeGetPreviewByTagIDCounter, 1)
  745. defer mm_atomic.AddUint64(&mmGetPreviewByTagID.afterGetPreviewByTagIDCounter, 1)
  746. if mmGetPreviewByTagID.inspectFuncGetPreviewByTagID != nil {
  747. mmGetPreviewByTagID.inspectFuncGetPreviewByTagID(ctx, tagID, lang)
  748. }
  749. mm_params := ArticleRepositoryMockGetPreviewByTagIDParams{ctx, tagID, lang}
  750. // Record call args
  751. mmGetPreviewByTagID.GetPreviewByTagIDMock.mutex.Lock()
  752. mmGetPreviewByTagID.GetPreviewByTagIDMock.callArgs = append(mmGetPreviewByTagID.GetPreviewByTagIDMock.callArgs, &mm_params)
  753. mmGetPreviewByTagID.GetPreviewByTagIDMock.mutex.Unlock()
  754. for _, e := range mmGetPreviewByTagID.GetPreviewByTagIDMock.expectations {
  755. if minimock.Equal(*e.params, mm_params) {
  756. mm_atomic.AddUint64(&e.Counter, 1)
  757. return e.results.aa1, e.results.err
  758. }
  759. }
  760. if mmGetPreviewByTagID.GetPreviewByTagIDMock.defaultExpectation != nil {
  761. mm_atomic.AddUint64(&mmGetPreviewByTagID.GetPreviewByTagIDMock.defaultExpectation.Counter, 1)
  762. mm_want := mmGetPreviewByTagID.GetPreviewByTagIDMock.defaultExpectation.params
  763. mm_want_ptrs := mmGetPreviewByTagID.GetPreviewByTagIDMock.defaultExpectation.paramPtrs
  764. mm_got := ArticleRepositoryMockGetPreviewByTagIDParams{ctx, tagID, lang}
  765. if mm_want_ptrs != nil {
  766. if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
  767. 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))
  768. }
  769. if mm_want_ptrs.tagID != nil && !minimock.Equal(*mm_want_ptrs.tagID, mm_got.tagID) {
  770. 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))
  771. }
  772. if mm_want_ptrs.lang != nil && !minimock.Equal(*mm_want_ptrs.lang, mm_got.lang) {
  773. 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))
  774. }
  775. } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
  776. mmGetPreviewByTagID.t.Errorf("ArticleRepositoryMock.GetPreviewByTagID got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
  777. }
  778. mm_results := mmGetPreviewByTagID.GetPreviewByTagIDMock.defaultExpectation.results
  779. if mm_results == nil {
  780. mmGetPreviewByTagID.t.Fatal("No results are set for the ArticleRepositoryMock.GetPreviewByTagID")
  781. }
  782. return (*mm_results).aa1, (*mm_results).err
  783. }
  784. if mmGetPreviewByTagID.funcGetPreviewByTagID != nil {
  785. return mmGetPreviewByTagID.funcGetPreviewByTagID(ctx, tagID, lang)
  786. }
  787. mmGetPreviewByTagID.t.Fatalf("Unexpected call to ArticleRepositoryMock.GetPreviewByTagID. %v %v %v", ctx, tagID, lang)
  788. return
  789. }
  790. // GetPreviewByTagIDAfterCounter returns a count of finished ArticleRepositoryMock.GetPreviewByTagID invocations
  791. func (mmGetPreviewByTagID *ArticleRepositoryMock) GetPreviewByTagIDAfterCounter() uint64 {
  792. return mm_atomic.LoadUint64(&mmGetPreviewByTagID.afterGetPreviewByTagIDCounter)
  793. }
  794. // GetPreviewByTagIDBeforeCounter returns a count of ArticleRepositoryMock.GetPreviewByTagID invocations
  795. func (mmGetPreviewByTagID *ArticleRepositoryMock) GetPreviewByTagIDBeforeCounter() uint64 {
  796. return mm_atomic.LoadUint64(&mmGetPreviewByTagID.beforeGetPreviewByTagIDCounter)
  797. }
  798. // Calls returns a list of arguments used in each call to ArticleRepositoryMock.GetPreviewByTagID.
  799. // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
  800. func (mmGetPreviewByTagID *mArticleRepositoryMockGetPreviewByTagID) Calls() []*ArticleRepositoryMockGetPreviewByTagIDParams {
  801. mmGetPreviewByTagID.mutex.RLock()
  802. argCopy := make([]*ArticleRepositoryMockGetPreviewByTagIDParams, len(mmGetPreviewByTagID.callArgs))
  803. copy(argCopy, mmGetPreviewByTagID.callArgs)
  804. mmGetPreviewByTagID.mutex.RUnlock()
  805. return argCopy
  806. }
  807. // MinimockGetPreviewByTagIDDone returns true if the count of the GetPreviewByTagID invocations corresponds
  808. // the number of defined expectations
  809. func (m *ArticleRepositoryMock) MinimockGetPreviewByTagIDDone() bool {
  810. if m.GetPreviewByTagIDMock.optional {
  811. // Optional methods provide '0 or more' call count restriction.
  812. return true
  813. }
  814. for _, e := range m.GetPreviewByTagIDMock.expectations {
  815. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  816. return false
  817. }
  818. }
  819. return m.GetPreviewByTagIDMock.invocationsDone()
  820. }
  821. // MinimockGetPreviewByTagIDInspect logs each unmet expectation
  822. func (m *ArticleRepositoryMock) MinimockGetPreviewByTagIDInspect() {
  823. for _, e := range m.GetPreviewByTagIDMock.expectations {
  824. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  825. m.t.Errorf("Expected call to ArticleRepositoryMock.GetPreviewByTagID with params: %#v", *e.params)
  826. }
  827. }
  828. afterGetPreviewByTagIDCounter := mm_atomic.LoadUint64(&m.afterGetPreviewByTagIDCounter)
  829. // if default expectation was set then invocations count should be greater than zero
  830. if m.GetPreviewByTagIDMock.defaultExpectation != nil && afterGetPreviewByTagIDCounter < 1 {
  831. if m.GetPreviewByTagIDMock.defaultExpectation.params == nil {
  832. m.t.Error("Expected call to ArticleRepositoryMock.GetPreviewByTagID")
  833. } else {
  834. m.t.Errorf("Expected call to ArticleRepositoryMock.GetPreviewByTagID with params: %#v", *m.GetPreviewByTagIDMock.defaultExpectation.params)
  835. }
  836. }
  837. // if func was set then invocations count should be greater than zero
  838. if m.funcGetPreviewByTagID != nil && afterGetPreviewByTagIDCounter < 1 {
  839. m.t.Error("Expected call to ArticleRepositoryMock.GetPreviewByTagID")
  840. }
  841. if !m.GetPreviewByTagIDMock.invocationsDone() && afterGetPreviewByTagIDCounter > 0 {
  842. m.t.Errorf("Expected %d calls to ArticleRepositoryMock.GetPreviewByTagID but found %d calls",
  843. mm_atomic.LoadUint64(&m.GetPreviewByTagIDMock.expectedInvocations), afterGetPreviewByTagIDCounter)
  844. }
  845. }
  846. // MinimockFinish checks that all mocked methods have been called the expected number of times
  847. func (m *ArticleRepositoryMock) MinimockFinish() {
  848. m.finishOnce.Do(func() {
  849. if !m.minimockDone() {
  850. m.MinimockGetAllPreviewInspect()
  851. m.MinimockGetByURLInspect()
  852. m.MinimockGetPreviewByTagIDInspect()
  853. }
  854. })
  855. }
  856. // MinimockWait waits for all mocked methods to be called the expected number of times
  857. func (m *ArticleRepositoryMock) MinimockWait(timeout mm_time.Duration) {
  858. timeoutCh := mm_time.After(timeout)
  859. for {
  860. if m.minimockDone() {
  861. return
  862. }
  863. select {
  864. case <-timeoutCh:
  865. m.MinimockFinish()
  866. return
  867. case <-mm_time.After(10 * mm_time.Millisecond):
  868. }
  869. }
  870. }
  871. func (m *ArticleRepositoryMock) minimockDone() bool {
  872. done := true
  873. return done &&
  874. m.MinimockGetAllPreviewDone() &&
  875. m.MinimockGetByURLDone() &&
  876. m.MinimockGetPreviewByTagIDDone()
  877. }