mocks_test.go 146 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317
  1. // Code generated by go-mockgen 1.3.3; DO NOT EDIT.
  2. //
  3. // This file was generated by running `go-mockgen` at the root of this repository.
  4. // To add additional mocks to this or another package, add a new entry to the
  5. // mockgen.yaml file in the root of this repository.
  6. package lfs
  7. import (
  8. "context"
  9. "sync"
  10. db "gogs.io/gogs/internal/db"
  11. lfsutil "gogs.io/gogs/internal/lfsutil"
  12. )
  13. // MockAccessTokensStore is a mock implementation of the AccessTokensStore
  14. // interface (from the package gogs.io/gogs/internal/db) used for unit
  15. // testing.
  16. type MockAccessTokensStore struct {
  17. // CreateFunc is an instance of a mock function object controlling the
  18. // behavior of the method Create.
  19. CreateFunc *AccessTokensStoreCreateFunc
  20. // DeleteByIDFunc is an instance of a mock function object controlling
  21. // the behavior of the method DeleteByID.
  22. DeleteByIDFunc *AccessTokensStoreDeleteByIDFunc
  23. // GetBySHA1Func is an instance of a mock function object controlling
  24. // the behavior of the method GetBySHA1.
  25. GetBySHA1Func *AccessTokensStoreGetBySHA1Func
  26. // ListFunc is an instance of a mock function object controlling the
  27. // behavior of the method List.
  28. ListFunc *AccessTokensStoreListFunc
  29. // TouchFunc is an instance of a mock function object controlling the
  30. // behavior of the method Touch.
  31. TouchFunc *AccessTokensStoreTouchFunc
  32. }
  33. // NewMockAccessTokensStore creates a new mock of the AccessTokensStore
  34. // interface. All methods return zero values for all results, unless
  35. // overwritten.
  36. func NewMockAccessTokensStore() *MockAccessTokensStore {
  37. return &MockAccessTokensStore{
  38. CreateFunc: &AccessTokensStoreCreateFunc{
  39. defaultHook: func(context.Context, int64, string) (r0 *db.AccessToken, r1 error) {
  40. return
  41. },
  42. },
  43. DeleteByIDFunc: &AccessTokensStoreDeleteByIDFunc{
  44. defaultHook: func(context.Context, int64, int64) (r0 error) {
  45. return
  46. },
  47. },
  48. GetBySHA1Func: &AccessTokensStoreGetBySHA1Func{
  49. defaultHook: func(context.Context, string) (r0 *db.AccessToken, r1 error) {
  50. return
  51. },
  52. },
  53. ListFunc: &AccessTokensStoreListFunc{
  54. defaultHook: func(context.Context, int64) (r0 []*db.AccessToken, r1 error) {
  55. return
  56. },
  57. },
  58. TouchFunc: &AccessTokensStoreTouchFunc{
  59. defaultHook: func(context.Context, int64) (r0 error) {
  60. return
  61. },
  62. },
  63. }
  64. }
  65. // NewStrictMockAccessTokensStore creates a new mock of the
  66. // AccessTokensStore interface. All methods panic on invocation, unless
  67. // overwritten.
  68. func NewStrictMockAccessTokensStore() *MockAccessTokensStore {
  69. return &MockAccessTokensStore{
  70. CreateFunc: &AccessTokensStoreCreateFunc{
  71. defaultHook: func(context.Context, int64, string) (*db.AccessToken, error) {
  72. panic("unexpected invocation of MockAccessTokensStore.Create")
  73. },
  74. },
  75. DeleteByIDFunc: &AccessTokensStoreDeleteByIDFunc{
  76. defaultHook: func(context.Context, int64, int64) error {
  77. panic("unexpected invocation of MockAccessTokensStore.DeleteByID")
  78. },
  79. },
  80. GetBySHA1Func: &AccessTokensStoreGetBySHA1Func{
  81. defaultHook: func(context.Context, string) (*db.AccessToken, error) {
  82. panic("unexpected invocation of MockAccessTokensStore.GetBySHA1")
  83. },
  84. },
  85. ListFunc: &AccessTokensStoreListFunc{
  86. defaultHook: func(context.Context, int64) ([]*db.AccessToken, error) {
  87. panic("unexpected invocation of MockAccessTokensStore.List")
  88. },
  89. },
  90. TouchFunc: &AccessTokensStoreTouchFunc{
  91. defaultHook: func(context.Context, int64) error {
  92. panic("unexpected invocation of MockAccessTokensStore.Touch")
  93. },
  94. },
  95. }
  96. }
  97. // NewMockAccessTokensStoreFrom creates a new mock of the
  98. // MockAccessTokensStore interface. All methods delegate to the given
  99. // implementation, unless overwritten.
  100. func NewMockAccessTokensStoreFrom(i db.AccessTokensStore) *MockAccessTokensStore {
  101. return &MockAccessTokensStore{
  102. CreateFunc: &AccessTokensStoreCreateFunc{
  103. defaultHook: i.Create,
  104. },
  105. DeleteByIDFunc: &AccessTokensStoreDeleteByIDFunc{
  106. defaultHook: i.DeleteByID,
  107. },
  108. GetBySHA1Func: &AccessTokensStoreGetBySHA1Func{
  109. defaultHook: i.GetBySHA1,
  110. },
  111. ListFunc: &AccessTokensStoreListFunc{
  112. defaultHook: i.List,
  113. },
  114. TouchFunc: &AccessTokensStoreTouchFunc{
  115. defaultHook: i.Touch,
  116. },
  117. }
  118. }
  119. // AccessTokensStoreCreateFunc describes the behavior when the Create method
  120. // of the parent MockAccessTokensStore instance is invoked.
  121. type AccessTokensStoreCreateFunc struct {
  122. defaultHook func(context.Context, int64, string) (*db.AccessToken, error)
  123. hooks []func(context.Context, int64, string) (*db.AccessToken, error)
  124. history []AccessTokensStoreCreateFuncCall
  125. mutex sync.Mutex
  126. }
  127. // Create delegates to the next hook function in the queue and stores the
  128. // parameter and result values of this invocation.
  129. func (m *MockAccessTokensStore) Create(v0 context.Context, v1 int64, v2 string) (*db.AccessToken, error) {
  130. r0, r1 := m.CreateFunc.nextHook()(v0, v1, v2)
  131. m.CreateFunc.appendCall(AccessTokensStoreCreateFuncCall{v0, v1, v2, r0, r1})
  132. return r0, r1
  133. }
  134. // SetDefaultHook sets function that is called when the Create method of the
  135. // parent MockAccessTokensStore instance is invoked and the hook queue is
  136. // empty.
  137. func (f *AccessTokensStoreCreateFunc) SetDefaultHook(hook func(context.Context, int64, string) (*db.AccessToken, error)) {
  138. f.defaultHook = hook
  139. }
  140. // PushHook adds a function to the end of hook queue. Each invocation of the
  141. // Create method of the parent MockAccessTokensStore instance invokes the
  142. // hook at the front of the queue and discards it. After the queue is empty,
  143. // the default hook function is invoked for any future action.
  144. func (f *AccessTokensStoreCreateFunc) PushHook(hook func(context.Context, int64, string) (*db.AccessToken, error)) {
  145. f.mutex.Lock()
  146. f.hooks = append(f.hooks, hook)
  147. f.mutex.Unlock()
  148. }
  149. // SetDefaultReturn calls SetDefaultHook with a function that returns the
  150. // given values.
  151. func (f *AccessTokensStoreCreateFunc) SetDefaultReturn(r0 *db.AccessToken, r1 error) {
  152. f.SetDefaultHook(func(context.Context, int64, string) (*db.AccessToken, error) {
  153. return r0, r1
  154. })
  155. }
  156. // PushReturn calls PushHook with a function that returns the given values.
  157. func (f *AccessTokensStoreCreateFunc) PushReturn(r0 *db.AccessToken, r1 error) {
  158. f.PushHook(func(context.Context, int64, string) (*db.AccessToken, error) {
  159. return r0, r1
  160. })
  161. }
  162. func (f *AccessTokensStoreCreateFunc) nextHook() func(context.Context, int64, string) (*db.AccessToken, error) {
  163. f.mutex.Lock()
  164. defer f.mutex.Unlock()
  165. if len(f.hooks) == 0 {
  166. return f.defaultHook
  167. }
  168. hook := f.hooks[0]
  169. f.hooks = f.hooks[1:]
  170. return hook
  171. }
  172. func (f *AccessTokensStoreCreateFunc) appendCall(r0 AccessTokensStoreCreateFuncCall) {
  173. f.mutex.Lock()
  174. f.history = append(f.history, r0)
  175. f.mutex.Unlock()
  176. }
  177. // History returns a sequence of AccessTokensStoreCreateFuncCall objects
  178. // describing the invocations of this function.
  179. func (f *AccessTokensStoreCreateFunc) History() []AccessTokensStoreCreateFuncCall {
  180. f.mutex.Lock()
  181. history := make([]AccessTokensStoreCreateFuncCall, len(f.history))
  182. copy(history, f.history)
  183. f.mutex.Unlock()
  184. return history
  185. }
  186. // AccessTokensStoreCreateFuncCall is an object that describes an invocation
  187. // of method Create on an instance of MockAccessTokensStore.
  188. type AccessTokensStoreCreateFuncCall struct {
  189. // Arg0 is the value of the 1st argument passed to this method
  190. // invocation.
  191. Arg0 context.Context
  192. // Arg1 is the value of the 2nd argument passed to this method
  193. // invocation.
  194. Arg1 int64
  195. // Arg2 is the value of the 3rd argument passed to this method
  196. // invocation.
  197. Arg2 string
  198. // Result0 is the value of the 1st result returned from this method
  199. // invocation.
  200. Result0 *db.AccessToken
  201. // Result1 is the value of the 2nd result returned from this method
  202. // invocation.
  203. Result1 error
  204. }
  205. // Args returns an interface slice containing the arguments of this
  206. // invocation.
  207. func (c AccessTokensStoreCreateFuncCall) Args() []interface{} {
  208. return []interface{}{c.Arg0, c.Arg1, c.Arg2}
  209. }
  210. // Results returns an interface slice containing the results of this
  211. // invocation.
  212. func (c AccessTokensStoreCreateFuncCall) Results() []interface{} {
  213. return []interface{}{c.Result0, c.Result1}
  214. }
  215. // AccessTokensStoreDeleteByIDFunc describes the behavior when the
  216. // DeleteByID method of the parent MockAccessTokensStore instance is
  217. // invoked.
  218. type AccessTokensStoreDeleteByIDFunc struct {
  219. defaultHook func(context.Context, int64, int64) error
  220. hooks []func(context.Context, int64, int64) error
  221. history []AccessTokensStoreDeleteByIDFuncCall
  222. mutex sync.Mutex
  223. }
  224. // DeleteByID delegates to the next hook function in the queue and stores
  225. // the parameter and result values of this invocation.
  226. func (m *MockAccessTokensStore) DeleteByID(v0 context.Context, v1 int64, v2 int64) error {
  227. r0 := m.DeleteByIDFunc.nextHook()(v0, v1, v2)
  228. m.DeleteByIDFunc.appendCall(AccessTokensStoreDeleteByIDFuncCall{v0, v1, v2, r0})
  229. return r0
  230. }
  231. // SetDefaultHook sets function that is called when the DeleteByID method of
  232. // the parent MockAccessTokensStore instance is invoked and the hook queue
  233. // is empty.
  234. func (f *AccessTokensStoreDeleteByIDFunc) SetDefaultHook(hook func(context.Context, int64, int64) error) {
  235. f.defaultHook = hook
  236. }
  237. // PushHook adds a function to the end of hook queue. Each invocation of the
  238. // DeleteByID method of the parent MockAccessTokensStore instance invokes
  239. // the hook at the front of the queue and discards it. After the queue is
  240. // empty, the default hook function is invoked for any future action.
  241. func (f *AccessTokensStoreDeleteByIDFunc) PushHook(hook func(context.Context, int64, int64) error) {
  242. f.mutex.Lock()
  243. f.hooks = append(f.hooks, hook)
  244. f.mutex.Unlock()
  245. }
  246. // SetDefaultReturn calls SetDefaultHook with a function that returns the
  247. // given values.
  248. func (f *AccessTokensStoreDeleteByIDFunc) SetDefaultReturn(r0 error) {
  249. f.SetDefaultHook(func(context.Context, int64, int64) error {
  250. return r0
  251. })
  252. }
  253. // PushReturn calls PushHook with a function that returns the given values.
  254. func (f *AccessTokensStoreDeleteByIDFunc) PushReturn(r0 error) {
  255. f.PushHook(func(context.Context, int64, int64) error {
  256. return r0
  257. })
  258. }
  259. func (f *AccessTokensStoreDeleteByIDFunc) nextHook() func(context.Context, int64, int64) error {
  260. f.mutex.Lock()
  261. defer f.mutex.Unlock()
  262. if len(f.hooks) == 0 {
  263. return f.defaultHook
  264. }
  265. hook := f.hooks[0]
  266. f.hooks = f.hooks[1:]
  267. return hook
  268. }
  269. func (f *AccessTokensStoreDeleteByIDFunc) appendCall(r0 AccessTokensStoreDeleteByIDFuncCall) {
  270. f.mutex.Lock()
  271. f.history = append(f.history, r0)
  272. f.mutex.Unlock()
  273. }
  274. // History returns a sequence of AccessTokensStoreDeleteByIDFuncCall objects
  275. // describing the invocations of this function.
  276. func (f *AccessTokensStoreDeleteByIDFunc) History() []AccessTokensStoreDeleteByIDFuncCall {
  277. f.mutex.Lock()
  278. history := make([]AccessTokensStoreDeleteByIDFuncCall, len(f.history))
  279. copy(history, f.history)
  280. f.mutex.Unlock()
  281. return history
  282. }
  283. // AccessTokensStoreDeleteByIDFuncCall is an object that describes an
  284. // invocation of method DeleteByID on an instance of MockAccessTokensStore.
  285. type AccessTokensStoreDeleteByIDFuncCall struct {
  286. // Arg0 is the value of the 1st argument passed to this method
  287. // invocation.
  288. Arg0 context.Context
  289. // Arg1 is the value of the 2nd argument passed to this method
  290. // invocation.
  291. Arg1 int64
  292. // Arg2 is the value of the 3rd argument passed to this method
  293. // invocation.
  294. Arg2 int64
  295. // Result0 is the value of the 1st result returned from this method
  296. // invocation.
  297. Result0 error
  298. }
  299. // Args returns an interface slice containing the arguments of this
  300. // invocation.
  301. func (c AccessTokensStoreDeleteByIDFuncCall) Args() []interface{} {
  302. return []interface{}{c.Arg0, c.Arg1, c.Arg2}
  303. }
  304. // Results returns an interface slice containing the results of this
  305. // invocation.
  306. func (c AccessTokensStoreDeleteByIDFuncCall) Results() []interface{} {
  307. return []interface{}{c.Result0}
  308. }
  309. // AccessTokensStoreGetBySHA1Func describes the behavior when the GetBySHA1
  310. // method of the parent MockAccessTokensStore instance is invoked.
  311. type AccessTokensStoreGetBySHA1Func struct {
  312. defaultHook func(context.Context, string) (*db.AccessToken, error)
  313. hooks []func(context.Context, string) (*db.AccessToken, error)
  314. history []AccessTokensStoreGetBySHA1FuncCall
  315. mutex sync.Mutex
  316. }
  317. // GetBySHA1 delegates to the next hook function in the queue and stores the
  318. // parameter and result values of this invocation.
  319. func (m *MockAccessTokensStore) GetBySHA1(v0 context.Context, v1 string) (*db.AccessToken, error) {
  320. r0, r1 := m.GetBySHA1Func.nextHook()(v0, v1)
  321. m.GetBySHA1Func.appendCall(AccessTokensStoreGetBySHA1FuncCall{v0, v1, r0, r1})
  322. return r0, r1
  323. }
  324. // SetDefaultHook sets function that is called when the GetBySHA1 method of
  325. // the parent MockAccessTokensStore instance is invoked and the hook queue
  326. // is empty.
  327. func (f *AccessTokensStoreGetBySHA1Func) SetDefaultHook(hook func(context.Context, string) (*db.AccessToken, error)) {
  328. f.defaultHook = hook
  329. }
  330. // PushHook adds a function to the end of hook queue. Each invocation of the
  331. // GetBySHA1 method of the parent MockAccessTokensStore instance invokes the
  332. // hook at the front of the queue and discards it. After the queue is empty,
  333. // the default hook function is invoked for any future action.
  334. func (f *AccessTokensStoreGetBySHA1Func) PushHook(hook func(context.Context, string) (*db.AccessToken, error)) {
  335. f.mutex.Lock()
  336. f.hooks = append(f.hooks, hook)
  337. f.mutex.Unlock()
  338. }
  339. // SetDefaultReturn calls SetDefaultHook with a function that returns the
  340. // given values.
  341. func (f *AccessTokensStoreGetBySHA1Func) SetDefaultReturn(r0 *db.AccessToken, r1 error) {
  342. f.SetDefaultHook(func(context.Context, string) (*db.AccessToken, error) {
  343. return r0, r1
  344. })
  345. }
  346. // PushReturn calls PushHook with a function that returns the given values.
  347. func (f *AccessTokensStoreGetBySHA1Func) PushReturn(r0 *db.AccessToken, r1 error) {
  348. f.PushHook(func(context.Context, string) (*db.AccessToken, error) {
  349. return r0, r1
  350. })
  351. }
  352. func (f *AccessTokensStoreGetBySHA1Func) nextHook() func(context.Context, string) (*db.AccessToken, error) {
  353. f.mutex.Lock()
  354. defer f.mutex.Unlock()
  355. if len(f.hooks) == 0 {
  356. return f.defaultHook
  357. }
  358. hook := f.hooks[0]
  359. f.hooks = f.hooks[1:]
  360. return hook
  361. }
  362. func (f *AccessTokensStoreGetBySHA1Func) appendCall(r0 AccessTokensStoreGetBySHA1FuncCall) {
  363. f.mutex.Lock()
  364. f.history = append(f.history, r0)
  365. f.mutex.Unlock()
  366. }
  367. // History returns a sequence of AccessTokensStoreGetBySHA1FuncCall objects
  368. // describing the invocations of this function.
  369. func (f *AccessTokensStoreGetBySHA1Func) History() []AccessTokensStoreGetBySHA1FuncCall {
  370. f.mutex.Lock()
  371. history := make([]AccessTokensStoreGetBySHA1FuncCall, len(f.history))
  372. copy(history, f.history)
  373. f.mutex.Unlock()
  374. return history
  375. }
  376. // AccessTokensStoreGetBySHA1FuncCall is an object that describes an
  377. // invocation of method GetBySHA1 on an instance of MockAccessTokensStore.
  378. type AccessTokensStoreGetBySHA1FuncCall struct {
  379. // Arg0 is the value of the 1st argument passed to this method
  380. // invocation.
  381. Arg0 context.Context
  382. // Arg1 is the value of the 2nd argument passed to this method
  383. // invocation.
  384. Arg1 string
  385. // Result0 is the value of the 1st result returned from this method
  386. // invocation.
  387. Result0 *db.AccessToken
  388. // Result1 is the value of the 2nd result returned from this method
  389. // invocation.
  390. Result1 error
  391. }
  392. // Args returns an interface slice containing the arguments of this
  393. // invocation.
  394. func (c AccessTokensStoreGetBySHA1FuncCall) Args() []interface{} {
  395. return []interface{}{c.Arg0, c.Arg1}
  396. }
  397. // Results returns an interface slice containing the results of this
  398. // invocation.
  399. func (c AccessTokensStoreGetBySHA1FuncCall) Results() []interface{} {
  400. return []interface{}{c.Result0, c.Result1}
  401. }
  402. // AccessTokensStoreListFunc describes the behavior when the List method of
  403. // the parent MockAccessTokensStore instance is invoked.
  404. type AccessTokensStoreListFunc struct {
  405. defaultHook func(context.Context, int64) ([]*db.AccessToken, error)
  406. hooks []func(context.Context, int64) ([]*db.AccessToken, error)
  407. history []AccessTokensStoreListFuncCall
  408. mutex sync.Mutex
  409. }
  410. // List delegates to the next hook function in the queue and stores the
  411. // parameter and result values of this invocation.
  412. func (m *MockAccessTokensStore) List(v0 context.Context, v1 int64) ([]*db.AccessToken, error) {
  413. r0, r1 := m.ListFunc.nextHook()(v0, v1)
  414. m.ListFunc.appendCall(AccessTokensStoreListFuncCall{v0, v1, r0, r1})
  415. return r0, r1
  416. }
  417. // SetDefaultHook sets function that is called when the List method of the
  418. // parent MockAccessTokensStore instance is invoked and the hook queue is
  419. // empty.
  420. func (f *AccessTokensStoreListFunc) SetDefaultHook(hook func(context.Context, int64) ([]*db.AccessToken, error)) {
  421. f.defaultHook = hook
  422. }
  423. // PushHook adds a function to the end of hook queue. Each invocation of the
  424. // List method of the parent MockAccessTokensStore instance invokes the hook
  425. // at the front of the queue and discards it. After the queue is empty, the
  426. // default hook function is invoked for any future action.
  427. func (f *AccessTokensStoreListFunc) PushHook(hook func(context.Context, int64) ([]*db.AccessToken, error)) {
  428. f.mutex.Lock()
  429. f.hooks = append(f.hooks, hook)
  430. f.mutex.Unlock()
  431. }
  432. // SetDefaultReturn calls SetDefaultHook with a function that returns the
  433. // given values.
  434. func (f *AccessTokensStoreListFunc) SetDefaultReturn(r0 []*db.AccessToken, r1 error) {
  435. f.SetDefaultHook(func(context.Context, int64) ([]*db.AccessToken, error) {
  436. return r0, r1
  437. })
  438. }
  439. // PushReturn calls PushHook with a function that returns the given values.
  440. func (f *AccessTokensStoreListFunc) PushReturn(r0 []*db.AccessToken, r1 error) {
  441. f.PushHook(func(context.Context, int64) ([]*db.AccessToken, error) {
  442. return r0, r1
  443. })
  444. }
  445. func (f *AccessTokensStoreListFunc) nextHook() func(context.Context, int64) ([]*db.AccessToken, error) {
  446. f.mutex.Lock()
  447. defer f.mutex.Unlock()
  448. if len(f.hooks) == 0 {
  449. return f.defaultHook
  450. }
  451. hook := f.hooks[0]
  452. f.hooks = f.hooks[1:]
  453. return hook
  454. }
  455. func (f *AccessTokensStoreListFunc) appendCall(r0 AccessTokensStoreListFuncCall) {
  456. f.mutex.Lock()
  457. f.history = append(f.history, r0)
  458. f.mutex.Unlock()
  459. }
  460. // History returns a sequence of AccessTokensStoreListFuncCall objects
  461. // describing the invocations of this function.
  462. func (f *AccessTokensStoreListFunc) History() []AccessTokensStoreListFuncCall {
  463. f.mutex.Lock()
  464. history := make([]AccessTokensStoreListFuncCall, len(f.history))
  465. copy(history, f.history)
  466. f.mutex.Unlock()
  467. return history
  468. }
  469. // AccessTokensStoreListFuncCall is an object that describes an invocation
  470. // of method List on an instance of MockAccessTokensStore.
  471. type AccessTokensStoreListFuncCall struct {
  472. // Arg0 is the value of the 1st argument passed to this method
  473. // invocation.
  474. Arg0 context.Context
  475. // Arg1 is the value of the 2nd argument passed to this method
  476. // invocation.
  477. Arg1 int64
  478. // Result0 is the value of the 1st result returned from this method
  479. // invocation.
  480. Result0 []*db.AccessToken
  481. // Result1 is the value of the 2nd result returned from this method
  482. // invocation.
  483. Result1 error
  484. }
  485. // Args returns an interface slice containing the arguments of this
  486. // invocation.
  487. func (c AccessTokensStoreListFuncCall) Args() []interface{} {
  488. return []interface{}{c.Arg0, c.Arg1}
  489. }
  490. // Results returns an interface slice containing the results of this
  491. // invocation.
  492. func (c AccessTokensStoreListFuncCall) Results() []interface{} {
  493. return []interface{}{c.Result0, c.Result1}
  494. }
  495. // AccessTokensStoreTouchFunc describes the behavior when the Touch method
  496. // of the parent MockAccessTokensStore instance is invoked.
  497. type AccessTokensStoreTouchFunc struct {
  498. defaultHook func(context.Context, int64) error
  499. hooks []func(context.Context, int64) error
  500. history []AccessTokensStoreTouchFuncCall
  501. mutex sync.Mutex
  502. }
  503. // Touch delegates to the next hook function in the queue and stores the
  504. // parameter and result values of this invocation.
  505. func (m *MockAccessTokensStore) Touch(v0 context.Context, v1 int64) error {
  506. r0 := m.TouchFunc.nextHook()(v0, v1)
  507. m.TouchFunc.appendCall(AccessTokensStoreTouchFuncCall{v0, v1, r0})
  508. return r0
  509. }
  510. // SetDefaultHook sets function that is called when the Touch method of the
  511. // parent MockAccessTokensStore instance is invoked and the hook queue is
  512. // empty.
  513. func (f *AccessTokensStoreTouchFunc) SetDefaultHook(hook func(context.Context, int64) error) {
  514. f.defaultHook = hook
  515. }
  516. // PushHook adds a function to the end of hook queue. Each invocation of the
  517. // Touch method of the parent MockAccessTokensStore instance invokes the
  518. // hook at the front of the queue and discards it. After the queue is empty,
  519. // the default hook function is invoked for any future action.
  520. func (f *AccessTokensStoreTouchFunc) PushHook(hook func(context.Context, int64) error) {
  521. f.mutex.Lock()
  522. f.hooks = append(f.hooks, hook)
  523. f.mutex.Unlock()
  524. }
  525. // SetDefaultReturn calls SetDefaultHook with a function that returns the
  526. // given values.
  527. func (f *AccessTokensStoreTouchFunc) SetDefaultReturn(r0 error) {
  528. f.SetDefaultHook(func(context.Context, int64) error {
  529. return r0
  530. })
  531. }
  532. // PushReturn calls PushHook with a function that returns the given values.
  533. func (f *AccessTokensStoreTouchFunc) PushReturn(r0 error) {
  534. f.PushHook(func(context.Context, int64) error {
  535. return r0
  536. })
  537. }
  538. func (f *AccessTokensStoreTouchFunc) nextHook() func(context.Context, int64) error {
  539. f.mutex.Lock()
  540. defer f.mutex.Unlock()
  541. if len(f.hooks) == 0 {
  542. return f.defaultHook
  543. }
  544. hook := f.hooks[0]
  545. f.hooks = f.hooks[1:]
  546. return hook
  547. }
  548. func (f *AccessTokensStoreTouchFunc) appendCall(r0 AccessTokensStoreTouchFuncCall) {
  549. f.mutex.Lock()
  550. f.history = append(f.history, r0)
  551. f.mutex.Unlock()
  552. }
  553. // History returns a sequence of AccessTokensStoreTouchFuncCall objects
  554. // describing the invocations of this function.
  555. func (f *AccessTokensStoreTouchFunc) History() []AccessTokensStoreTouchFuncCall {
  556. f.mutex.Lock()
  557. history := make([]AccessTokensStoreTouchFuncCall, len(f.history))
  558. copy(history, f.history)
  559. f.mutex.Unlock()
  560. return history
  561. }
  562. // AccessTokensStoreTouchFuncCall is an object that describes an invocation
  563. // of method Touch on an instance of MockAccessTokensStore.
  564. type AccessTokensStoreTouchFuncCall struct {
  565. // Arg0 is the value of the 1st argument passed to this method
  566. // invocation.
  567. Arg0 context.Context
  568. // Arg1 is the value of the 2nd argument passed to this method
  569. // invocation.
  570. Arg1 int64
  571. // Result0 is the value of the 1st result returned from this method
  572. // invocation.
  573. Result0 error
  574. }
  575. // Args returns an interface slice containing the arguments of this
  576. // invocation.
  577. func (c AccessTokensStoreTouchFuncCall) Args() []interface{} {
  578. return []interface{}{c.Arg0, c.Arg1}
  579. }
  580. // Results returns an interface slice containing the results of this
  581. // invocation.
  582. func (c AccessTokensStoreTouchFuncCall) Results() []interface{} {
  583. return []interface{}{c.Result0}
  584. }
  585. // MockLFSStore is a mock implementation of the LFSStore interface (from the
  586. // package gogs.io/gogs/internal/db) used for unit testing.
  587. type MockLFSStore struct {
  588. // CreateObjectFunc is an instance of a mock function object controlling
  589. // the behavior of the method CreateObject.
  590. CreateObjectFunc *LFSStoreCreateObjectFunc
  591. // GetObjectByOIDFunc is an instance of a mock function object
  592. // controlling the behavior of the method GetObjectByOID.
  593. GetObjectByOIDFunc *LFSStoreGetObjectByOIDFunc
  594. // GetObjectsByOIDsFunc is an instance of a mock function object
  595. // controlling the behavior of the method GetObjectsByOIDs.
  596. GetObjectsByOIDsFunc *LFSStoreGetObjectsByOIDsFunc
  597. }
  598. // NewMockLFSStore creates a new mock of the LFSStore interface. All methods
  599. // return zero values for all results, unless overwritten.
  600. func NewMockLFSStore() *MockLFSStore {
  601. return &MockLFSStore{
  602. CreateObjectFunc: &LFSStoreCreateObjectFunc{
  603. defaultHook: func(context.Context, int64, lfsutil.OID, int64, lfsutil.Storage) (r0 error) {
  604. return
  605. },
  606. },
  607. GetObjectByOIDFunc: &LFSStoreGetObjectByOIDFunc{
  608. defaultHook: func(context.Context, int64, lfsutil.OID) (r0 *db.LFSObject, r1 error) {
  609. return
  610. },
  611. },
  612. GetObjectsByOIDsFunc: &LFSStoreGetObjectsByOIDsFunc{
  613. defaultHook: func(context.Context, int64, ...lfsutil.OID) (r0 []*db.LFSObject, r1 error) {
  614. return
  615. },
  616. },
  617. }
  618. }
  619. // NewStrictMockLFSStore creates a new mock of the LFSStore interface. All
  620. // methods panic on invocation, unless overwritten.
  621. func NewStrictMockLFSStore() *MockLFSStore {
  622. return &MockLFSStore{
  623. CreateObjectFunc: &LFSStoreCreateObjectFunc{
  624. defaultHook: func(context.Context, int64, lfsutil.OID, int64, lfsutil.Storage) error {
  625. panic("unexpected invocation of MockLFSStore.CreateObject")
  626. },
  627. },
  628. GetObjectByOIDFunc: &LFSStoreGetObjectByOIDFunc{
  629. defaultHook: func(context.Context, int64, lfsutil.OID) (*db.LFSObject, error) {
  630. panic("unexpected invocation of MockLFSStore.GetObjectByOID")
  631. },
  632. },
  633. GetObjectsByOIDsFunc: &LFSStoreGetObjectsByOIDsFunc{
  634. defaultHook: func(context.Context, int64, ...lfsutil.OID) ([]*db.LFSObject, error) {
  635. panic("unexpected invocation of MockLFSStore.GetObjectsByOIDs")
  636. },
  637. },
  638. }
  639. }
  640. // NewMockLFSStoreFrom creates a new mock of the MockLFSStore interface. All
  641. // methods delegate to the given implementation, unless overwritten.
  642. func NewMockLFSStoreFrom(i db.LFSStore) *MockLFSStore {
  643. return &MockLFSStore{
  644. CreateObjectFunc: &LFSStoreCreateObjectFunc{
  645. defaultHook: i.CreateObject,
  646. },
  647. GetObjectByOIDFunc: &LFSStoreGetObjectByOIDFunc{
  648. defaultHook: i.GetObjectByOID,
  649. },
  650. GetObjectsByOIDsFunc: &LFSStoreGetObjectsByOIDsFunc{
  651. defaultHook: i.GetObjectsByOIDs,
  652. },
  653. }
  654. }
  655. // LFSStoreCreateObjectFunc describes the behavior when the CreateObject
  656. // method of the parent MockLFSStore instance is invoked.
  657. type LFSStoreCreateObjectFunc struct {
  658. defaultHook func(context.Context, int64, lfsutil.OID, int64, lfsutil.Storage) error
  659. hooks []func(context.Context, int64, lfsutil.OID, int64, lfsutil.Storage) error
  660. history []LFSStoreCreateObjectFuncCall
  661. mutex sync.Mutex
  662. }
  663. // CreateObject delegates to the next hook function in the queue and stores
  664. // the parameter and result values of this invocation.
  665. func (m *MockLFSStore) CreateObject(v0 context.Context, v1 int64, v2 lfsutil.OID, v3 int64, v4 lfsutil.Storage) error {
  666. r0 := m.CreateObjectFunc.nextHook()(v0, v1, v2, v3, v4)
  667. m.CreateObjectFunc.appendCall(LFSStoreCreateObjectFuncCall{v0, v1, v2, v3, v4, r0})
  668. return r0
  669. }
  670. // SetDefaultHook sets function that is called when the CreateObject method
  671. // of the parent MockLFSStore instance is invoked and the hook queue is
  672. // empty.
  673. func (f *LFSStoreCreateObjectFunc) SetDefaultHook(hook func(context.Context, int64, lfsutil.OID, int64, lfsutil.Storage) error) {
  674. f.defaultHook = hook
  675. }
  676. // PushHook adds a function to the end of hook queue. Each invocation of the
  677. // CreateObject method of the parent MockLFSStore instance invokes the hook
  678. // at the front of the queue and discards it. After the queue is empty, the
  679. // default hook function is invoked for any future action.
  680. func (f *LFSStoreCreateObjectFunc) PushHook(hook func(context.Context, int64, lfsutil.OID, int64, lfsutil.Storage) error) {
  681. f.mutex.Lock()
  682. f.hooks = append(f.hooks, hook)
  683. f.mutex.Unlock()
  684. }
  685. // SetDefaultReturn calls SetDefaultHook with a function that returns the
  686. // given values.
  687. func (f *LFSStoreCreateObjectFunc) SetDefaultReturn(r0 error) {
  688. f.SetDefaultHook(func(context.Context, int64, lfsutil.OID, int64, lfsutil.Storage) error {
  689. return r0
  690. })
  691. }
  692. // PushReturn calls PushHook with a function that returns the given values.
  693. func (f *LFSStoreCreateObjectFunc) PushReturn(r0 error) {
  694. f.PushHook(func(context.Context, int64, lfsutil.OID, int64, lfsutil.Storage) error {
  695. return r0
  696. })
  697. }
  698. func (f *LFSStoreCreateObjectFunc) nextHook() func(context.Context, int64, lfsutil.OID, int64, lfsutil.Storage) error {
  699. f.mutex.Lock()
  700. defer f.mutex.Unlock()
  701. if len(f.hooks) == 0 {
  702. return f.defaultHook
  703. }
  704. hook := f.hooks[0]
  705. f.hooks = f.hooks[1:]
  706. return hook
  707. }
  708. func (f *LFSStoreCreateObjectFunc) appendCall(r0 LFSStoreCreateObjectFuncCall) {
  709. f.mutex.Lock()
  710. f.history = append(f.history, r0)
  711. f.mutex.Unlock()
  712. }
  713. // History returns a sequence of LFSStoreCreateObjectFuncCall objects
  714. // describing the invocations of this function.
  715. func (f *LFSStoreCreateObjectFunc) History() []LFSStoreCreateObjectFuncCall {
  716. f.mutex.Lock()
  717. history := make([]LFSStoreCreateObjectFuncCall, len(f.history))
  718. copy(history, f.history)
  719. f.mutex.Unlock()
  720. return history
  721. }
  722. // LFSStoreCreateObjectFuncCall is an object that describes an invocation of
  723. // method CreateObject on an instance of MockLFSStore.
  724. type LFSStoreCreateObjectFuncCall struct {
  725. // Arg0 is the value of the 1st argument passed to this method
  726. // invocation.
  727. Arg0 context.Context
  728. // Arg1 is the value of the 2nd argument passed to this method
  729. // invocation.
  730. Arg1 int64
  731. // Arg2 is the value of the 3rd argument passed to this method
  732. // invocation.
  733. Arg2 lfsutil.OID
  734. // Arg3 is the value of the 4th argument passed to this method
  735. // invocation.
  736. Arg3 int64
  737. // Arg4 is the value of the 5th argument passed to this method
  738. // invocation.
  739. Arg4 lfsutil.Storage
  740. // Result0 is the value of the 1st result returned from this method
  741. // invocation.
  742. Result0 error
  743. }
  744. // Args returns an interface slice containing the arguments of this
  745. // invocation.
  746. func (c LFSStoreCreateObjectFuncCall) Args() []interface{} {
  747. return []interface{}{c.Arg0, c.Arg1, c.Arg2, c.Arg3, c.Arg4}
  748. }
  749. // Results returns an interface slice containing the results of this
  750. // invocation.
  751. func (c LFSStoreCreateObjectFuncCall) Results() []interface{} {
  752. return []interface{}{c.Result0}
  753. }
  754. // LFSStoreGetObjectByOIDFunc describes the behavior when the GetObjectByOID
  755. // method of the parent MockLFSStore instance is invoked.
  756. type LFSStoreGetObjectByOIDFunc struct {
  757. defaultHook func(context.Context, int64, lfsutil.OID) (*db.LFSObject, error)
  758. hooks []func(context.Context, int64, lfsutil.OID) (*db.LFSObject, error)
  759. history []LFSStoreGetObjectByOIDFuncCall
  760. mutex sync.Mutex
  761. }
  762. // GetObjectByOID delegates to the next hook function in the queue and
  763. // stores the parameter and result values of this invocation.
  764. func (m *MockLFSStore) GetObjectByOID(v0 context.Context, v1 int64, v2 lfsutil.OID) (*db.LFSObject, error) {
  765. r0, r1 := m.GetObjectByOIDFunc.nextHook()(v0, v1, v2)
  766. m.GetObjectByOIDFunc.appendCall(LFSStoreGetObjectByOIDFuncCall{v0, v1, v2, r0, r1})
  767. return r0, r1
  768. }
  769. // SetDefaultHook sets function that is called when the GetObjectByOID
  770. // method of the parent MockLFSStore instance is invoked and the hook queue
  771. // is empty.
  772. func (f *LFSStoreGetObjectByOIDFunc) SetDefaultHook(hook func(context.Context, int64, lfsutil.OID) (*db.LFSObject, error)) {
  773. f.defaultHook = hook
  774. }
  775. // PushHook adds a function to the end of hook queue. Each invocation of the
  776. // GetObjectByOID method of the parent MockLFSStore instance invokes the
  777. // hook at the front of the queue and discards it. After the queue is empty,
  778. // the default hook function is invoked for any future action.
  779. func (f *LFSStoreGetObjectByOIDFunc) PushHook(hook func(context.Context, int64, lfsutil.OID) (*db.LFSObject, error)) {
  780. f.mutex.Lock()
  781. f.hooks = append(f.hooks, hook)
  782. f.mutex.Unlock()
  783. }
  784. // SetDefaultReturn calls SetDefaultHook with a function that returns the
  785. // given values.
  786. func (f *LFSStoreGetObjectByOIDFunc) SetDefaultReturn(r0 *db.LFSObject, r1 error) {
  787. f.SetDefaultHook(func(context.Context, int64, lfsutil.OID) (*db.LFSObject, error) {
  788. return r0, r1
  789. })
  790. }
  791. // PushReturn calls PushHook with a function that returns the given values.
  792. func (f *LFSStoreGetObjectByOIDFunc) PushReturn(r0 *db.LFSObject, r1 error) {
  793. f.PushHook(func(context.Context, int64, lfsutil.OID) (*db.LFSObject, error) {
  794. return r0, r1
  795. })
  796. }
  797. func (f *LFSStoreGetObjectByOIDFunc) nextHook() func(context.Context, int64, lfsutil.OID) (*db.LFSObject, error) {
  798. f.mutex.Lock()
  799. defer f.mutex.Unlock()
  800. if len(f.hooks) == 0 {
  801. return f.defaultHook
  802. }
  803. hook := f.hooks[0]
  804. f.hooks = f.hooks[1:]
  805. return hook
  806. }
  807. func (f *LFSStoreGetObjectByOIDFunc) appendCall(r0 LFSStoreGetObjectByOIDFuncCall) {
  808. f.mutex.Lock()
  809. f.history = append(f.history, r0)
  810. f.mutex.Unlock()
  811. }
  812. // History returns a sequence of LFSStoreGetObjectByOIDFuncCall objects
  813. // describing the invocations of this function.
  814. func (f *LFSStoreGetObjectByOIDFunc) History() []LFSStoreGetObjectByOIDFuncCall {
  815. f.mutex.Lock()
  816. history := make([]LFSStoreGetObjectByOIDFuncCall, len(f.history))
  817. copy(history, f.history)
  818. f.mutex.Unlock()
  819. return history
  820. }
  821. // LFSStoreGetObjectByOIDFuncCall is an object that describes an invocation
  822. // of method GetObjectByOID on an instance of MockLFSStore.
  823. type LFSStoreGetObjectByOIDFuncCall struct {
  824. // Arg0 is the value of the 1st argument passed to this method
  825. // invocation.
  826. Arg0 context.Context
  827. // Arg1 is the value of the 2nd argument passed to this method
  828. // invocation.
  829. Arg1 int64
  830. // Arg2 is the value of the 3rd argument passed to this method
  831. // invocation.
  832. Arg2 lfsutil.OID
  833. // Result0 is the value of the 1st result returned from this method
  834. // invocation.
  835. Result0 *db.LFSObject
  836. // Result1 is the value of the 2nd result returned from this method
  837. // invocation.
  838. Result1 error
  839. }
  840. // Args returns an interface slice containing the arguments of this
  841. // invocation.
  842. func (c LFSStoreGetObjectByOIDFuncCall) Args() []interface{} {
  843. return []interface{}{c.Arg0, c.Arg1, c.Arg2}
  844. }
  845. // Results returns an interface slice containing the results of this
  846. // invocation.
  847. func (c LFSStoreGetObjectByOIDFuncCall) Results() []interface{} {
  848. return []interface{}{c.Result0, c.Result1}
  849. }
  850. // LFSStoreGetObjectsByOIDsFunc describes the behavior when the
  851. // GetObjectsByOIDs method of the parent MockLFSStore instance is invoked.
  852. type LFSStoreGetObjectsByOIDsFunc struct {
  853. defaultHook func(context.Context, int64, ...lfsutil.OID) ([]*db.LFSObject, error)
  854. hooks []func(context.Context, int64, ...lfsutil.OID) ([]*db.LFSObject, error)
  855. history []LFSStoreGetObjectsByOIDsFuncCall
  856. mutex sync.Mutex
  857. }
  858. // GetObjectsByOIDs delegates to the next hook function in the queue and
  859. // stores the parameter and result values of this invocation.
  860. func (m *MockLFSStore) GetObjectsByOIDs(v0 context.Context, v1 int64, v2 ...lfsutil.OID) ([]*db.LFSObject, error) {
  861. r0, r1 := m.GetObjectsByOIDsFunc.nextHook()(v0, v1, v2...)
  862. m.GetObjectsByOIDsFunc.appendCall(LFSStoreGetObjectsByOIDsFuncCall{v0, v1, v2, r0, r1})
  863. return r0, r1
  864. }
  865. // SetDefaultHook sets function that is called when the GetObjectsByOIDs
  866. // method of the parent MockLFSStore instance is invoked and the hook queue
  867. // is empty.
  868. func (f *LFSStoreGetObjectsByOIDsFunc) SetDefaultHook(hook func(context.Context, int64, ...lfsutil.OID) ([]*db.LFSObject, error)) {
  869. f.defaultHook = hook
  870. }
  871. // PushHook adds a function to the end of hook queue. Each invocation of the
  872. // GetObjectsByOIDs method of the parent MockLFSStore instance invokes the
  873. // hook at the front of the queue and discards it. After the queue is empty,
  874. // the default hook function is invoked for any future action.
  875. func (f *LFSStoreGetObjectsByOIDsFunc) PushHook(hook func(context.Context, int64, ...lfsutil.OID) ([]*db.LFSObject, error)) {
  876. f.mutex.Lock()
  877. f.hooks = append(f.hooks, hook)
  878. f.mutex.Unlock()
  879. }
  880. // SetDefaultReturn calls SetDefaultHook with a function that returns the
  881. // given values.
  882. func (f *LFSStoreGetObjectsByOIDsFunc) SetDefaultReturn(r0 []*db.LFSObject, r1 error) {
  883. f.SetDefaultHook(func(context.Context, int64, ...lfsutil.OID) ([]*db.LFSObject, error) {
  884. return r0, r1
  885. })
  886. }
  887. // PushReturn calls PushHook with a function that returns the given values.
  888. func (f *LFSStoreGetObjectsByOIDsFunc) PushReturn(r0 []*db.LFSObject, r1 error) {
  889. f.PushHook(func(context.Context, int64, ...lfsutil.OID) ([]*db.LFSObject, error) {
  890. return r0, r1
  891. })
  892. }
  893. func (f *LFSStoreGetObjectsByOIDsFunc) nextHook() func(context.Context, int64, ...lfsutil.OID) ([]*db.LFSObject, error) {
  894. f.mutex.Lock()
  895. defer f.mutex.Unlock()
  896. if len(f.hooks) == 0 {
  897. return f.defaultHook
  898. }
  899. hook := f.hooks[0]
  900. f.hooks = f.hooks[1:]
  901. return hook
  902. }
  903. func (f *LFSStoreGetObjectsByOIDsFunc) appendCall(r0 LFSStoreGetObjectsByOIDsFuncCall) {
  904. f.mutex.Lock()
  905. f.history = append(f.history, r0)
  906. f.mutex.Unlock()
  907. }
  908. // History returns a sequence of LFSStoreGetObjectsByOIDsFuncCall objects
  909. // describing the invocations of this function.
  910. func (f *LFSStoreGetObjectsByOIDsFunc) History() []LFSStoreGetObjectsByOIDsFuncCall {
  911. f.mutex.Lock()
  912. history := make([]LFSStoreGetObjectsByOIDsFuncCall, len(f.history))
  913. copy(history, f.history)
  914. f.mutex.Unlock()
  915. return history
  916. }
  917. // LFSStoreGetObjectsByOIDsFuncCall is an object that describes an
  918. // invocation of method GetObjectsByOIDs on an instance of MockLFSStore.
  919. type LFSStoreGetObjectsByOIDsFuncCall struct {
  920. // Arg0 is the value of the 1st argument passed to this method
  921. // invocation.
  922. Arg0 context.Context
  923. // Arg1 is the value of the 2nd argument passed to this method
  924. // invocation.
  925. Arg1 int64
  926. // Arg2 is a slice containing the values of the variadic arguments
  927. // passed to this method invocation.
  928. Arg2 []lfsutil.OID
  929. // Result0 is the value of the 1st result returned from this method
  930. // invocation.
  931. Result0 []*db.LFSObject
  932. // Result1 is the value of the 2nd result returned from this method
  933. // invocation.
  934. Result1 error
  935. }
  936. // Args returns an interface slice containing the arguments of this
  937. // invocation. The variadic slice argument is flattened in this array such
  938. // that one positional argument and three variadic arguments would result in
  939. // a slice of four, not two.
  940. func (c LFSStoreGetObjectsByOIDsFuncCall) Args() []interface{} {
  941. trailing := []interface{}{}
  942. for _, val := range c.Arg2 {
  943. trailing = append(trailing, val)
  944. }
  945. return append([]interface{}{c.Arg0, c.Arg1}, trailing...)
  946. }
  947. // Results returns an interface slice containing the results of this
  948. // invocation.
  949. func (c LFSStoreGetObjectsByOIDsFuncCall) Results() []interface{} {
  950. return []interface{}{c.Result0, c.Result1}
  951. }
  952. // MockPermsStore is a mock implementation of the PermsStore interface (from
  953. // the package gogs.io/gogs/internal/db) used for unit testing.
  954. type MockPermsStore struct {
  955. // AccessModeFunc is an instance of a mock function object controlling
  956. // the behavior of the method AccessMode.
  957. AccessModeFunc *PermsStoreAccessModeFunc
  958. // AuthorizeFunc is an instance of a mock function object controlling
  959. // the behavior of the method Authorize.
  960. AuthorizeFunc *PermsStoreAuthorizeFunc
  961. // SetRepoPermsFunc is an instance of a mock function object controlling
  962. // the behavior of the method SetRepoPerms.
  963. SetRepoPermsFunc *PermsStoreSetRepoPermsFunc
  964. }
  965. // NewMockPermsStore creates a new mock of the PermsStore interface. All
  966. // methods return zero values for all results, unless overwritten.
  967. func NewMockPermsStore() *MockPermsStore {
  968. return &MockPermsStore{
  969. AccessModeFunc: &PermsStoreAccessModeFunc{
  970. defaultHook: func(context.Context, int64, int64, db.AccessModeOptions) (r0 db.AccessMode) {
  971. return
  972. },
  973. },
  974. AuthorizeFunc: &PermsStoreAuthorizeFunc{
  975. defaultHook: func(context.Context, int64, int64, db.AccessMode, db.AccessModeOptions) (r0 bool) {
  976. return
  977. },
  978. },
  979. SetRepoPermsFunc: &PermsStoreSetRepoPermsFunc{
  980. defaultHook: func(context.Context, int64, map[int64]db.AccessMode) (r0 error) {
  981. return
  982. },
  983. },
  984. }
  985. }
  986. // NewStrictMockPermsStore creates a new mock of the PermsStore interface.
  987. // All methods panic on invocation, unless overwritten.
  988. func NewStrictMockPermsStore() *MockPermsStore {
  989. return &MockPermsStore{
  990. AccessModeFunc: &PermsStoreAccessModeFunc{
  991. defaultHook: func(context.Context, int64, int64, db.AccessModeOptions) db.AccessMode {
  992. panic("unexpected invocation of MockPermsStore.AccessMode")
  993. },
  994. },
  995. AuthorizeFunc: &PermsStoreAuthorizeFunc{
  996. defaultHook: func(context.Context, int64, int64, db.AccessMode, db.AccessModeOptions) bool {
  997. panic("unexpected invocation of MockPermsStore.Authorize")
  998. },
  999. },
  1000. SetRepoPermsFunc: &PermsStoreSetRepoPermsFunc{
  1001. defaultHook: func(context.Context, int64, map[int64]db.AccessMode) error {
  1002. panic("unexpected invocation of MockPermsStore.SetRepoPerms")
  1003. },
  1004. },
  1005. }
  1006. }
  1007. // NewMockPermsStoreFrom creates a new mock of the MockPermsStore interface.
  1008. // All methods delegate to the given implementation, unless overwritten.
  1009. func NewMockPermsStoreFrom(i db.PermsStore) *MockPermsStore {
  1010. return &MockPermsStore{
  1011. AccessModeFunc: &PermsStoreAccessModeFunc{
  1012. defaultHook: i.AccessMode,
  1013. },
  1014. AuthorizeFunc: &PermsStoreAuthorizeFunc{
  1015. defaultHook: i.Authorize,
  1016. },
  1017. SetRepoPermsFunc: &PermsStoreSetRepoPermsFunc{
  1018. defaultHook: i.SetRepoPerms,
  1019. },
  1020. }
  1021. }
  1022. // PermsStoreAccessModeFunc describes the behavior when the AccessMode
  1023. // method of the parent MockPermsStore instance is invoked.
  1024. type PermsStoreAccessModeFunc struct {
  1025. defaultHook func(context.Context, int64, int64, db.AccessModeOptions) db.AccessMode
  1026. hooks []func(context.Context, int64, int64, db.AccessModeOptions) db.AccessMode
  1027. history []PermsStoreAccessModeFuncCall
  1028. mutex sync.Mutex
  1029. }
  1030. // AccessMode delegates to the next hook function in the queue and stores
  1031. // the parameter and result values of this invocation.
  1032. func (m *MockPermsStore) AccessMode(v0 context.Context, v1 int64, v2 int64, v3 db.AccessModeOptions) db.AccessMode {
  1033. r0 := m.AccessModeFunc.nextHook()(v0, v1, v2, v3)
  1034. m.AccessModeFunc.appendCall(PermsStoreAccessModeFuncCall{v0, v1, v2, v3, r0})
  1035. return r0
  1036. }
  1037. // SetDefaultHook sets function that is called when the AccessMode method of
  1038. // the parent MockPermsStore instance is invoked and the hook queue is
  1039. // empty.
  1040. func (f *PermsStoreAccessModeFunc) SetDefaultHook(hook func(context.Context, int64, int64, db.AccessModeOptions) db.AccessMode) {
  1041. f.defaultHook = hook
  1042. }
  1043. // PushHook adds a function to the end of hook queue. Each invocation of the
  1044. // AccessMode method of the parent MockPermsStore instance invokes the hook
  1045. // at the front of the queue and discards it. After the queue is empty, the
  1046. // default hook function is invoked for any future action.
  1047. func (f *PermsStoreAccessModeFunc) PushHook(hook func(context.Context, int64, int64, db.AccessModeOptions) db.AccessMode) {
  1048. f.mutex.Lock()
  1049. f.hooks = append(f.hooks, hook)
  1050. f.mutex.Unlock()
  1051. }
  1052. // SetDefaultReturn calls SetDefaultHook with a function that returns the
  1053. // given values.
  1054. func (f *PermsStoreAccessModeFunc) SetDefaultReturn(r0 db.AccessMode) {
  1055. f.SetDefaultHook(func(context.Context, int64, int64, db.AccessModeOptions) db.AccessMode {
  1056. return r0
  1057. })
  1058. }
  1059. // PushReturn calls PushHook with a function that returns the given values.
  1060. func (f *PermsStoreAccessModeFunc) PushReturn(r0 db.AccessMode) {
  1061. f.PushHook(func(context.Context, int64, int64, db.AccessModeOptions) db.AccessMode {
  1062. return r0
  1063. })
  1064. }
  1065. func (f *PermsStoreAccessModeFunc) nextHook() func(context.Context, int64, int64, db.AccessModeOptions) db.AccessMode {
  1066. f.mutex.Lock()
  1067. defer f.mutex.Unlock()
  1068. if len(f.hooks) == 0 {
  1069. return f.defaultHook
  1070. }
  1071. hook := f.hooks[0]
  1072. f.hooks = f.hooks[1:]
  1073. return hook
  1074. }
  1075. func (f *PermsStoreAccessModeFunc) appendCall(r0 PermsStoreAccessModeFuncCall) {
  1076. f.mutex.Lock()
  1077. f.history = append(f.history, r0)
  1078. f.mutex.Unlock()
  1079. }
  1080. // History returns a sequence of PermsStoreAccessModeFuncCall objects
  1081. // describing the invocations of this function.
  1082. func (f *PermsStoreAccessModeFunc) History() []PermsStoreAccessModeFuncCall {
  1083. f.mutex.Lock()
  1084. history := make([]PermsStoreAccessModeFuncCall, len(f.history))
  1085. copy(history, f.history)
  1086. f.mutex.Unlock()
  1087. return history
  1088. }
  1089. // PermsStoreAccessModeFuncCall is an object that describes an invocation of
  1090. // method AccessMode on an instance of MockPermsStore.
  1091. type PermsStoreAccessModeFuncCall struct {
  1092. // Arg0 is the value of the 1st argument passed to this method
  1093. // invocation.
  1094. Arg0 context.Context
  1095. // Arg1 is the value of the 2nd argument passed to this method
  1096. // invocation.
  1097. Arg1 int64
  1098. // Arg2 is the value of the 3rd argument passed to this method
  1099. // invocation.
  1100. Arg2 int64
  1101. // Arg3 is the value of the 4th argument passed to this method
  1102. // invocation.
  1103. Arg3 db.AccessModeOptions
  1104. // Result0 is the value of the 1st result returned from this method
  1105. // invocation.
  1106. Result0 db.AccessMode
  1107. }
  1108. // Args returns an interface slice containing the arguments of this
  1109. // invocation.
  1110. func (c PermsStoreAccessModeFuncCall) Args() []interface{} {
  1111. return []interface{}{c.Arg0, c.Arg1, c.Arg2, c.Arg3}
  1112. }
  1113. // Results returns an interface slice containing the results of this
  1114. // invocation.
  1115. func (c PermsStoreAccessModeFuncCall) Results() []interface{} {
  1116. return []interface{}{c.Result0}
  1117. }
  1118. // PermsStoreAuthorizeFunc describes the behavior when the Authorize method
  1119. // of the parent MockPermsStore instance is invoked.
  1120. type PermsStoreAuthorizeFunc struct {
  1121. defaultHook func(context.Context, int64, int64, db.AccessMode, db.AccessModeOptions) bool
  1122. hooks []func(context.Context, int64, int64, db.AccessMode, db.AccessModeOptions) bool
  1123. history []PermsStoreAuthorizeFuncCall
  1124. mutex sync.Mutex
  1125. }
  1126. // Authorize delegates to the next hook function in the queue and stores the
  1127. // parameter and result values of this invocation.
  1128. func (m *MockPermsStore) Authorize(v0 context.Context, v1 int64, v2 int64, v3 db.AccessMode, v4 db.AccessModeOptions) bool {
  1129. r0 := m.AuthorizeFunc.nextHook()(v0, v1, v2, v3, v4)
  1130. m.AuthorizeFunc.appendCall(PermsStoreAuthorizeFuncCall{v0, v1, v2, v3, v4, r0})
  1131. return r0
  1132. }
  1133. // SetDefaultHook sets function that is called when the Authorize method of
  1134. // the parent MockPermsStore instance is invoked and the hook queue is
  1135. // empty.
  1136. func (f *PermsStoreAuthorizeFunc) SetDefaultHook(hook func(context.Context, int64, int64, db.AccessMode, db.AccessModeOptions) bool) {
  1137. f.defaultHook = hook
  1138. }
  1139. // PushHook adds a function to the end of hook queue. Each invocation of the
  1140. // Authorize method of the parent MockPermsStore instance invokes the hook
  1141. // at the front of the queue and discards it. After the queue is empty, the
  1142. // default hook function is invoked for any future action.
  1143. func (f *PermsStoreAuthorizeFunc) PushHook(hook func(context.Context, int64, int64, db.AccessMode, db.AccessModeOptions) bool) {
  1144. f.mutex.Lock()
  1145. f.hooks = append(f.hooks, hook)
  1146. f.mutex.Unlock()
  1147. }
  1148. // SetDefaultReturn calls SetDefaultHook with a function that returns the
  1149. // given values.
  1150. func (f *PermsStoreAuthorizeFunc) SetDefaultReturn(r0 bool) {
  1151. f.SetDefaultHook(func(context.Context, int64, int64, db.AccessMode, db.AccessModeOptions) bool {
  1152. return r0
  1153. })
  1154. }
  1155. // PushReturn calls PushHook with a function that returns the given values.
  1156. func (f *PermsStoreAuthorizeFunc) PushReturn(r0 bool) {
  1157. f.PushHook(func(context.Context, int64, int64, db.AccessMode, db.AccessModeOptions) bool {
  1158. return r0
  1159. })
  1160. }
  1161. func (f *PermsStoreAuthorizeFunc) nextHook() func(context.Context, int64, int64, db.AccessMode, db.AccessModeOptions) bool {
  1162. f.mutex.Lock()
  1163. defer f.mutex.Unlock()
  1164. if len(f.hooks) == 0 {
  1165. return f.defaultHook
  1166. }
  1167. hook := f.hooks[0]
  1168. f.hooks = f.hooks[1:]
  1169. return hook
  1170. }
  1171. func (f *PermsStoreAuthorizeFunc) appendCall(r0 PermsStoreAuthorizeFuncCall) {
  1172. f.mutex.Lock()
  1173. f.history = append(f.history, r0)
  1174. f.mutex.Unlock()
  1175. }
  1176. // History returns a sequence of PermsStoreAuthorizeFuncCall objects
  1177. // describing the invocations of this function.
  1178. func (f *PermsStoreAuthorizeFunc) History() []PermsStoreAuthorizeFuncCall {
  1179. f.mutex.Lock()
  1180. history := make([]PermsStoreAuthorizeFuncCall, len(f.history))
  1181. copy(history, f.history)
  1182. f.mutex.Unlock()
  1183. return history
  1184. }
  1185. // PermsStoreAuthorizeFuncCall is an object that describes an invocation of
  1186. // method Authorize on an instance of MockPermsStore.
  1187. type PermsStoreAuthorizeFuncCall struct {
  1188. // Arg0 is the value of the 1st argument passed to this method
  1189. // invocation.
  1190. Arg0 context.Context
  1191. // Arg1 is the value of the 2nd argument passed to this method
  1192. // invocation.
  1193. Arg1 int64
  1194. // Arg2 is the value of the 3rd argument passed to this method
  1195. // invocation.
  1196. Arg2 int64
  1197. // Arg3 is the value of the 4th argument passed to this method
  1198. // invocation.
  1199. Arg3 db.AccessMode
  1200. // Arg4 is the value of the 5th argument passed to this method
  1201. // invocation.
  1202. Arg4 db.AccessModeOptions
  1203. // Result0 is the value of the 1st result returned from this method
  1204. // invocation.
  1205. Result0 bool
  1206. }
  1207. // Args returns an interface slice containing the arguments of this
  1208. // invocation.
  1209. func (c PermsStoreAuthorizeFuncCall) Args() []interface{} {
  1210. return []interface{}{c.Arg0, c.Arg1, c.Arg2, c.Arg3, c.Arg4}
  1211. }
  1212. // Results returns an interface slice containing the results of this
  1213. // invocation.
  1214. func (c PermsStoreAuthorizeFuncCall) Results() []interface{} {
  1215. return []interface{}{c.Result0}
  1216. }
  1217. // PermsStoreSetRepoPermsFunc describes the behavior when the SetRepoPerms
  1218. // method of the parent MockPermsStore instance is invoked.
  1219. type PermsStoreSetRepoPermsFunc struct {
  1220. defaultHook func(context.Context, int64, map[int64]db.AccessMode) error
  1221. hooks []func(context.Context, int64, map[int64]db.AccessMode) error
  1222. history []PermsStoreSetRepoPermsFuncCall
  1223. mutex sync.Mutex
  1224. }
  1225. // SetRepoPerms delegates to the next hook function in the queue and stores
  1226. // the parameter and result values of this invocation.
  1227. func (m *MockPermsStore) SetRepoPerms(v0 context.Context, v1 int64, v2 map[int64]db.AccessMode) error {
  1228. r0 := m.SetRepoPermsFunc.nextHook()(v0, v1, v2)
  1229. m.SetRepoPermsFunc.appendCall(PermsStoreSetRepoPermsFuncCall{v0, v1, v2, r0})
  1230. return r0
  1231. }
  1232. // SetDefaultHook sets function that is called when the SetRepoPerms method
  1233. // of the parent MockPermsStore instance is invoked and the hook queue is
  1234. // empty.
  1235. func (f *PermsStoreSetRepoPermsFunc) SetDefaultHook(hook func(context.Context, int64, map[int64]db.AccessMode) error) {
  1236. f.defaultHook = hook
  1237. }
  1238. // PushHook adds a function to the end of hook queue. Each invocation of the
  1239. // SetRepoPerms method of the parent MockPermsStore instance invokes the
  1240. // hook at the front of the queue and discards it. After the queue is empty,
  1241. // the default hook function is invoked for any future action.
  1242. func (f *PermsStoreSetRepoPermsFunc) PushHook(hook func(context.Context, int64, map[int64]db.AccessMode) error) {
  1243. f.mutex.Lock()
  1244. f.hooks = append(f.hooks, hook)
  1245. f.mutex.Unlock()
  1246. }
  1247. // SetDefaultReturn calls SetDefaultHook with a function that returns the
  1248. // given values.
  1249. func (f *PermsStoreSetRepoPermsFunc) SetDefaultReturn(r0 error) {
  1250. f.SetDefaultHook(func(context.Context, int64, map[int64]db.AccessMode) error {
  1251. return r0
  1252. })
  1253. }
  1254. // PushReturn calls PushHook with a function that returns the given values.
  1255. func (f *PermsStoreSetRepoPermsFunc) PushReturn(r0 error) {
  1256. f.PushHook(func(context.Context, int64, map[int64]db.AccessMode) error {
  1257. return r0
  1258. })
  1259. }
  1260. func (f *PermsStoreSetRepoPermsFunc) nextHook() func(context.Context, int64, map[int64]db.AccessMode) error {
  1261. f.mutex.Lock()
  1262. defer f.mutex.Unlock()
  1263. if len(f.hooks) == 0 {
  1264. return f.defaultHook
  1265. }
  1266. hook := f.hooks[0]
  1267. f.hooks = f.hooks[1:]
  1268. return hook
  1269. }
  1270. func (f *PermsStoreSetRepoPermsFunc) appendCall(r0 PermsStoreSetRepoPermsFuncCall) {
  1271. f.mutex.Lock()
  1272. f.history = append(f.history, r0)
  1273. f.mutex.Unlock()
  1274. }
  1275. // History returns a sequence of PermsStoreSetRepoPermsFuncCall objects
  1276. // describing the invocations of this function.
  1277. func (f *PermsStoreSetRepoPermsFunc) History() []PermsStoreSetRepoPermsFuncCall {
  1278. f.mutex.Lock()
  1279. history := make([]PermsStoreSetRepoPermsFuncCall, len(f.history))
  1280. copy(history, f.history)
  1281. f.mutex.Unlock()
  1282. return history
  1283. }
  1284. // PermsStoreSetRepoPermsFuncCall is an object that describes an invocation
  1285. // of method SetRepoPerms on an instance of MockPermsStore.
  1286. type PermsStoreSetRepoPermsFuncCall struct {
  1287. // Arg0 is the value of the 1st argument passed to this method
  1288. // invocation.
  1289. Arg0 context.Context
  1290. // Arg1 is the value of the 2nd argument passed to this method
  1291. // invocation.
  1292. Arg1 int64
  1293. // Arg2 is the value of the 3rd argument passed to this method
  1294. // invocation.
  1295. Arg2 map[int64]db.AccessMode
  1296. // Result0 is the value of the 1st result returned from this method
  1297. // invocation.
  1298. Result0 error
  1299. }
  1300. // Args returns an interface slice containing the arguments of this
  1301. // invocation.
  1302. func (c PermsStoreSetRepoPermsFuncCall) Args() []interface{} {
  1303. return []interface{}{c.Arg0, c.Arg1, c.Arg2}
  1304. }
  1305. // Results returns an interface slice containing the results of this
  1306. // invocation.
  1307. func (c PermsStoreSetRepoPermsFuncCall) Results() []interface{} {
  1308. return []interface{}{c.Result0}
  1309. }
  1310. // MockReposStore is a mock implementation of the ReposStore interface (from
  1311. // the package gogs.io/gogs/internal/db) used for unit testing.
  1312. type MockReposStore struct {
  1313. // CreateFunc is an instance of a mock function object controlling the
  1314. // behavior of the method Create.
  1315. CreateFunc *ReposStoreCreateFunc
  1316. // GetByNameFunc is an instance of a mock function object controlling
  1317. // the behavior of the method GetByName.
  1318. GetByNameFunc *ReposStoreGetByNameFunc
  1319. // TouchFunc is an instance of a mock function object controlling the
  1320. // behavior of the method Touch.
  1321. TouchFunc *ReposStoreTouchFunc
  1322. }
  1323. // NewMockReposStore creates a new mock of the ReposStore interface. All
  1324. // methods return zero values for all results, unless overwritten.
  1325. func NewMockReposStore() *MockReposStore {
  1326. return &MockReposStore{
  1327. CreateFunc: &ReposStoreCreateFunc{
  1328. defaultHook: func(context.Context, int64, db.CreateRepoOptions) (r0 *db.Repository, r1 error) {
  1329. return
  1330. },
  1331. },
  1332. GetByNameFunc: &ReposStoreGetByNameFunc{
  1333. defaultHook: func(context.Context, int64, string) (r0 *db.Repository, r1 error) {
  1334. return
  1335. },
  1336. },
  1337. TouchFunc: &ReposStoreTouchFunc{
  1338. defaultHook: func(context.Context, int64) (r0 error) {
  1339. return
  1340. },
  1341. },
  1342. }
  1343. }
  1344. // NewStrictMockReposStore creates a new mock of the ReposStore interface.
  1345. // All methods panic on invocation, unless overwritten.
  1346. func NewStrictMockReposStore() *MockReposStore {
  1347. return &MockReposStore{
  1348. CreateFunc: &ReposStoreCreateFunc{
  1349. defaultHook: func(context.Context, int64, db.CreateRepoOptions) (*db.Repository, error) {
  1350. panic("unexpected invocation of MockReposStore.Create")
  1351. },
  1352. },
  1353. GetByNameFunc: &ReposStoreGetByNameFunc{
  1354. defaultHook: func(context.Context, int64, string) (*db.Repository, error) {
  1355. panic("unexpected invocation of MockReposStore.GetByName")
  1356. },
  1357. },
  1358. TouchFunc: &ReposStoreTouchFunc{
  1359. defaultHook: func(context.Context, int64) error {
  1360. panic("unexpected invocation of MockReposStore.Touch")
  1361. },
  1362. },
  1363. }
  1364. }
  1365. // NewMockReposStoreFrom creates a new mock of the MockReposStore interface.
  1366. // All methods delegate to the given implementation, unless overwritten.
  1367. func NewMockReposStoreFrom(i db.ReposStore) *MockReposStore {
  1368. return &MockReposStore{
  1369. CreateFunc: &ReposStoreCreateFunc{
  1370. defaultHook: i.Create,
  1371. },
  1372. GetByNameFunc: &ReposStoreGetByNameFunc{
  1373. defaultHook: i.GetByName,
  1374. },
  1375. TouchFunc: &ReposStoreTouchFunc{
  1376. defaultHook: i.Touch,
  1377. },
  1378. }
  1379. }
  1380. // ReposStoreCreateFunc describes the behavior when the Create method of the
  1381. // parent MockReposStore instance is invoked.
  1382. type ReposStoreCreateFunc struct {
  1383. defaultHook func(context.Context, int64, db.CreateRepoOptions) (*db.Repository, error)
  1384. hooks []func(context.Context, int64, db.CreateRepoOptions) (*db.Repository, error)
  1385. history []ReposStoreCreateFuncCall
  1386. mutex sync.Mutex
  1387. }
  1388. // Create delegates to the next hook function in the queue and stores the
  1389. // parameter and result values of this invocation.
  1390. func (m *MockReposStore) Create(v0 context.Context, v1 int64, v2 db.CreateRepoOptions) (*db.Repository, error) {
  1391. r0, r1 := m.CreateFunc.nextHook()(v0, v1, v2)
  1392. m.CreateFunc.appendCall(ReposStoreCreateFuncCall{v0, v1, v2, r0, r1})
  1393. return r0, r1
  1394. }
  1395. // SetDefaultHook sets function that is called when the Create method of the
  1396. // parent MockReposStore instance is invoked and the hook queue is empty.
  1397. func (f *ReposStoreCreateFunc) SetDefaultHook(hook func(context.Context, int64, db.CreateRepoOptions) (*db.Repository, error)) {
  1398. f.defaultHook = hook
  1399. }
  1400. // PushHook adds a function to the end of hook queue. Each invocation of the
  1401. // Create method of the parent MockReposStore instance invokes the hook at
  1402. // the front of the queue and discards it. After the queue is empty, the
  1403. // default hook function is invoked for any future action.
  1404. func (f *ReposStoreCreateFunc) PushHook(hook func(context.Context, int64, db.CreateRepoOptions) (*db.Repository, error)) {
  1405. f.mutex.Lock()
  1406. f.hooks = append(f.hooks, hook)
  1407. f.mutex.Unlock()
  1408. }
  1409. // SetDefaultReturn calls SetDefaultHook with a function that returns the
  1410. // given values.
  1411. func (f *ReposStoreCreateFunc) SetDefaultReturn(r0 *db.Repository, r1 error) {
  1412. f.SetDefaultHook(func(context.Context, int64, db.CreateRepoOptions) (*db.Repository, error) {
  1413. return r0, r1
  1414. })
  1415. }
  1416. // PushReturn calls PushHook with a function that returns the given values.
  1417. func (f *ReposStoreCreateFunc) PushReturn(r0 *db.Repository, r1 error) {
  1418. f.PushHook(func(context.Context, int64, db.CreateRepoOptions) (*db.Repository, error) {
  1419. return r0, r1
  1420. })
  1421. }
  1422. func (f *ReposStoreCreateFunc) nextHook() func(context.Context, int64, db.CreateRepoOptions) (*db.Repository, error) {
  1423. f.mutex.Lock()
  1424. defer f.mutex.Unlock()
  1425. if len(f.hooks) == 0 {
  1426. return f.defaultHook
  1427. }
  1428. hook := f.hooks[0]
  1429. f.hooks = f.hooks[1:]
  1430. return hook
  1431. }
  1432. func (f *ReposStoreCreateFunc) appendCall(r0 ReposStoreCreateFuncCall) {
  1433. f.mutex.Lock()
  1434. f.history = append(f.history, r0)
  1435. f.mutex.Unlock()
  1436. }
  1437. // History returns a sequence of ReposStoreCreateFuncCall objects describing
  1438. // the invocations of this function.
  1439. func (f *ReposStoreCreateFunc) History() []ReposStoreCreateFuncCall {
  1440. f.mutex.Lock()
  1441. history := make([]ReposStoreCreateFuncCall, len(f.history))
  1442. copy(history, f.history)
  1443. f.mutex.Unlock()
  1444. return history
  1445. }
  1446. // ReposStoreCreateFuncCall is an object that describes an invocation of
  1447. // method Create on an instance of MockReposStore.
  1448. type ReposStoreCreateFuncCall struct {
  1449. // Arg0 is the value of the 1st argument passed to this method
  1450. // invocation.
  1451. Arg0 context.Context
  1452. // Arg1 is the value of the 2nd argument passed to this method
  1453. // invocation.
  1454. Arg1 int64
  1455. // Arg2 is the value of the 3rd argument passed to this method
  1456. // invocation.
  1457. Arg2 db.CreateRepoOptions
  1458. // Result0 is the value of the 1st result returned from this method
  1459. // invocation.
  1460. Result0 *db.Repository
  1461. // Result1 is the value of the 2nd result returned from this method
  1462. // invocation.
  1463. Result1 error
  1464. }
  1465. // Args returns an interface slice containing the arguments of this
  1466. // invocation.
  1467. func (c ReposStoreCreateFuncCall) Args() []interface{} {
  1468. return []interface{}{c.Arg0, c.Arg1, c.Arg2}
  1469. }
  1470. // Results returns an interface slice containing the results of this
  1471. // invocation.
  1472. func (c ReposStoreCreateFuncCall) Results() []interface{} {
  1473. return []interface{}{c.Result0, c.Result1}
  1474. }
  1475. // ReposStoreGetByNameFunc describes the behavior when the GetByName method
  1476. // of the parent MockReposStore instance is invoked.
  1477. type ReposStoreGetByNameFunc struct {
  1478. defaultHook func(context.Context, int64, string) (*db.Repository, error)
  1479. hooks []func(context.Context, int64, string) (*db.Repository, error)
  1480. history []ReposStoreGetByNameFuncCall
  1481. mutex sync.Mutex
  1482. }
  1483. // GetByName delegates to the next hook function in the queue and stores the
  1484. // parameter and result values of this invocation.
  1485. func (m *MockReposStore) GetByName(v0 context.Context, v1 int64, v2 string) (*db.Repository, error) {
  1486. r0, r1 := m.GetByNameFunc.nextHook()(v0, v1, v2)
  1487. m.GetByNameFunc.appendCall(ReposStoreGetByNameFuncCall{v0, v1, v2, r0, r1})
  1488. return r0, r1
  1489. }
  1490. // SetDefaultHook sets function that is called when the GetByName method of
  1491. // the parent MockReposStore instance is invoked and the hook queue is
  1492. // empty.
  1493. func (f *ReposStoreGetByNameFunc) SetDefaultHook(hook func(context.Context, int64, string) (*db.Repository, error)) {
  1494. f.defaultHook = hook
  1495. }
  1496. // PushHook adds a function to the end of hook queue. Each invocation of the
  1497. // GetByName method of the parent MockReposStore instance invokes the hook
  1498. // at the front of the queue and discards it. After the queue is empty, the
  1499. // default hook function is invoked for any future action.
  1500. func (f *ReposStoreGetByNameFunc) PushHook(hook func(context.Context, int64, string) (*db.Repository, error)) {
  1501. f.mutex.Lock()
  1502. f.hooks = append(f.hooks, hook)
  1503. f.mutex.Unlock()
  1504. }
  1505. // SetDefaultReturn calls SetDefaultHook with a function that returns the
  1506. // given values.
  1507. func (f *ReposStoreGetByNameFunc) SetDefaultReturn(r0 *db.Repository, r1 error) {
  1508. f.SetDefaultHook(func(context.Context, int64, string) (*db.Repository, error) {
  1509. return r0, r1
  1510. })
  1511. }
  1512. // PushReturn calls PushHook with a function that returns the given values.
  1513. func (f *ReposStoreGetByNameFunc) PushReturn(r0 *db.Repository, r1 error) {
  1514. f.PushHook(func(context.Context, int64, string) (*db.Repository, error) {
  1515. return r0, r1
  1516. })
  1517. }
  1518. func (f *ReposStoreGetByNameFunc) nextHook() func(context.Context, int64, string) (*db.Repository, error) {
  1519. f.mutex.Lock()
  1520. defer f.mutex.Unlock()
  1521. if len(f.hooks) == 0 {
  1522. return f.defaultHook
  1523. }
  1524. hook := f.hooks[0]
  1525. f.hooks = f.hooks[1:]
  1526. return hook
  1527. }
  1528. func (f *ReposStoreGetByNameFunc) appendCall(r0 ReposStoreGetByNameFuncCall) {
  1529. f.mutex.Lock()
  1530. f.history = append(f.history, r0)
  1531. f.mutex.Unlock()
  1532. }
  1533. // History returns a sequence of ReposStoreGetByNameFuncCall objects
  1534. // describing the invocations of this function.
  1535. func (f *ReposStoreGetByNameFunc) History() []ReposStoreGetByNameFuncCall {
  1536. f.mutex.Lock()
  1537. history := make([]ReposStoreGetByNameFuncCall, len(f.history))
  1538. copy(history, f.history)
  1539. f.mutex.Unlock()
  1540. return history
  1541. }
  1542. // ReposStoreGetByNameFuncCall is an object that describes an invocation of
  1543. // method GetByName on an instance of MockReposStore.
  1544. type ReposStoreGetByNameFuncCall struct {
  1545. // Arg0 is the value of the 1st argument passed to this method
  1546. // invocation.
  1547. Arg0 context.Context
  1548. // Arg1 is the value of the 2nd argument passed to this method
  1549. // invocation.
  1550. Arg1 int64
  1551. // Arg2 is the value of the 3rd argument passed to this method
  1552. // invocation.
  1553. Arg2 string
  1554. // Result0 is the value of the 1st result returned from this method
  1555. // invocation.
  1556. Result0 *db.Repository
  1557. // Result1 is the value of the 2nd result returned from this method
  1558. // invocation.
  1559. Result1 error
  1560. }
  1561. // Args returns an interface slice containing the arguments of this
  1562. // invocation.
  1563. func (c ReposStoreGetByNameFuncCall) Args() []interface{} {
  1564. return []interface{}{c.Arg0, c.Arg1, c.Arg2}
  1565. }
  1566. // Results returns an interface slice containing the results of this
  1567. // invocation.
  1568. func (c ReposStoreGetByNameFuncCall) Results() []interface{} {
  1569. return []interface{}{c.Result0, c.Result1}
  1570. }
  1571. // ReposStoreTouchFunc describes the behavior when the Touch method of the
  1572. // parent MockReposStore instance is invoked.
  1573. type ReposStoreTouchFunc struct {
  1574. defaultHook func(context.Context, int64) error
  1575. hooks []func(context.Context, int64) error
  1576. history []ReposStoreTouchFuncCall
  1577. mutex sync.Mutex
  1578. }
  1579. // Touch delegates to the next hook function in the queue and stores the
  1580. // parameter and result values of this invocation.
  1581. func (m *MockReposStore) Touch(v0 context.Context, v1 int64) error {
  1582. r0 := m.TouchFunc.nextHook()(v0, v1)
  1583. m.TouchFunc.appendCall(ReposStoreTouchFuncCall{v0, v1, r0})
  1584. return r0
  1585. }
  1586. // SetDefaultHook sets function that is called when the Touch method of the
  1587. // parent MockReposStore instance is invoked and the hook queue is empty.
  1588. func (f *ReposStoreTouchFunc) SetDefaultHook(hook func(context.Context, int64) error) {
  1589. f.defaultHook = hook
  1590. }
  1591. // PushHook adds a function to the end of hook queue. Each invocation of the
  1592. // Touch method of the parent MockReposStore instance invokes the hook at
  1593. // the front of the queue and discards it. After the queue is empty, the
  1594. // default hook function is invoked for any future action.
  1595. func (f *ReposStoreTouchFunc) PushHook(hook func(context.Context, int64) error) {
  1596. f.mutex.Lock()
  1597. f.hooks = append(f.hooks, hook)
  1598. f.mutex.Unlock()
  1599. }
  1600. // SetDefaultReturn calls SetDefaultHook with a function that returns the
  1601. // given values.
  1602. func (f *ReposStoreTouchFunc) SetDefaultReturn(r0 error) {
  1603. f.SetDefaultHook(func(context.Context, int64) error {
  1604. return r0
  1605. })
  1606. }
  1607. // PushReturn calls PushHook with a function that returns the given values.
  1608. func (f *ReposStoreTouchFunc) PushReturn(r0 error) {
  1609. f.PushHook(func(context.Context, int64) error {
  1610. return r0
  1611. })
  1612. }
  1613. func (f *ReposStoreTouchFunc) nextHook() func(context.Context, int64) error {
  1614. f.mutex.Lock()
  1615. defer f.mutex.Unlock()
  1616. if len(f.hooks) == 0 {
  1617. return f.defaultHook
  1618. }
  1619. hook := f.hooks[0]
  1620. f.hooks = f.hooks[1:]
  1621. return hook
  1622. }
  1623. func (f *ReposStoreTouchFunc) appendCall(r0 ReposStoreTouchFuncCall) {
  1624. f.mutex.Lock()
  1625. f.history = append(f.history, r0)
  1626. f.mutex.Unlock()
  1627. }
  1628. // History returns a sequence of ReposStoreTouchFuncCall objects describing
  1629. // the invocations of this function.
  1630. func (f *ReposStoreTouchFunc) History() []ReposStoreTouchFuncCall {
  1631. f.mutex.Lock()
  1632. history := make([]ReposStoreTouchFuncCall, len(f.history))
  1633. copy(history, f.history)
  1634. f.mutex.Unlock()
  1635. return history
  1636. }
  1637. // ReposStoreTouchFuncCall is an object that describes an invocation of
  1638. // method Touch on an instance of MockReposStore.
  1639. type ReposStoreTouchFuncCall struct {
  1640. // Arg0 is the value of the 1st argument passed to this method
  1641. // invocation.
  1642. Arg0 context.Context
  1643. // Arg1 is the value of the 2nd argument passed to this method
  1644. // invocation.
  1645. Arg1 int64
  1646. // Result0 is the value of the 1st result returned from this method
  1647. // invocation.
  1648. Result0 error
  1649. }
  1650. // Args returns an interface slice containing the arguments of this
  1651. // invocation.
  1652. func (c ReposStoreTouchFuncCall) Args() []interface{} {
  1653. return []interface{}{c.Arg0, c.Arg1}
  1654. }
  1655. // Results returns an interface slice containing the results of this
  1656. // invocation.
  1657. func (c ReposStoreTouchFuncCall) Results() []interface{} {
  1658. return []interface{}{c.Result0}
  1659. }
  1660. // MockTwoFactorsStore is a mock implementation of the TwoFactorsStore
  1661. // interface (from the package gogs.io/gogs/internal/db) used for unit
  1662. // testing.
  1663. type MockTwoFactorsStore struct {
  1664. // CreateFunc is an instance of a mock function object controlling the
  1665. // behavior of the method Create.
  1666. CreateFunc *TwoFactorsStoreCreateFunc
  1667. // GetByUserIDFunc is an instance of a mock function object controlling
  1668. // the behavior of the method GetByUserID.
  1669. GetByUserIDFunc *TwoFactorsStoreGetByUserIDFunc
  1670. // IsEnabledFunc is an instance of a mock function object controlling
  1671. // the behavior of the method IsEnabled.
  1672. IsEnabledFunc *TwoFactorsStoreIsEnabledFunc
  1673. }
  1674. // NewMockTwoFactorsStore creates a new mock of the TwoFactorsStore
  1675. // interface. All methods return zero values for all results, unless
  1676. // overwritten.
  1677. func NewMockTwoFactorsStore() *MockTwoFactorsStore {
  1678. return &MockTwoFactorsStore{
  1679. CreateFunc: &TwoFactorsStoreCreateFunc{
  1680. defaultHook: func(context.Context, int64, string, string) (r0 error) {
  1681. return
  1682. },
  1683. },
  1684. GetByUserIDFunc: &TwoFactorsStoreGetByUserIDFunc{
  1685. defaultHook: func(context.Context, int64) (r0 *db.TwoFactor, r1 error) {
  1686. return
  1687. },
  1688. },
  1689. IsEnabledFunc: &TwoFactorsStoreIsEnabledFunc{
  1690. defaultHook: func(context.Context, int64) (r0 bool) {
  1691. return
  1692. },
  1693. },
  1694. }
  1695. }
  1696. // NewStrictMockTwoFactorsStore creates a new mock of the TwoFactorsStore
  1697. // interface. All methods panic on invocation, unless overwritten.
  1698. func NewStrictMockTwoFactorsStore() *MockTwoFactorsStore {
  1699. return &MockTwoFactorsStore{
  1700. CreateFunc: &TwoFactorsStoreCreateFunc{
  1701. defaultHook: func(context.Context, int64, string, string) error {
  1702. panic("unexpected invocation of MockTwoFactorsStore.Create")
  1703. },
  1704. },
  1705. GetByUserIDFunc: &TwoFactorsStoreGetByUserIDFunc{
  1706. defaultHook: func(context.Context, int64) (*db.TwoFactor, error) {
  1707. panic("unexpected invocation of MockTwoFactorsStore.GetByUserID")
  1708. },
  1709. },
  1710. IsEnabledFunc: &TwoFactorsStoreIsEnabledFunc{
  1711. defaultHook: func(context.Context, int64) bool {
  1712. panic("unexpected invocation of MockTwoFactorsStore.IsEnabled")
  1713. },
  1714. },
  1715. }
  1716. }
  1717. // NewMockTwoFactorsStoreFrom creates a new mock of the MockTwoFactorsStore
  1718. // interface. All methods delegate to the given implementation, unless
  1719. // overwritten.
  1720. func NewMockTwoFactorsStoreFrom(i db.TwoFactorsStore) *MockTwoFactorsStore {
  1721. return &MockTwoFactorsStore{
  1722. CreateFunc: &TwoFactorsStoreCreateFunc{
  1723. defaultHook: i.Create,
  1724. },
  1725. GetByUserIDFunc: &TwoFactorsStoreGetByUserIDFunc{
  1726. defaultHook: i.GetByUserID,
  1727. },
  1728. IsEnabledFunc: &TwoFactorsStoreIsEnabledFunc{
  1729. defaultHook: i.IsEnabled,
  1730. },
  1731. }
  1732. }
  1733. // TwoFactorsStoreCreateFunc describes the behavior when the Create method
  1734. // of the parent MockTwoFactorsStore instance is invoked.
  1735. type TwoFactorsStoreCreateFunc struct {
  1736. defaultHook func(context.Context, int64, string, string) error
  1737. hooks []func(context.Context, int64, string, string) error
  1738. history []TwoFactorsStoreCreateFuncCall
  1739. mutex sync.Mutex
  1740. }
  1741. // Create delegates to the next hook function in the queue and stores the
  1742. // parameter and result values of this invocation.
  1743. func (m *MockTwoFactorsStore) Create(v0 context.Context, v1 int64, v2 string, v3 string) error {
  1744. r0 := m.CreateFunc.nextHook()(v0, v1, v2, v3)
  1745. m.CreateFunc.appendCall(TwoFactorsStoreCreateFuncCall{v0, v1, v2, v3, r0})
  1746. return r0
  1747. }
  1748. // SetDefaultHook sets function that is called when the Create method of the
  1749. // parent MockTwoFactorsStore instance is invoked and the hook queue is
  1750. // empty.
  1751. func (f *TwoFactorsStoreCreateFunc) SetDefaultHook(hook func(context.Context, int64, string, string) error) {
  1752. f.defaultHook = hook
  1753. }
  1754. // PushHook adds a function to the end of hook queue. Each invocation of the
  1755. // Create method of the parent MockTwoFactorsStore instance invokes the hook
  1756. // at the front of the queue and discards it. After the queue is empty, the
  1757. // default hook function is invoked for any future action.
  1758. func (f *TwoFactorsStoreCreateFunc) PushHook(hook func(context.Context, int64, string, string) error) {
  1759. f.mutex.Lock()
  1760. f.hooks = append(f.hooks, hook)
  1761. f.mutex.Unlock()
  1762. }
  1763. // SetDefaultReturn calls SetDefaultHook with a function that returns the
  1764. // given values.
  1765. func (f *TwoFactorsStoreCreateFunc) SetDefaultReturn(r0 error) {
  1766. f.SetDefaultHook(func(context.Context, int64, string, string) error {
  1767. return r0
  1768. })
  1769. }
  1770. // PushReturn calls PushHook with a function that returns the given values.
  1771. func (f *TwoFactorsStoreCreateFunc) PushReturn(r0 error) {
  1772. f.PushHook(func(context.Context, int64, string, string) error {
  1773. return r0
  1774. })
  1775. }
  1776. func (f *TwoFactorsStoreCreateFunc) nextHook() func(context.Context, int64, string, string) error {
  1777. f.mutex.Lock()
  1778. defer f.mutex.Unlock()
  1779. if len(f.hooks) == 0 {
  1780. return f.defaultHook
  1781. }
  1782. hook := f.hooks[0]
  1783. f.hooks = f.hooks[1:]
  1784. return hook
  1785. }
  1786. func (f *TwoFactorsStoreCreateFunc) appendCall(r0 TwoFactorsStoreCreateFuncCall) {
  1787. f.mutex.Lock()
  1788. f.history = append(f.history, r0)
  1789. f.mutex.Unlock()
  1790. }
  1791. // History returns a sequence of TwoFactorsStoreCreateFuncCall objects
  1792. // describing the invocations of this function.
  1793. func (f *TwoFactorsStoreCreateFunc) History() []TwoFactorsStoreCreateFuncCall {
  1794. f.mutex.Lock()
  1795. history := make([]TwoFactorsStoreCreateFuncCall, len(f.history))
  1796. copy(history, f.history)
  1797. f.mutex.Unlock()
  1798. return history
  1799. }
  1800. // TwoFactorsStoreCreateFuncCall is an object that describes an invocation
  1801. // of method Create on an instance of MockTwoFactorsStore.
  1802. type TwoFactorsStoreCreateFuncCall struct {
  1803. // Arg0 is the value of the 1st argument passed to this method
  1804. // invocation.
  1805. Arg0 context.Context
  1806. // Arg1 is the value of the 2nd argument passed to this method
  1807. // invocation.
  1808. Arg1 int64
  1809. // Arg2 is the value of the 3rd argument passed to this method
  1810. // invocation.
  1811. Arg2 string
  1812. // Arg3 is the value of the 4th argument passed to this method
  1813. // invocation.
  1814. Arg3 string
  1815. // Result0 is the value of the 1st result returned from this method
  1816. // invocation.
  1817. Result0 error
  1818. }
  1819. // Args returns an interface slice containing the arguments of this
  1820. // invocation.
  1821. func (c TwoFactorsStoreCreateFuncCall) Args() []interface{} {
  1822. return []interface{}{c.Arg0, c.Arg1, c.Arg2, c.Arg3}
  1823. }
  1824. // Results returns an interface slice containing the results of this
  1825. // invocation.
  1826. func (c TwoFactorsStoreCreateFuncCall) Results() []interface{} {
  1827. return []interface{}{c.Result0}
  1828. }
  1829. // TwoFactorsStoreGetByUserIDFunc describes the behavior when the
  1830. // GetByUserID method of the parent MockTwoFactorsStore instance is invoked.
  1831. type TwoFactorsStoreGetByUserIDFunc struct {
  1832. defaultHook func(context.Context, int64) (*db.TwoFactor, error)
  1833. hooks []func(context.Context, int64) (*db.TwoFactor, error)
  1834. history []TwoFactorsStoreGetByUserIDFuncCall
  1835. mutex sync.Mutex
  1836. }
  1837. // GetByUserID delegates to the next hook function in the queue and stores
  1838. // the parameter and result values of this invocation.
  1839. func (m *MockTwoFactorsStore) GetByUserID(v0 context.Context, v1 int64) (*db.TwoFactor, error) {
  1840. r0, r1 := m.GetByUserIDFunc.nextHook()(v0, v1)
  1841. m.GetByUserIDFunc.appendCall(TwoFactorsStoreGetByUserIDFuncCall{v0, v1, r0, r1})
  1842. return r0, r1
  1843. }
  1844. // SetDefaultHook sets function that is called when the GetByUserID method
  1845. // of the parent MockTwoFactorsStore instance is invoked and the hook queue
  1846. // is empty.
  1847. func (f *TwoFactorsStoreGetByUserIDFunc) SetDefaultHook(hook func(context.Context, int64) (*db.TwoFactor, error)) {
  1848. f.defaultHook = hook
  1849. }
  1850. // PushHook adds a function to the end of hook queue. Each invocation of the
  1851. // GetByUserID method of the parent MockTwoFactorsStore instance invokes the
  1852. // hook at the front of the queue and discards it. After the queue is empty,
  1853. // the default hook function is invoked for any future action.
  1854. func (f *TwoFactorsStoreGetByUserIDFunc) PushHook(hook func(context.Context, int64) (*db.TwoFactor, error)) {
  1855. f.mutex.Lock()
  1856. f.hooks = append(f.hooks, hook)
  1857. f.mutex.Unlock()
  1858. }
  1859. // SetDefaultReturn calls SetDefaultHook with a function that returns the
  1860. // given values.
  1861. func (f *TwoFactorsStoreGetByUserIDFunc) SetDefaultReturn(r0 *db.TwoFactor, r1 error) {
  1862. f.SetDefaultHook(func(context.Context, int64) (*db.TwoFactor, error) {
  1863. return r0, r1
  1864. })
  1865. }
  1866. // PushReturn calls PushHook with a function that returns the given values.
  1867. func (f *TwoFactorsStoreGetByUserIDFunc) PushReturn(r0 *db.TwoFactor, r1 error) {
  1868. f.PushHook(func(context.Context, int64) (*db.TwoFactor, error) {
  1869. return r0, r1
  1870. })
  1871. }
  1872. func (f *TwoFactorsStoreGetByUserIDFunc) nextHook() func(context.Context, int64) (*db.TwoFactor, error) {
  1873. f.mutex.Lock()
  1874. defer f.mutex.Unlock()
  1875. if len(f.hooks) == 0 {
  1876. return f.defaultHook
  1877. }
  1878. hook := f.hooks[0]
  1879. f.hooks = f.hooks[1:]
  1880. return hook
  1881. }
  1882. func (f *TwoFactorsStoreGetByUserIDFunc) appendCall(r0 TwoFactorsStoreGetByUserIDFuncCall) {
  1883. f.mutex.Lock()
  1884. f.history = append(f.history, r0)
  1885. f.mutex.Unlock()
  1886. }
  1887. // History returns a sequence of TwoFactorsStoreGetByUserIDFuncCall objects
  1888. // describing the invocations of this function.
  1889. func (f *TwoFactorsStoreGetByUserIDFunc) History() []TwoFactorsStoreGetByUserIDFuncCall {
  1890. f.mutex.Lock()
  1891. history := make([]TwoFactorsStoreGetByUserIDFuncCall, len(f.history))
  1892. copy(history, f.history)
  1893. f.mutex.Unlock()
  1894. return history
  1895. }
  1896. // TwoFactorsStoreGetByUserIDFuncCall is an object that describes an
  1897. // invocation of method GetByUserID on an instance of MockTwoFactorsStore.
  1898. type TwoFactorsStoreGetByUserIDFuncCall struct {
  1899. // Arg0 is the value of the 1st argument passed to this method
  1900. // invocation.
  1901. Arg0 context.Context
  1902. // Arg1 is the value of the 2nd argument passed to this method
  1903. // invocation.
  1904. Arg1 int64
  1905. // Result0 is the value of the 1st result returned from this method
  1906. // invocation.
  1907. Result0 *db.TwoFactor
  1908. // Result1 is the value of the 2nd result returned from this method
  1909. // invocation.
  1910. Result1 error
  1911. }
  1912. // Args returns an interface slice containing the arguments of this
  1913. // invocation.
  1914. func (c TwoFactorsStoreGetByUserIDFuncCall) Args() []interface{} {
  1915. return []interface{}{c.Arg0, c.Arg1}
  1916. }
  1917. // Results returns an interface slice containing the results of this
  1918. // invocation.
  1919. func (c TwoFactorsStoreGetByUserIDFuncCall) Results() []interface{} {
  1920. return []interface{}{c.Result0, c.Result1}
  1921. }
  1922. // TwoFactorsStoreIsEnabledFunc describes the behavior when the IsEnabled
  1923. // method of the parent MockTwoFactorsStore instance is invoked.
  1924. type TwoFactorsStoreIsEnabledFunc struct {
  1925. defaultHook func(context.Context, int64) bool
  1926. hooks []func(context.Context, int64) bool
  1927. history []TwoFactorsStoreIsEnabledFuncCall
  1928. mutex sync.Mutex
  1929. }
  1930. // IsEnabled delegates to the next hook function in the queue and stores the
  1931. // parameter and result values of this invocation.
  1932. func (m *MockTwoFactorsStore) IsEnabled(v0 context.Context, v1 int64) bool {
  1933. r0 := m.IsEnabledFunc.nextHook()(v0, v1)
  1934. m.IsEnabledFunc.appendCall(TwoFactorsStoreIsEnabledFuncCall{v0, v1, r0})
  1935. return r0
  1936. }
  1937. // SetDefaultHook sets function that is called when the IsEnabled method of
  1938. // the parent MockTwoFactorsStore instance is invoked and the hook queue is
  1939. // empty.
  1940. func (f *TwoFactorsStoreIsEnabledFunc) SetDefaultHook(hook func(context.Context, int64) bool) {
  1941. f.defaultHook = hook
  1942. }
  1943. // PushHook adds a function to the end of hook queue. Each invocation of the
  1944. // IsEnabled method of the parent MockTwoFactorsStore instance invokes the
  1945. // hook at the front of the queue and discards it. After the queue is empty,
  1946. // the default hook function is invoked for any future action.
  1947. func (f *TwoFactorsStoreIsEnabledFunc) PushHook(hook func(context.Context, int64) bool) {
  1948. f.mutex.Lock()
  1949. f.hooks = append(f.hooks, hook)
  1950. f.mutex.Unlock()
  1951. }
  1952. // SetDefaultReturn calls SetDefaultHook with a function that returns the
  1953. // given values.
  1954. func (f *TwoFactorsStoreIsEnabledFunc) SetDefaultReturn(r0 bool) {
  1955. f.SetDefaultHook(func(context.Context, int64) bool {
  1956. return r0
  1957. })
  1958. }
  1959. // PushReturn calls PushHook with a function that returns the given values.
  1960. func (f *TwoFactorsStoreIsEnabledFunc) PushReturn(r0 bool) {
  1961. f.PushHook(func(context.Context, int64) bool {
  1962. return r0
  1963. })
  1964. }
  1965. func (f *TwoFactorsStoreIsEnabledFunc) nextHook() func(context.Context, int64) bool {
  1966. f.mutex.Lock()
  1967. defer f.mutex.Unlock()
  1968. if len(f.hooks) == 0 {
  1969. return f.defaultHook
  1970. }
  1971. hook := f.hooks[0]
  1972. f.hooks = f.hooks[1:]
  1973. return hook
  1974. }
  1975. func (f *TwoFactorsStoreIsEnabledFunc) appendCall(r0 TwoFactorsStoreIsEnabledFuncCall) {
  1976. f.mutex.Lock()
  1977. f.history = append(f.history, r0)
  1978. f.mutex.Unlock()
  1979. }
  1980. // History returns a sequence of TwoFactorsStoreIsEnabledFuncCall objects
  1981. // describing the invocations of this function.
  1982. func (f *TwoFactorsStoreIsEnabledFunc) History() []TwoFactorsStoreIsEnabledFuncCall {
  1983. f.mutex.Lock()
  1984. history := make([]TwoFactorsStoreIsEnabledFuncCall, len(f.history))
  1985. copy(history, f.history)
  1986. f.mutex.Unlock()
  1987. return history
  1988. }
  1989. // TwoFactorsStoreIsEnabledFuncCall is an object that describes an
  1990. // invocation of method IsEnabled on an instance of MockTwoFactorsStore.
  1991. type TwoFactorsStoreIsEnabledFuncCall struct {
  1992. // Arg0 is the value of the 1st argument passed to this method
  1993. // invocation.
  1994. Arg0 context.Context
  1995. // Arg1 is the value of the 2nd argument passed to this method
  1996. // invocation.
  1997. Arg1 int64
  1998. // Result0 is the value of the 1st result returned from this method
  1999. // invocation.
  2000. Result0 bool
  2001. }
  2002. // Args returns an interface slice containing the arguments of this
  2003. // invocation.
  2004. func (c TwoFactorsStoreIsEnabledFuncCall) Args() []interface{} {
  2005. return []interface{}{c.Arg0, c.Arg1}
  2006. }
  2007. // Results returns an interface slice containing the results of this
  2008. // invocation.
  2009. func (c TwoFactorsStoreIsEnabledFuncCall) Results() []interface{} {
  2010. return []interface{}{c.Result0}
  2011. }
  2012. // MockUsersStore is a mock implementation of the UsersStore interface (from
  2013. // the package gogs.io/gogs/internal/db) used for unit testing.
  2014. type MockUsersStore struct {
  2015. // AuthenticateFunc is an instance of a mock function object controlling
  2016. // the behavior of the method Authenticate.
  2017. AuthenticateFunc *UsersStoreAuthenticateFunc
  2018. // ChangeUsernameFunc is an instance of a mock function object
  2019. // controlling the behavior of the method ChangeUsername.
  2020. ChangeUsernameFunc *UsersStoreChangeUsernameFunc
  2021. // CountFunc is an instance of a mock function object controlling the
  2022. // behavior of the method Count.
  2023. CountFunc *UsersStoreCountFunc
  2024. // CreateFunc is an instance of a mock function object controlling the
  2025. // behavior of the method Create.
  2026. CreateFunc *UsersStoreCreateFunc
  2027. // DeleteCustomAvatarFunc is an instance of a mock function object
  2028. // controlling the behavior of the method DeleteCustomAvatar.
  2029. DeleteCustomAvatarFunc *UsersStoreDeleteCustomAvatarFunc
  2030. // GetByEmailFunc is an instance of a mock function object controlling
  2031. // the behavior of the method GetByEmail.
  2032. GetByEmailFunc *UsersStoreGetByEmailFunc
  2033. // GetByIDFunc is an instance of a mock function object controlling the
  2034. // behavior of the method GetByID.
  2035. GetByIDFunc *UsersStoreGetByIDFunc
  2036. // GetByKeyIDFunc is an instance of a mock function object controlling
  2037. // the behavior of the method GetByKeyID.
  2038. GetByKeyIDFunc *UsersStoreGetByKeyIDFunc
  2039. // GetByUsernameFunc is an instance of a mock function object
  2040. // controlling the behavior of the method GetByUsername.
  2041. GetByUsernameFunc *UsersStoreGetByUsernameFunc
  2042. // HasForkedRepositoryFunc is an instance of a mock function object
  2043. // controlling the behavior of the method HasForkedRepository.
  2044. HasForkedRepositoryFunc *UsersStoreHasForkedRepositoryFunc
  2045. // IsUsernameUsedFunc is an instance of a mock function object
  2046. // controlling the behavior of the method IsUsernameUsed.
  2047. IsUsernameUsedFunc *UsersStoreIsUsernameUsedFunc
  2048. // ListFunc is an instance of a mock function object controlling the
  2049. // behavior of the method List.
  2050. ListFunc *UsersStoreListFunc
  2051. // ListFollowersFunc is an instance of a mock function object
  2052. // controlling the behavior of the method ListFollowers.
  2053. ListFollowersFunc *UsersStoreListFollowersFunc
  2054. // ListFollowingsFunc is an instance of a mock function object
  2055. // controlling the behavior of the method ListFollowings.
  2056. ListFollowingsFunc *UsersStoreListFollowingsFunc
  2057. // UpdateFunc is an instance of a mock function object controlling the
  2058. // behavior of the method Update.
  2059. UpdateFunc *UsersStoreUpdateFunc
  2060. // UseCustomAvatarFunc is an instance of a mock function object
  2061. // controlling the behavior of the method UseCustomAvatar.
  2062. UseCustomAvatarFunc *UsersStoreUseCustomAvatarFunc
  2063. }
  2064. // NewMockUsersStore creates a new mock of the UsersStore interface. All
  2065. // methods return zero values for all results, unless overwritten.
  2066. func NewMockUsersStore() *MockUsersStore {
  2067. return &MockUsersStore{
  2068. AuthenticateFunc: &UsersStoreAuthenticateFunc{
  2069. defaultHook: func(context.Context, string, string, int64) (r0 *db.User, r1 error) {
  2070. return
  2071. },
  2072. },
  2073. ChangeUsernameFunc: &UsersStoreChangeUsernameFunc{
  2074. defaultHook: func(context.Context, int64, string) (r0 error) {
  2075. return
  2076. },
  2077. },
  2078. CountFunc: &UsersStoreCountFunc{
  2079. defaultHook: func(context.Context) (r0 int64) {
  2080. return
  2081. },
  2082. },
  2083. CreateFunc: &UsersStoreCreateFunc{
  2084. defaultHook: func(context.Context, string, string, db.CreateUserOptions) (r0 *db.User, r1 error) {
  2085. return
  2086. },
  2087. },
  2088. DeleteCustomAvatarFunc: &UsersStoreDeleteCustomAvatarFunc{
  2089. defaultHook: func(context.Context, int64) (r0 error) {
  2090. return
  2091. },
  2092. },
  2093. GetByEmailFunc: &UsersStoreGetByEmailFunc{
  2094. defaultHook: func(context.Context, string) (r0 *db.User, r1 error) {
  2095. return
  2096. },
  2097. },
  2098. GetByIDFunc: &UsersStoreGetByIDFunc{
  2099. defaultHook: func(context.Context, int64) (r0 *db.User, r1 error) {
  2100. return
  2101. },
  2102. },
  2103. GetByKeyIDFunc: &UsersStoreGetByKeyIDFunc{
  2104. defaultHook: func(context.Context, int64) (r0 *db.User, r1 error) {
  2105. return
  2106. },
  2107. },
  2108. GetByUsernameFunc: &UsersStoreGetByUsernameFunc{
  2109. defaultHook: func(context.Context, string) (r0 *db.User, r1 error) {
  2110. return
  2111. },
  2112. },
  2113. HasForkedRepositoryFunc: &UsersStoreHasForkedRepositoryFunc{
  2114. defaultHook: func(context.Context, int64, int64) (r0 bool) {
  2115. return
  2116. },
  2117. },
  2118. IsUsernameUsedFunc: &UsersStoreIsUsernameUsedFunc{
  2119. defaultHook: func(context.Context, string, int64) (r0 bool) {
  2120. return
  2121. },
  2122. },
  2123. ListFunc: &UsersStoreListFunc{
  2124. defaultHook: func(context.Context, int, int) (r0 []*db.User, r1 error) {
  2125. return
  2126. },
  2127. },
  2128. ListFollowersFunc: &UsersStoreListFollowersFunc{
  2129. defaultHook: func(context.Context, int64, int, int) (r0 []*db.User, r1 error) {
  2130. return
  2131. },
  2132. },
  2133. ListFollowingsFunc: &UsersStoreListFollowingsFunc{
  2134. defaultHook: func(context.Context, int64, int, int) (r0 []*db.User, r1 error) {
  2135. return
  2136. },
  2137. },
  2138. UpdateFunc: &UsersStoreUpdateFunc{
  2139. defaultHook: func(context.Context, int64, db.UpdateUserOptions) (r0 error) {
  2140. return
  2141. },
  2142. },
  2143. UseCustomAvatarFunc: &UsersStoreUseCustomAvatarFunc{
  2144. defaultHook: func(context.Context, int64, []byte) (r0 error) {
  2145. return
  2146. },
  2147. },
  2148. }
  2149. }
  2150. // NewStrictMockUsersStore creates a new mock of the UsersStore interface.
  2151. // All methods panic on invocation, unless overwritten.
  2152. func NewStrictMockUsersStore() *MockUsersStore {
  2153. return &MockUsersStore{
  2154. AuthenticateFunc: &UsersStoreAuthenticateFunc{
  2155. defaultHook: func(context.Context, string, string, int64) (*db.User, error) {
  2156. panic("unexpected invocation of MockUsersStore.Authenticate")
  2157. },
  2158. },
  2159. ChangeUsernameFunc: &UsersStoreChangeUsernameFunc{
  2160. defaultHook: func(context.Context, int64, string) error {
  2161. panic("unexpected invocation of MockUsersStore.ChangeUsername")
  2162. },
  2163. },
  2164. CountFunc: &UsersStoreCountFunc{
  2165. defaultHook: func(context.Context) int64 {
  2166. panic("unexpected invocation of MockUsersStore.Count")
  2167. },
  2168. },
  2169. CreateFunc: &UsersStoreCreateFunc{
  2170. defaultHook: func(context.Context, string, string, db.CreateUserOptions) (*db.User, error) {
  2171. panic("unexpected invocation of MockUsersStore.Create")
  2172. },
  2173. },
  2174. DeleteCustomAvatarFunc: &UsersStoreDeleteCustomAvatarFunc{
  2175. defaultHook: func(context.Context, int64) error {
  2176. panic("unexpected invocation of MockUsersStore.DeleteCustomAvatar")
  2177. },
  2178. },
  2179. GetByEmailFunc: &UsersStoreGetByEmailFunc{
  2180. defaultHook: func(context.Context, string) (*db.User, error) {
  2181. panic("unexpected invocation of MockUsersStore.GetByEmail")
  2182. },
  2183. },
  2184. GetByIDFunc: &UsersStoreGetByIDFunc{
  2185. defaultHook: func(context.Context, int64) (*db.User, error) {
  2186. panic("unexpected invocation of MockUsersStore.GetByID")
  2187. },
  2188. },
  2189. GetByKeyIDFunc: &UsersStoreGetByKeyIDFunc{
  2190. defaultHook: func(context.Context, int64) (*db.User, error) {
  2191. panic("unexpected invocation of MockUsersStore.GetByKeyID")
  2192. },
  2193. },
  2194. GetByUsernameFunc: &UsersStoreGetByUsernameFunc{
  2195. defaultHook: func(context.Context, string) (*db.User, error) {
  2196. panic("unexpected invocation of MockUsersStore.GetByUsername")
  2197. },
  2198. },
  2199. HasForkedRepositoryFunc: &UsersStoreHasForkedRepositoryFunc{
  2200. defaultHook: func(context.Context, int64, int64) bool {
  2201. panic("unexpected invocation of MockUsersStore.HasForkedRepository")
  2202. },
  2203. },
  2204. IsUsernameUsedFunc: &UsersStoreIsUsernameUsedFunc{
  2205. defaultHook: func(context.Context, string, int64) bool {
  2206. panic("unexpected invocation of MockUsersStore.IsUsernameUsed")
  2207. },
  2208. },
  2209. ListFunc: &UsersStoreListFunc{
  2210. defaultHook: func(context.Context, int, int) ([]*db.User, error) {
  2211. panic("unexpected invocation of MockUsersStore.List")
  2212. },
  2213. },
  2214. ListFollowersFunc: &UsersStoreListFollowersFunc{
  2215. defaultHook: func(context.Context, int64, int, int) ([]*db.User, error) {
  2216. panic("unexpected invocation of MockUsersStore.ListFollowers")
  2217. },
  2218. },
  2219. ListFollowingsFunc: &UsersStoreListFollowingsFunc{
  2220. defaultHook: func(context.Context, int64, int, int) ([]*db.User, error) {
  2221. panic("unexpected invocation of MockUsersStore.ListFollowings")
  2222. },
  2223. },
  2224. UpdateFunc: &UsersStoreUpdateFunc{
  2225. defaultHook: func(context.Context, int64, db.UpdateUserOptions) error {
  2226. panic("unexpected invocation of MockUsersStore.Update")
  2227. },
  2228. },
  2229. UseCustomAvatarFunc: &UsersStoreUseCustomAvatarFunc{
  2230. defaultHook: func(context.Context, int64, []byte) error {
  2231. panic("unexpected invocation of MockUsersStore.UseCustomAvatar")
  2232. },
  2233. },
  2234. }
  2235. }
  2236. // NewMockUsersStoreFrom creates a new mock of the MockUsersStore interface.
  2237. // All methods delegate to the given implementation, unless overwritten.
  2238. func NewMockUsersStoreFrom(i db.UsersStore) *MockUsersStore {
  2239. return &MockUsersStore{
  2240. AuthenticateFunc: &UsersStoreAuthenticateFunc{
  2241. defaultHook: i.Authenticate,
  2242. },
  2243. ChangeUsernameFunc: &UsersStoreChangeUsernameFunc{
  2244. defaultHook: i.ChangeUsername,
  2245. },
  2246. CountFunc: &UsersStoreCountFunc{
  2247. defaultHook: i.Count,
  2248. },
  2249. CreateFunc: &UsersStoreCreateFunc{
  2250. defaultHook: i.Create,
  2251. },
  2252. DeleteCustomAvatarFunc: &UsersStoreDeleteCustomAvatarFunc{
  2253. defaultHook: i.DeleteCustomAvatar,
  2254. },
  2255. GetByEmailFunc: &UsersStoreGetByEmailFunc{
  2256. defaultHook: i.GetByEmail,
  2257. },
  2258. GetByIDFunc: &UsersStoreGetByIDFunc{
  2259. defaultHook: i.GetByID,
  2260. },
  2261. GetByKeyIDFunc: &UsersStoreGetByKeyIDFunc{
  2262. defaultHook: i.GetByKeyID,
  2263. },
  2264. GetByUsernameFunc: &UsersStoreGetByUsernameFunc{
  2265. defaultHook: i.GetByUsername,
  2266. },
  2267. HasForkedRepositoryFunc: &UsersStoreHasForkedRepositoryFunc{
  2268. defaultHook: i.HasForkedRepository,
  2269. },
  2270. IsUsernameUsedFunc: &UsersStoreIsUsernameUsedFunc{
  2271. defaultHook: i.IsUsernameUsed,
  2272. },
  2273. ListFunc: &UsersStoreListFunc{
  2274. defaultHook: i.List,
  2275. },
  2276. ListFollowersFunc: &UsersStoreListFollowersFunc{
  2277. defaultHook: i.ListFollowers,
  2278. },
  2279. ListFollowingsFunc: &UsersStoreListFollowingsFunc{
  2280. defaultHook: i.ListFollowings,
  2281. },
  2282. UpdateFunc: &UsersStoreUpdateFunc{
  2283. defaultHook: i.Update,
  2284. },
  2285. UseCustomAvatarFunc: &UsersStoreUseCustomAvatarFunc{
  2286. defaultHook: i.UseCustomAvatar,
  2287. },
  2288. }
  2289. }
  2290. // UsersStoreAuthenticateFunc describes the behavior when the Authenticate
  2291. // method of the parent MockUsersStore instance is invoked.
  2292. type UsersStoreAuthenticateFunc struct {
  2293. defaultHook func(context.Context, string, string, int64) (*db.User, error)
  2294. hooks []func(context.Context, string, string, int64) (*db.User, error)
  2295. history []UsersStoreAuthenticateFuncCall
  2296. mutex sync.Mutex
  2297. }
  2298. // Authenticate delegates to the next hook function in the queue and stores
  2299. // the parameter and result values of this invocation.
  2300. func (m *MockUsersStore) Authenticate(v0 context.Context, v1 string, v2 string, v3 int64) (*db.User, error) {
  2301. r0, r1 := m.AuthenticateFunc.nextHook()(v0, v1, v2, v3)
  2302. m.AuthenticateFunc.appendCall(UsersStoreAuthenticateFuncCall{v0, v1, v2, v3, r0, r1})
  2303. return r0, r1
  2304. }
  2305. // SetDefaultHook sets function that is called when the Authenticate method
  2306. // of the parent MockUsersStore instance is invoked and the hook queue is
  2307. // empty.
  2308. func (f *UsersStoreAuthenticateFunc) SetDefaultHook(hook func(context.Context, string, string, int64) (*db.User, error)) {
  2309. f.defaultHook = hook
  2310. }
  2311. // PushHook adds a function to the end of hook queue. Each invocation of the
  2312. // Authenticate method of the parent MockUsersStore instance invokes the
  2313. // hook at the front of the queue and discards it. After the queue is empty,
  2314. // the default hook function is invoked for any future action.
  2315. func (f *UsersStoreAuthenticateFunc) PushHook(hook func(context.Context, string, string, int64) (*db.User, error)) {
  2316. f.mutex.Lock()
  2317. f.hooks = append(f.hooks, hook)
  2318. f.mutex.Unlock()
  2319. }
  2320. // SetDefaultReturn calls SetDefaultHook with a function that returns the
  2321. // given values.
  2322. func (f *UsersStoreAuthenticateFunc) SetDefaultReturn(r0 *db.User, r1 error) {
  2323. f.SetDefaultHook(func(context.Context, string, string, int64) (*db.User, error) {
  2324. return r0, r1
  2325. })
  2326. }
  2327. // PushReturn calls PushHook with a function that returns the given values.
  2328. func (f *UsersStoreAuthenticateFunc) PushReturn(r0 *db.User, r1 error) {
  2329. f.PushHook(func(context.Context, string, string, int64) (*db.User, error) {
  2330. return r0, r1
  2331. })
  2332. }
  2333. func (f *UsersStoreAuthenticateFunc) nextHook() func(context.Context, string, string, int64) (*db.User, error) {
  2334. f.mutex.Lock()
  2335. defer f.mutex.Unlock()
  2336. if len(f.hooks) == 0 {
  2337. return f.defaultHook
  2338. }
  2339. hook := f.hooks[0]
  2340. f.hooks = f.hooks[1:]
  2341. return hook
  2342. }
  2343. func (f *UsersStoreAuthenticateFunc) appendCall(r0 UsersStoreAuthenticateFuncCall) {
  2344. f.mutex.Lock()
  2345. f.history = append(f.history, r0)
  2346. f.mutex.Unlock()
  2347. }
  2348. // History returns a sequence of UsersStoreAuthenticateFuncCall objects
  2349. // describing the invocations of this function.
  2350. func (f *UsersStoreAuthenticateFunc) History() []UsersStoreAuthenticateFuncCall {
  2351. f.mutex.Lock()
  2352. history := make([]UsersStoreAuthenticateFuncCall, len(f.history))
  2353. copy(history, f.history)
  2354. f.mutex.Unlock()
  2355. return history
  2356. }
  2357. // UsersStoreAuthenticateFuncCall is an object that describes an invocation
  2358. // of method Authenticate on an instance of MockUsersStore.
  2359. type UsersStoreAuthenticateFuncCall struct {
  2360. // Arg0 is the value of the 1st argument passed to this method
  2361. // invocation.
  2362. Arg0 context.Context
  2363. // Arg1 is the value of the 2nd argument passed to this method
  2364. // invocation.
  2365. Arg1 string
  2366. // Arg2 is the value of the 3rd argument passed to this method
  2367. // invocation.
  2368. Arg2 string
  2369. // Arg3 is the value of the 4th argument passed to this method
  2370. // invocation.
  2371. Arg3 int64
  2372. // Result0 is the value of the 1st result returned from this method
  2373. // invocation.
  2374. Result0 *db.User
  2375. // Result1 is the value of the 2nd result returned from this method
  2376. // invocation.
  2377. Result1 error
  2378. }
  2379. // Args returns an interface slice containing the arguments of this
  2380. // invocation.
  2381. func (c UsersStoreAuthenticateFuncCall) Args() []interface{} {
  2382. return []interface{}{c.Arg0, c.Arg1, c.Arg2, c.Arg3}
  2383. }
  2384. // Results returns an interface slice containing the results of this
  2385. // invocation.
  2386. func (c UsersStoreAuthenticateFuncCall) Results() []interface{} {
  2387. return []interface{}{c.Result0, c.Result1}
  2388. }
  2389. // UsersStoreChangeUsernameFunc describes the behavior when the
  2390. // ChangeUsername method of the parent MockUsersStore instance is invoked.
  2391. type UsersStoreChangeUsernameFunc struct {
  2392. defaultHook func(context.Context, int64, string) error
  2393. hooks []func(context.Context, int64, string) error
  2394. history []UsersStoreChangeUsernameFuncCall
  2395. mutex sync.Mutex
  2396. }
  2397. // ChangeUsername delegates to the next hook function in the queue and
  2398. // stores the parameter and result values of this invocation.
  2399. func (m *MockUsersStore) ChangeUsername(v0 context.Context, v1 int64, v2 string) error {
  2400. r0 := m.ChangeUsernameFunc.nextHook()(v0, v1, v2)
  2401. m.ChangeUsernameFunc.appendCall(UsersStoreChangeUsernameFuncCall{v0, v1, v2, r0})
  2402. return r0
  2403. }
  2404. // SetDefaultHook sets function that is called when the ChangeUsername
  2405. // method of the parent MockUsersStore instance is invoked and the hook
  2406. // queue is empty.
  2407. func (f *UsersStoreChangeUsernameFunc) SetDefaultHook(hook func(context.Context, int64, string) error) {
  2408. f.defaultHook = hook
  2409. }
  2410. // PushHook adds a function to the end of hook queue. Each invocation of the
  2411. // ChangeUsername method of the parent MockUsersStore instance invokes the
  2412. // hook at the front of the queue and discards it. After the queue is empty,
  2413. // the default hook function is invoked for any future action.
  2414. func (f *UsersStoreChangeUsernameFunc) PushHook(hook func(context.Context, int64, string) error) {
  2415. f.mutex.Lock()
  2416. f.hooks = append(f.hooks, hook)
  2417. f.mutex.Unlock()
  2418. }
  2419. // SetDefaultReturn calls SetDefaultHook with a function that returns the
  2420. // given values.
  2421. func (f *UsersStoreChangeUsernameFunc) SetDefaultReturn(r0 error) {
  2422. f.SetDefaultHook(func(context.Context, int64, string) error {
  2423. return r0
  2424. })
  2425. }
  2426. // PushReturn calls PushHook with a function that returns the given values.
  2427. func (f *UsersStoreChangeUsernameFunc) PushReturn(r0 error) {
  2428. f.PushHook(func(context.Context, int64, string) error {
  2429. return r0
  2430. })
  2431. }
  2432. func (f *UsersStoreChangeUsernameFunc) nextHook() func(context.Context, int64, string) error {
  2433. f.mutex.Lock()
  2434. defer f.mutex.Unlock()
  2435. if len(f.hooks) == 0 {
  2436. return f.defaultHook
  2437. }
  2438. hook := f.hooks[0]
  2439. f.hooks = f.hooks[1:]
  2440. return hook
  2441. }
  2442. func (f *UsersStoreChangeUsernameFunc) appendCall(r0 UsersStoreChangeUsernameFuncCall) {
  2443. f.mutex.Lock()
  2444. f.history = append(f.history, r0)
  2445. f.mutex.Unlock()
  2446. }
  2447. // History returns a sequence of UsersStoreChangeUsernameFuncCall objects
  2448. // describing the invocations of this function.
  2449. func (f *UsersStoreChangeUsernameFunc) History() []UsersStoreChangeUsernameFuncCall {
  2450. f.mutex.Lock()
  2451. history := make([]UsersStoreChangeUsernameFuncCall, len(f.history))
  2452. copy(history, f.history)
  2453. f.mutex.Unlock()
  2454. return history
  2455. }
  2456. // UsersStoreChangeUsernameFuncCall is an object that describes an
  2457. // invocation of method ChangeUsername on an instance of MockUsersStore.
  2458. type UsersStoreChangeUsernameFuncCall struct {
  2459. // Arg0 is the value of the 1st argument passed to this method
  2460. // invocation.
  2461. Arg0 context.Context
  2462. // Arg1 is the value of the 2nd argument passed to this method
  2463. // invocation.
  2464. Arg1 int64
  2465. // Arg2 is the value of the 3rd argument passed to this method
  2466. // invocation.
  2467. Arg2 string
  2468. // Result0 is the value of the 1st result returned from this method
  2469. // invocation.
  2470. Result0 error
  2471. }
  2472. // Args returns an interface slice containing the arguments of this
  2473. // invocation.
  2474. func (c UsersStoreChangeUsernameFuncCall) Args() []interface{} {
  2475. return []interface{}{c.Arg0, c.Arg1, c.Arg2}
  2476. }
  2477. // Results returns an interface slice containing the results of this
  2478. // invocation.
  2479. func (c UsersStoreChangeUsernameFuncCall) Results() []interface{} {
  2480. return []interface{}{c.Result0}
  2481. }
  2482. // UsersStoreCountFunc describes the behavior when the Count method of the
  2483. // parent MockUsersStore instance is invoked.
  2484. type UsersStoreCountFunc struct {
  2485. defaultHook func(context.Context) int64
  2486. hooks []func(context.Context) int64
  2487. history []UsersStoreCountFuncCall
  2488. mutex sync.Mutex
  2489. }
  2490. // Count delegates to the next hook function in the queue and stores the
  2491. // parameter and result values of this invocation.
  2492. func (m *MockUsersStore) Count(v0 context.Context) int64 {
  2493. r0 := m.CountFunc.nextHook()(v0)
  2494. m.CountFunc.appendCall(UsersStoreCountFuncCall{v0, r0})
  2495. return r0
  2496. }
  2497. // SetDefaultHook sets function that is called when the Count method of the
  2498. // parent MockUsersStore instance is invoked and the hook queue is empty.
  2499. func (f *UsersStoreCountFunc) SetDefaultHook(hook func(context.Context) int64) {
  2500. f.defaultHook = hook
  2501. }
  2502. // PushHook adds a function to the end of hook queue. Each invocation of the
  2503. // Count method of the parent MockUsersStore instance invokes the hook at
  2504. // the front of the queue and discards it. After the queue is empty, the
  2505. // default hook function is invoked for any future action.
  2506. func (f *UsersStoreCountFunc) PushHook(hook func(context.Context) int64) {
  2507. f.mutex.Lock()
  2508. f.hooks = append(f.hooks, hook)
  2509. f.mutex.Unlock()
  2510. }
  2511. // SetDefaultReturn calls SetDefaultHook with a function that returns the
  2512. // given values.
  2513. func (f *UsersStoreCountFunc) SetDefaultReturn(r0 int64) {
  2514. f.SetDefaultHook(func(context.Context) int64 {
  2515. return r0
  2516. })
  2517. }
  2518. // PushReturn calls PushHook with a function that returns the given values.
  2519. func (f *UsersStoreCountFunc) PushReturn(r0 int64) {
  2520. f.PushHook(func(context.Context) int64 {
  2521. return r0
  2522. })
  2523. }
  2524. func (f *UsersStoreCountFunc) nextHook() func(context.Context) int64 {
  2525. f.mutex.Lock()
  2526. defer f.mutex.Unlock()
  2527. if len(f.hooks) == 0 {
  2528. return f.defaultHook
  2529. }
  2530. hook := f.hooks[0]
  2531. f.hooks = f.hooks[1:]
  2532. return hook
  2533. }
  2534. func (f *UsersStoreCountFunc) appendCall(r0 UsersStoreCountFuncCall) {
  2535. f.mutex.Lock()
  2536. f.history = append(f.history, r0)
  2537. f.mutex.Unlock()
  2538. }
  2539. // History returns a sequence of UsersStoreCountFuncCall objects describing
  2540. // the invocations of this function.
  2541. func (f *UsersStoreCountFunc) History() []UsersStoreCountFuncCall {
  2542. f.mutex.Lock()
  2543. history := make([]UsersStoreCountFuncCall, len(f.history))
  2544. copy(history, f.history)
  2545. f.mutex.Unlock()
  2546. return history
  2547. }
  2548. // UsersStoreCountFuncCall is an object that describes an invocation of
  2549. // method Count on an instance of MockUsersStore.
  2550. type UsersStoreCountFuncCall struct {
  2551. // Arg0 is the value of the 1st argument passed to this method
  2552. // invocation.
  2553. Arg0 context.Context
  2554. // Result0 is the value of the 1st result returned from this method
  2555. // invocation.
  2556. Result0 int64
  2557. }
  2558. // Args returns an interface slice containing the arguments of this
  2559. // invocation.
  2560. func (c UsersStoreCountFuncCall) Args() []interface{} {
  2561. return []interface{}{c.Arg0}
  2562. }
  2563. // Results returns an interface slice containing the results of this
  2564. // invocation.
  2565. func (c UsersStoreCountFuncCall) Results() []interface{} {
  2566. return []interface{}{c.Result0}
  2567. }
  2568. // UsersStoreCreateFunc describes the behavior when the Create method of the
  2569. // parent MockUsersStore instance is invoked.
  2570. type UsersStoreCreateFunc struct {
  2571. defaultHook func(context.Context, string, string, db.CreateUserOptions) (*db.User, error)
  2572. hooks []func(context.Context, string, string, db.CreateUserOptions) (*db.User, error)
  2573. history []UsersStoreCreateFuncCall
  2574. mutex sync.Mutex
  2575. }
  2576. // Create delegates to the next hook function in the queue and stores the
  2577. // parameter and result values of this invocation.
  2578. func (m *MockUsersStore) Create(v0 context.Context, v1 string, v2 string, v3 db.CreateUserOptions) (*db.User, error) {
  2579. r0, r1 := m.CreateFunc.nextHook()(v0, v1, v2, v3)
  2580. m.CreateFunc.appendCall(UsersStoreCreateFuncCall{v0, v1, v2, v3, r0, r1})
  2581. return r0, r1
  2582. }
  2583. // SetDefaultHook sets function that is called when the Create method of the
  2584. // parent MockUsersStore instance is invoked and the hook queue is empty.
  2585. func (f *UsersStoreCreateFunc) SetDefaultHook(hook func(context.Context, string, string, db.CreateUserOptions) (*db.User, error)) {
  2586. f.defaultHook = hook
  2587. }
  2588. // PushHook adds a function to the end of hook queue. Each invocation of the
  2589. // Create method of the parent MockUsersStore instance invokes the hook at
  2590. // the front of the queue and discards it. After the queue is empty, the
  2591. // default hook function is invoked for any future action.
  2592. func (f *UsersStoreCreateFunc) PushHook(hook func(context.Context, string, string, db.CreateUserOptions) (*db.User, error)) {
  2593. f.mutex.Lock()
  2594. f.hooks = append(f.hooks, hook)
  2595. f.mutex.Unlock()
  2596. }
  2597. // SetDefaultReturn calls SetDefaultHook with a function that returns the
  2598. // given values.
  2599. func (f *UsersStoreCreateFunc) SetDefaultReturn(r0 *db.User, r1 error) {
  2600. f.SetDefaultHook(func(context.Context, string, string, db.CreateUserOptions) (*db.User, error) {
  2601. return r0, r1
  2602. })
  2603. }
  2604. // PushReturn calls PushHook with a function that returns the given values.
  2605. func (f *UsersStoreCreateFunc) PushReturn(r0 *db.User, r1 error) {
  2606. f.PushHook(func(context.Context, string, string, db.CreateUserOptions) (*db.User, error) {
  2607. return r0, r1
  2608. })
  2609. }
  2610. func (f *UsersStoreCreateFunc) nextHook() func(context.Context, string, string, db.CreateUserOptions) (*db.User, error) {
  2611. f.mutex.Lock()
  2612. defer f.mutex.Unlock()
  2613. if len(f.hooks) == 0 {
  2614. return f.defaultHook
  2615. }
  2616. hook := f.hooks[0]
  2617. f.hooks = f.hooks[1:]
  2618. return hook
  2619. }
  2620. func (f *UsersStoreCreateFunc) appendCall(r0 UsersStoreCreateFuncCall) {
  2621. f.mutex.Lock()
  2622. f.history = append(f.history, r0)
  2623. f.mutex.Unlock()
  2624. }
  2625. // History returns a sequence of UsersStoreCreateFuncCall objects describing
  2626. // the invocations of this function.
  2627. func (f *UsersStoreCreateFunc) History() []UsersStoreCreateFuncCall {
  2628. f.mutex.Lock()
  2629. history := make([]UsersStoreCreateFuncCall, len(f.history))
  2630. copy(history, f.history)
  2631. f.mutex.Unlock()
  2632. return history
  2633. }
  2634. // UsersStoreCreateFuncCall is an object that describes an invocation of
  2635. // method Create on an instance of MockUsersStore.
  2636. type UsersStoreCreateFuncCall struct {
  2637. // Arg0 is the value of the 1st argument passed to this method
  2638. // invocation.
  2639. Arg0 context.Context
  2640. // Arg1 is the value of the 2nd argument passed to this method
  2641. // invocation.
  2642. Arg1 string
  2643. // Arg2 is the value of the 3rd argument passed to this method
  2644. // invocation.
  2645. Arg2 string
  2646. // Arg3 is the value of the 4th argument passed to this method
  2647. // invocation.
  2648. Arg3 db.CreateUserOptions
  2649. // Result0 is the value of the 1st result returned from this method
  2650. // invocation.
  2651. Result0 *db.User
  2652. // Result1 is the value of the 2nd result returned from this method
  2653. // invocation.
  2654. Result1 error
  2655. }
  2656. // Args returns an interface slice containing the arguments of this
  2657. // invocation.
  2658. func (c UsersStoreCreateFuncCall) Args() []interface{} {
  2659. return []interface{}{c.Arg0, c.Arg1, c.Arg2, c.Arg3}
  2660. }
  2661. // Results returns an interface slice containing the results of this
  2662. // invocation.
  2663. func (c UsersStoreCreateFuncCall) Results() []interface{} {
  2664. return []interface{}{c.Result0, c.Result1}
  2665. }
  2666. // UsersStoreDeleteCustomAvatarFunc describes the behavior when the
  2667. // DeleteCustomAvatar method of the parent MockUsersStore instance is
  2668. // invoked.
  2669. type UsersStoreDeleteCustomAvatarFunc struct {
  2670. defaultHook func(context.Context, int64) error
  2671. hooks []func(context.Context, int64) error
  2672. history []UsersStoreDeleteCustomAvatarFuncCall
  2673. mutex sync.Mutex
  2674. }
  2675. // DeleteCustomAvatar delegates to the next hook function in the queue and
  2676. // stores the parameter and result values of this invocation.
  2677. func (m *MockUsersStore) DeleteCustomAvatar(v0 context.Context, v1 int64) error {
  2678. r0 := m.DeleteCustomAvatarFunc.nextHook()(v0, v1)
  2679. m.DeleteCustomAvatarFunc.appendCall(UsersStoreDeleteCustomAvatarFuncCall{v0, v1, r0})
  2680. return r0
  2681. }
  2682. // SetDefaultHook sets function that is called when the DeleteCustomAvatar
  2683. // method of the parent MockUsersStore instance is invoked and the hook
  2684. // queue is empty.
  2685. func (f *UsersStoreDeleteCustomAvatarFunc) SetDefaultHook(hook func(context.Context, int64) error) {
  2686. f.defaultHook = hook
  2687. }
  2688. // PushHook adds a function to the end of hook queue. Each invocation of the
  2689. // DeleteCustomAvatar method of the parent MockUsersStore instance invokes
  2690. // the hook at the front of the queue and discards it. After the queue is
  2691. // empty, the default hook function is invoked for any future action.
  2692. func (f *UsersStoreDeleteCustomAvatarFunc) PushHook(hook func(context.Context, int64) error) {
  2693. f.mutex.Lock()
  2694. f.hooks = append(f.hooks, hook)
  2695. f.mutex.Unlock()
  2696. }
  2697. // SetDefaultReturn calls SetDefaultHook with a function that returns the
  2698. // given values.
  2699. func (f *UsersStoreDeleteCustomAvatarFunc) SetDefaultReturn(r0 error) {
  2700. f.SetDefaultHook(func(context.Context, int64) error {
  2701. return r0
  2702. })
  2703. }
  2704. // PushReturn calls PushHook with a function that returns the given values.
  2705. func (f *UsersStoreDeleteCustomAvatarFunc) PushReturn(r0 error) {
  2706. f.PushHook(func(context.Context, int64) error {
  2707. return r0
  2708. })
  2709. }
  2710. func (f *UsersStoreDeleteCustomAvatarFunc) nextHook() func(context.Context, int64) error {
  2711. f.mutex.Lock()
  2712. defer f.mutex.Unlock()
  2713. if len(f.hooks) == 0 {
  2714. return f.defaultHook
  2715. }
  2716. hook := f.hooks[0]
  2717. f.hooks = f.hooks[1:]
  2718. return hook
  2719. }
  2720. func (f *UsersStoreDeleteCustomAvatarFunc) appendCall(r0 UsersStoreDeleteCustomAvatarFuncCall) {
  2721. f.mutex.Lock()
  2722. f.history = append(f.history, r0)
  2723. f.mutex.Unlock()
  2724. }
  2725. // History returns a sequence of UsersStoreDeleteCustomAvatarFuncCall
  2726. // objects describing the invocations of this function.
  2727. func (f *UsersStoreDeleteCustomAvatarFunc) History() []UsersStoreDeleteCustomAvatarFuncCall {
  2728. f.mutex.Lock()
  2729. history := make([]UsersStoreDeleteCustomAvatarFuncCall, len(f.history))
  2730. copy(history, f.history)
  2731. f.mutex.Unlock()
  2732. return history
  2733. }
  2734. // UsersStoreDeleteCustomAvatarFuncCall is an object that describes an
  2735. // invocation of method DeleteCustomAvatar on an instance of MockUsersStore.
  2736. type UsersStoreDeleteCustomAvatarFuncCall struct {
  2737. // Arg0 is the value of the 1st argument passed to this method
  2738. // invocation.
  2739. Arg0 context.Context
  2740. // Arg1 is the value of the 2nd argument passed to this method
  2741. // invocation.
  2742. Arg1 int64
  2743. // Result0 is the value of the 1st result returned from this method
  2744. // invocation.
  2745. Result0 error
  2746. }
  2747. // Args returns an interface slice containing the arguments of this
  2748. // invocation.
  2749. func (c UsersStoreDeleteCustomAvatarFuncCall) Args() []interface{} {
  2750. return []interface{}{c.Arg0, c.Arg1}
  2751. }
  2752. // Results returns an interface slice containing the results of this
  2753. // invocation.
  2754. func (c UsersStoreDeleteCustomAvatarFuncCall) Results() []interface{} {
  2755. return []interface{}{c.Result0}
  2756. }
  2757. // UsersStoreGetByEmailFunc describes the behavior when the GetByEmail
  2758. // method of the parent MockUsersStore instance is invoked.
  2759. type UsersStoreGetByEmailFunc struct {
  2760. defaultHook func(context.Context, string) (*db.User, error)
  2761. hooks []func(context.Context, string) (*db.User, error)
  2762. history []UsersStoreGetByEmailFuncCall
  2763. mutex sync.Mutex
  2764. }
  2765. // GetByEmail delegates to the next hook function in the queue and stores
  2766. // the parameter and result values of this invocation.
  2767. func (m *MockUsersStore) GetByEmail(v0 context.Context, v1 string) (*db.User, error) {
  2768. r0, r1 := m.GetByEmailFunc.nextHook()(v0, v1)
  2769. m.GetByEmailFunc.appendCall(UsersStoreGetByEmailFuncCall{v0, v1, r0, r1})
  2770. return r0, r1
  2771. }
  2772. // SetDefaultHook sets function that is called when the GetByEmail method of
  2773. // the parent MockUsersStore instance is invoked and the hook queue is
  2774. // empty.
  2775. func (f *UsersStoreGetByEmailFunc) SetDefaultHook(hook func(context.Context, string) (*db.User, error)) {
  2776. f.defaultHook = hook
  2777. }
  2778. // PushHook adds a function to the end of hook queue. Each invocation of the
  2779. // GetByEmail method of the parent MockUsersStore instance invokes the hook
  2780. // at the front of the queue and discards it. After the queue is empty, the
  2781. // default hook function is invoked for any future action.
  2782. func (f *UsersStoreGetByEmailFunc) PushHook(hook func(context.Context, string) (*db.User, error)) {
  2783. f.mutex.Lock()
  2784. f.hooks = append(f.hooks, hook)
  2785. f.mutex.Unlock()
  2786. }
  2787. // SetDefaultReturn calls SetDefaultHook with a function that returns the
  2788. // given values.
  2789. func (f *UsersStoreGetByEmailFunc) SetDefaultReturn(r0 *db.User, r1 error) {
  2790. f.SetDefaultHook(func(context.Context, string) (*db.User, error) {
  2791. return r0, r1
  2792. })
  2793. }
  2794. // PushReturn calls PushHook with a function that returns the given values.
  2795. func (f *UsersStoreGetByEmailFunc) PushReturn(r0 *db.User, r1 error) {
  2796. f.PushHook(func(context.Context, string) (*db.User, error) {
  2797. return r0, r1
  2798. })
  2799. }
  2800. func (f *UsersStoreGetByEmailFunc) nextHook() func(context.Context, string) (*db.User, error) {
  2801. f.mutex.Lock()
  2802. defer f.mutex.Unlock()
  2803. if len(f.hooks) == 0 {
  2804. return f.defaultHook
  2805. }
  2806. hook := f.hooks[0]
  2807. f.hooks = f.hooks[1:]
  2808. return hook
  2809. }
  2810. func (f *UsersStoreGetByEmailFunc) appendCall(r0 UsersStoreGetByEmailFuncCall) {
  2811. f.mutex.Lock()
  2812. f.history = append(f.history, r0)
  2813. f.mutex.Unlock()
  2814. }
  2815. // History returns a sequence of UsersStoreGetByEmailFuncCall objects
  2816. // describing the invocations of this function.
  2817. func (f *UsersStoreGetByEmailFunc) History() []UsersStoreGetByEmailFuncCall {
  2818. f.mutex.Lock()
  2819. history := make([]UsersStoreGetByEmailFuncCall, len(f.history))
  2820. copy(history, f.history)
  2821. f.mutex.Unlock()
  2822. return history
  2823. }
  2824. // UsersStoreGetByEmailFuncCall is an object that describes an invocation of
  2825. // method GetByEmail on an instance of MockUsersStore.
  2826. type UsersStoreGetByEmailFuncCall struct {
  2827. // Arg0 is the value of the 1st argument passed to this method
  2828. // invocation.
  2829. Arg0 context.Context
  2830. // Arg1 is the value of the 2nd argument passed to this method
  2831. // invocation.
  2832. Arg1 string
  2833. // Result0 is the value of the 1st result returned from this method
  2834. // invocation.
  2835. Result0 *db.User
  2836. // Result1 is the value of the 2nd result returned from this method
  2837. // invocation.
  2838. Result1 error
  2839. }
  2840. // Args returns an interface slice containing the arguments of this
  2841. // invocation.
  2842. func (c UsersStoreGetByEmailFuncCall) Args() []interface{} {
  2843. return []interface{}{c.Arg0, c.Arg1}
  2844. }
  2845. // Results returns an interface slice containing the results of this
  2846. // invocation.
  2847. func (c UsersStoreGetByEmailFuncCall) Results() []interface{} {
  2848. return []interface{}{c.Result0, c.Result1}
  2849. }
  2850. // UsersStoreGetByIDFunc describes the behavior when the GetByID method of
  2851. // the parent MockUsersStore instance is invoked.
  2852. type UsersStoreGetByIDFunc struct {
  2853. defaultHook func(context.Context, int64) (*db.User, error)
  2854. hooks []func(context.Context, int64) (*db.User, error)
  2855. history []UsersStoreGetByIDFuncCall
  2856. mutex sync.Mutex
  2857. }
  2858. // GetByID delegates to the next hook function in the queue and stores the
  2859. // parameter and result values of this invocation.
  2860. func (m *MockUsersStore) GetByID(v0 context.Context, v1 int64) (*db.User, error) {
  2861. r0, r1 := m.GetByIDFunc.nextHook()(v0, v1)
  2862. m.GetByIDFunc.appendCall(UsersStoreGetByIDFuncCall{v0, v1, r0, r1})
  2863. return r0, r1
  2864. }
  2865. // SetDefaultHook sets function that is called when the GetByID method of
  2866. // the parent MockUsersStore instance is invoked and the hook queue is
  2867. // empty.
  2868. func (f *UsersStoreGetByIDFunc) SetDefaultHook(hook func(context.Context, int64) (*db.User, error)) {
  2869. f.defaultHook = hook
  2870. }
  2871. // PushHook adds a function to the end of hook queue. Each invocation of the
  2872. // GetByID method of the parent MockUsersStore instance invokes the hook at
  2873. // the front of the queue and discards it. After the queue is empty, the
  2874. // default hook function is invoked for any future action.
  2875. func (f *UsersStoreGetByIDFunc) PushHook(hook func(context.Context, int64) (*db.User, error)) {
  2876. f.mutex.Lock()
  2877. f.hooks = append(f.hooks, hook)
  2878. f.mutex.Unlock()
  2879. }
  2880. // SetDefaultReturn calls SetDefaultHook with a function that returns the
  2881. // given values.
  2882. func (f *UsersStoreGetByIDFunc) SetDefaultReturn(r0 *db.User, r1 error) {
  2883. f.SetDefaultHook(func(context.Context, int64) (*db.User, error) {
  2884. return r0, r1
  2885. })
  2886. }
  2887. // PushReturn calls PushHook with a function that returns the given values.
  2888. func (f *UsersStoreGetByIDFunc) PushReturn(r0 *db.User, r1 error) {
  2889. f.PushHook(func(context.Context, int64) (*db.User, error) {
  2890. return r0, r1
  2891. })
  2892. }
  2893. func (f *UsersStoreGetByIDFunc) nextHook() func(context.Context, int64) (*db.User, error) {
  2894. f.mutex.Lock()
  2895. defer f.mutex.Unlock()
  2896. if len(f.hooks) == 0 {
  2897. return f.defaultHook
  2898. }
  2899. hook := f.hooks[0]
  2900. f.hooks = f.hooks[1:]
  2901. return hook
  2902. }
  2903. func (f *UsersStoreGetByIDFunc) appendCall(r0 UsersStoreGetByIDFuncCall) {
  2904. f.mutex.Lock()
  2905. f.history = append(f.history, r0)
  2906. f.mutex.Unlock()
  2907. }
  2908. // History returns a sequence of UsersStoreGetByIDFuncCall objects
  2909. // describing the invocations of this function.
  2910. func (f *UsersStoreGetByIDFunc) History() []UsersStoreGetByIDFuncCall {
  2911. f.mutex.Lock()
  2912. history := make([]UsersStoreGetByIDFuncCall, len(f.history))
  2913. copy(history, f.history)
  2914. f.mutex.Unlock()
  2915. return history
  2916. }
  2917. // UsersStoreGetByIDFuncCall is an object that describes an invocation of
  2918. // method GetByID on an instance of MockUsersStore.
  2919. type UsersStoreGetByIDFuncCall struct {
  2920. // Arg0 is the value of the 1st argument passed to this method
  2921. // invocation.
  2922. Arg0 context.Context
  2923. // Arg1 is the value of the 2nd argument passed to this method
  2924. // invocation.
  2925. Arg1 int64
  2926. // Result0 is the value of the 1st result returned from this method
  2927. // invocation.
  2928. Result0 *db.User
  2929. // Result1 is the value of the 2nd result returned from this method
  2930. // invocation.
  2931. Result1 error
  2932. }
  2933. // Args returns an interface slice containing the arguments of this
  2934. // invocation.
  2935. func (c UsersStoreGetByIDFuncCall) Args() []interface{} {
  2936. return []interface{}{c.Arg0, c.Arg1}
  2937. }
  2938. // Results returns an interface slice containing the results of this
  2939. // invocation.
  2940. func (c UsersStoreGetByIDFuncCall) Results() []interface{} {
  2941. return []interface{}{c.Result0, c.Result1}
  2942. }
  2943. // UsersStoreGetByKeyIDFunc describes the behavior when the GetByKeyID
  2944. // method of the parent MockUsersStore instance is invoked.
  2945. type UsersStoreGetByKeyIDFunc struct {
  2946. defaultHook func(context.Context, int64) (*db.User, error)
  2947. hooks []func(context.Context, int64) (*db.User, error)
  2948. history []UsersStoreGetByKeyIDFuncCall
  2949. mutex sync.Mutex
  2950. }
  2951. // GetByKeyID delegates to the next hook function in the queue and stores
  2952. // the parameter and result values of this invocation.
  2953. func (m *MockUsersStore) GetByKeyID(v0 context.Context, v1 int64) (*db.User, error) {
  2954. r0, r1 := m.GetByKeyIDFunc.nextHook()(v0, v1)
  2955. m.GetByKeyIDFunc.appendCall(UsersStoreGetByKeyIDFuncCall{v0, v1, r0, r1})
  2956. return r0, r1
  2957. }
  2958. // SetDefaultHook sets function that is called when the GetByKeyID method of
  2959. // the parent MockUsersStore instance is invoked and the hook queue is
  2960. // empty.
  2961. func (f *UsersStoreGetByKeyIDFunc) SetDefaultHook(hook func(context.Context, int64) (*db.User, error)) {
  2962. f.defaultHook = hook
  2963. }
  2964. // PushHook adds a function to the end of hook queue. Each invocation of the
  2965. // GetByKeyID method of the parent MockUsersStore instance invokes the hook
  2966. // at the front of the queue and discards it. After the queue is empty, the
  2967. // default hook function is invoked for any future action.
  2968. func (f *UsersStoreGetByKeyIDFunc) PushHook(hook func(context.Context, int64) (*db.User, error)) {
  2969. f.mutex.Lock()
  2970. f.hooks = append(f.hooks, hook)
  2971. f.mutex.Unlock()
  2972. }
  2973. // SetDefaultReturn calls SetDefaultHook with a function that returns the
  2974. // given values.
  2975. func (f *UsersStoreGetByKeyIDFunc) SetDefaultReturn(r0 *db.User, r1 error) {
  2976. f.SetDefaultHook(func(context.Context, int64) (*db.User, error) {
  2977. return r0, r1
  2978. })
  2979. }
  2980. // PushReturn calls PushHook with a function that returns the given values.
  2981. func (f *UsersStoreGetByKeyIDFunc) PushReturn(r0 *db.User, r1 error) {
  2982. f.PushHook(func(context.Context, int64) (*db.User, error) {
  2983. return r0, r1
  2984. })
  2985. }
  2986. func (f *UsersStoreGetByKeyIDFunc) nextHook() func(context.Context, int64) (*db.User, error) {
  2987. f.mutex.Lock()
  2988. defer f.mutex.Unlock()
  2989. if len(f.hooks) == 0 {
  2990. return f.defaultHook
  2991. }
  2992. hook := f.hooks[0]
  2993. f.hooks = f.hooks[1:]
  2994. return hook
  2995. }
  2996. func (f *UsersStoreGetByKeyIDFunc) appendCall(r0 UsersStoreGetByKeyIDFuncCall) {
  2997. f.mutex.Lock()
  2998. f.history = append(f.history, r0)
  2999. f.mutex.Unlock()
  3000. }
  3001. // History returns a sequence of UsersStoreGetByKeyIDFuncCall objects
  3002. // describing the invocations of this function.
  3003. func (f *UsersStoreGetByKeyIDFunc) History() []UsersStoreGetByKeyIDFuncCall {
  3004. f.mutex.Lock()
  3005. history := make([]UsersStoreGetByKeyIDFuncCall, len(f.history))
  3006. copy(history, f.history)
  3007. f.mutex.Unlock()
  3008. return history
  3009. }
  3010. // UsersStoreGetByKeyIDFuncCall is an object that describes an invocation of
  3011. // method GetByKeyID on an instance of MockUsersStore.
  3012. type UsersStoreGetByKeyIDFuncCall struct {
  3013. // Arg0 is the value of the 1st argument passed to this method
  3014. // invocation.
  3015. Arg0 context.Context
  3016. // Arg1 is the value of the 2nd argument passed to this method
  3017. // invocation.
  3018. Arg1 int64
  3019. // Result0 is the value of the 1st result returned from this method
  3020. // invocation.
  3021. Result0 *db.User
  3022. // Result1 is the value of the 2nd result returned from this method
  3023. // invocation.
  3024. Result1 error
  3025. }
  3026. // Args returns an interface slice containing the arguments of this
  3027. // invocation.
  3028. func (c UsersStoreGetByKeyIDFuncCall) Args() []interface{} {
  3029. return []interface{}{c.Arg0, c.Arg1}
  3030. }
  3031. // Results returns an interface slice containing the results of this
  3032. // invocation.
  3033. func (c UsersStoreGetByKeyIDFuncCall) Results() []interface{} {
  3034. return []interface{}{c.Result0, c.Result1}
  3035. }
  3036. // UsersStoreGetByUsernameFunc describes the behavior when the GetByUsername
  3037. // method of the parent MockUsersStore instance is invoked.
  3038. type UsersStoreGetByUsernameFunc struct {
  3039. defaultHook func(context.Context, string) (*db.User, error)
  3040. hooks []func(context.Context, string) (*db.User, error)
  3041. history []UsersStoreGetByUsernameFuncCall
  3042. mutex sync.Mutex
  3043. }
  3044. // GetByUsername delegates to the next hook function in the queue and stores
  3045. // the parameter and result values of this invocation.
  3046. func (m *MockUsersStore) GetByUsername(v0 context.Context, v1 string) (*db.User, error) {
  3047. r0, r1 := m.GetByUsernameFunc.nextHook()(v0, v1)
  3048. m.GetByUsernameFunc.appendCall(UsersStoreGetByUsernameFuncCall{v0, v1, r0, r1})
  3049. return r0, r1
  3050. }
  3051. // SetDefaultHook sets function that is called when the GetByUsername method
  3052. // of the parent MockUsersStore instance is invoked and the hook queue is
  3053. // empty.
  3054. func (f *UsersStoreGetByUsernameFunc) SetDefaultHook(hook func(context.Context, string) (*db.User, error)) {
  3055. f.defaultHook = hook
  3056. }
  3057. // PushHook adds a function to the end of hook queue. Each invocation of the
  3058. // GetByUsername method of the parent MockUsersStore instance invokes the
  3059. // hook at the front of the queue and discards it. After the queue is empty,
  3060. // the default hook function is invoked for any future action.
  3061. func (f *UsersStoreGetByUsernameFunc) PushHook(hook func(context.Context, string) (*db.User, error)) {
  3062. f.mutex.Lock()
  3063. f.hooks = append(f.hooks, hook)
  3064. f.mutex.Unlock()
  3065. }
  3066. // SetDefaultReturn calls SetDefaultHook with a function that returns the
  3067. // given values.
  3068. func (f *UsersStoreGetByUsernameFunc) SetDefaultReturn(r0 *db.User, r1 error) {
  3069. f.SetDefaultHook(func(context.Context, string) (*db.User, error) {
  3070. return r0, r1
  3071. })
  3072. }
  3073. // PushReturn calls PushHook with a function that returns the given values.
  3074. func (f *UsersStoreGetByUsernameFunc) PushReturn(r0 *db.User, r1 error) {
  3075. f.PushHook(func(context.Context, string) (*db.User, error) {
  3076. return r0, r1
  3077. })
  3078. }
  3079. func (f *UsersStoreGetByUsernameFunc) nextHook() func(context.Context, string) (*db.User, error) {
  3080. f.mutex.Lock()
  3081. defer f.mutex.Unlock()
  3082. if len(f.hooks) == 0 {
  3083. return f.defaultHook
  3084. }
  3085. hook := f.hooks[0]
  3086. f.hooks = f.hooks[1:]
  3087. return hook
  3088. }
  3089. func (f *UsersStoreGetByUsernameFunc) appendCall(r0 UsersStoreGetByUsernameFuncCall) {
  3090. f.mutex.Lock()
  3091. f.history = append(f.history, r0)
  3092. f.mutex.Unlock()
  3093. }
  3094. // History returns a sequence of UsersStoreGetByUsernameFuncCall objects
  3095. // describing the invocations of this function.
  3096. func (f *UsersStoreGetByUsernameFunc) History() []UsersStoreGetByUsernameFuncCall {
  3097. f.mutex.Lock()
  3098. history := make([]UsersStoreGetByUsernameFuncCall, len(f.history))
  3099. copy(history, f.history)
  3100. f.mutex.Unlock()
  3101. return history
  3102. }
  3103. // UsersStoreGetByUsernameFuncCall is an object that describes an invocation
  3104. // of method GetByUsername on an instance of MockUsersStore.
  3105. type UsersStoreGetByUsernameFuncCall struct {
  3106. // Arg0 is the value of the 1st argument passed to this method
  3107. // invocation.
  3108. Arg0 context.Context
  3109. // Arg1 is the value of the 2nd argument passed to this method
  3110. // invocation.
  3111. Arg1 string
  3112. // Result0 is the value of the 1st result returned from this method
  3113. // invocation.
  3114. Result0 *db.User
  3115. // Result1 is the value of the 2nd result returned from this method
  3116. // invocation.
  3117. Result1 error
  3118. }
  3119. // Args returns an interface slice containing the arguments of this
  3120. // invocation.
  3121. func (c UsersStoreGetByUsernameFuncCall) Args() []interface{} {
  3122. return []interface{}{c.Arg0, c.Arg1}
  3123. }
  3124. // Results returns an interface slice containing the results of this
  3125. // invocation.
  3126. func (c UsersStoreGetByUsernameFuncCall) Results() []interface{} {
  3127. return []interface{}{c.Result0, c.Result1}
  3128. }
  3129. // UsersStoreHasForkedRepositoryFunc describes the behavior when the
  3130. // HasForkedRepository method of the parent MockUsersStore instance is
  3131. // invoked.
  3132. type UsersStoreHasForkedRepositoryFunc struct {
  3133. defaultHook func(context.Context, int64, int64) bool
  3134. hooks []func(context.Context, int64, int64) bool
  3135. history []UsersStoreHasForkedRepositoryFuncCall
  3136. mutex sync.Mutex
  3137. }
  3138. // HasForkedRepository delegates to the next hook function in the queue and
  3139. // stores the parameter and result values of this invocation.
  3140. func (m *MockUsersStore) HasForkedRepository(v0 context.Context, v1 int64, v2 int64) bool {
  3141. r0 := m.HasForkedRepositoryFunc.nextHook()(v0, v1, v2)
  3142. m.HasForkedRepositoryFunc.appendCall(UsersStoreHasForkedRepositoryFuncCall{v0, v1, v2, r0})
  3143. return r0
  3144. }
  3145. // SetDefaultHook sets function that is called when the HasForkedRepository
  3146. // method of the parent MockUsersStore instance is invoked and the hook
  3147. // queue is empty.
  3148. func (f *UsersStoreHasForkedRepositoryFunc) SetDefaultHook(hook func(context.Context, int64, int64) bool) {
  3149. f.defaultHook = hook
  3150. }
  3151. // PushHook adds a function to the end of hook queue. Each invocation of the
  3152. // HasForkedRepository method of the parent MockUsersStore instance invokes
  3153. // the hook at the front of the queue and discards it. After the queue is
  3154. // empty, the default hook function is invoked for any future action.
  3155. func (f *UsersStoreHasForkedRepositoryFunc) PushHook(hook func(context.Context, int64, int64) bool) {
  3156. f.mutex.Lock()
  3157. f.hooks = append(f.hooks, hook)
  3158. f.mutex.Unlock()
  3159. }
  3160. // SetDefaultReturn calls SetDefaultHook with a function that returns the
  3161. // given values.
  3162. func (f *UsersStoreHasForkedRepositoryFunc) SetDefaultReturn(r0 bool) {
  3163. f.SetDefaultHook(func(context.Context, int64, int64) bool {
  3164. return r0
  3165. })
  3166. }
  3167. // PushReturn calls PushHook with a function that returns the given values.
  3168. func (f *UsersStoreHasForkedRepositoryFunc) PushReturn(r0 bool) {
  3169. f.PushHook(func(context.Context, int64, int64) bool {
  3170. return r0
  3171. })
  3172. }
  3173. func (f *UsersStoreHasForkedRepositoryFunc) nextHook() func(context.Context, int64, int64) bool {
  3174. f.mutex.Lock()
  3175. defer f.mutex.Unlock()
  3176. if len(f.hooks) == 0 {
  3177. return f.defaultHook
  3178. }
  3179. hook := f.hooks[0]
  3180. f.hooks = f.hooks[1:]
  3181. return hook
  3182. }
  3183. func (f *UsersStoreHasForkedRepositoryFunc) appendCall(r0 UsersStoreHasForkedRepositoryFuncCall) {
  3184. f.mutex.Lock()
  3185. f.history = append(f.history, r0)
  3186. f.mutex.Unlock()
  3187. }
  3188. // History returns a sequence of UsersStoreHasForkedRepositoryFuncCall
  3189. // objects describing the invocations of this function.
  3190. func (f *UsersStoreHasForkedRepositoryFunc) History() []UsersStoreHasForkedRepositoryFuncCall {
  3191. f.mutex.Lock()
  3192. history := make([]UsersStoreHasForkedRepositoryFuncCall, len(f.history))
  3193. copy(history, f.history)
  3194. f.mutex.Unlock()
  3195. return history
  3196. }
  3197. // UsersStoreHasForkedRepositoryFuncCall is an object that describes an
  3198. // invocation of method HasForkedRepository on an instance of
  3199. // MockUsersStore.
  3200. type UsersStoreHasForkedRepositoryFuncCall struct {
  3201. // Arg0 is the value of the 1st argument passed to this method
  3202. // invocation.
  3203. Arg0 context.Context
  3204. // Arg1 is the value of the 2nd argument passed to this method
  3205. // invocation.
  3206. Arg1 int64
  3207. // Arg2 is the value of the 3rd argument passed to this method
  3208. // invocation.
  3209. Arg2 int64
  3210. // Result0 is the value of the 1st result returned from this method
  3211. // invocation.
  3212. Result0 bool
  3213. }
  3214. // Args returns an interface slice containing the arguments of this
  3215. // invocation.
  3216. func (c UsersStoreHasForkedRepositoryFuncCall) Args() []interface{} {
  3217. return []interface{}{c.Arg0, c.Arg1, c.Arg2}
  3218. }
  3219. // Results returns an interface slice containing the results of this
  3220. // invocation.
  3221. func (c UsersStoreHasForkedRepositoryFuncCall) Results() []interface{} {
  3222. return []interface{}{c.Result0}
  3223. }
  3224. // UsersStoreIsUsernameUsedFunc describes the behavior when the
  3225. // IsUsernameUsed method of the parent MockUsersStore instance is invoked.
  3226. type UsersStoreIsUsernameUsedFunc struct {
  3227. defaultHook func(context.Context, string, int64) bool
  3228. hooks []func(context.Context, string, int64) bool
  3229. history []UsersStoreIsUsernameUsedFuncCall
  3230. mutex sync.Mutex
  3231. }
  3232. // IsUsernameUsed delegates to the next hook function in the queue and
  3233. // stores the parameter and result values of this invocation.
  3234. func (m *MockUsersStore) IsUsernameUsed(v0 context.Context, v1 string, v2 int64) bool {
  3235. r0 := m.IsUsernameUsedFunc.nextHook()(v0, v1, v2)
  3236. m.IsUsernameUsedFunc.appendCall(UsersStoreIsUsernameUsedFuncCall{v0, v1, v2, r0})
  3237. return r0
  3238. }
  3239. // SetDefaultHook sets function that is called when the IsUsernameUsed
  3240. // method of the parent MockUsersStore instance is invoked and the hook
  3241. // queue is empty.
  3242. func (f *UsersStoreIsUsernameUsedFunc) SetDefaultHook(hook func(context.Context, string, int64) bool) {
  3243. f.defaultHook = hook
  3244. }
  3245. // PushHook adds a function to the end of hook queue. Each invocation of the
  3246. // IsUsernameUsed method of the parent MockUsersStore instance invokes the
  3247. // hook at the front of the queue and discards it. After the queue is empty,
  3248. // the default hook function is invoked for any future action.
  3249. func (f *UsersStoreIsUsernameUsedFunc) PushHook(hook func(context.Context, string, int64) bool) {
  3250. f.mutex.Lock()
  3251. f.hooks = append(f.hooks, hook)
  3252. f.mutex.Unlock()
  3253. }
  3254. // SetDefaultReturn calls SetDefaultHook with a function that returns the
  3255. // given values.
  3256. func (f *UsersStoreIsUsernameUsedFunc) SetDefaultReturn(r0 bool) {
  3257. f.SetDefaultHook(func(context.Context, string, int64) bool {
  3258. return r0
  3259. })
  3260. }
  3261. // PushReturn calls PushHook with a function that returns the given values.
  3262. func (f *UsersStoreIsUsernameUsedFunc) PushReturn(r0 bool) {
  3263. f.PushHook(func(context.Context, string, int64) bool {
  3264. return r0
  3265. })
  3266. }
  3267. func (f *UsersStoreIsUsernameUsedFunc) nextHook() func(context.Context, string, int64) bool {
  3268. f.mutex.Lock()
  3269. defer f.mutex.Unlock()
  3270. if len(f.hooks) == 0 {
  3271. return f.defaultHook
  3272. }
  3273. hook := f.hooks[0]
  3274. f.hooks = f.hooks[1:]
  3275. return hook
  3276. }
  3277. func (f *UsersStoreIsUsernameUsedFunc) appendCall(r0 UsersStoreIsUsernameUsedFuncCall) {
  3278. f.mutex.Lock()
  3279. f.history = append(f.history, r0)
  3280. f.mutex.Unlock()
  3281. }
  3282. // History returns a sequence of UsersStoreIsUsernameUsedFuncCall objects
  3283. // describing the invocations of this function.
  3284. func (f *UsersStoreIsUsernameUsedFunc) History() []UsersStoreIsUsernameUsedFuncCall {
  3285. f.mutex.Lock()
  3286. history := make([]UsersStoreIsUsernameUsedFuncCall, len(f.history))
  3287. copy(history, f.history)
  3288. f.mutex.Unlock()
  3289. return history
  3290. }
  3291. // UsersStoreIsUsernameUsedFuncCall is an object that describes an
  3292. // invocation of method IsUsernameUsed on an instance of MockUsersStore.
  3293. type UsersStoreIsUsernameUsedFuncCall struct {
  3294. // Arg0 is the value of the 1st argument passed to this method
  3295. // invocation.
  3296. Arg0 context.Context
  3297. // Arg1 is the value of the 2nd argument passed to this method
  3298. // invocation.
  3299. Arg1 string
  3300. // Arg2 is the value of the 3rd argument passed to this method
  3301. // invocation.
  3302. Arg2 int64
  3303. // Result0 is the value of the 1st result returned from this method
  3304. // invocation.
  3305. Result0 bool
  3306. }
  3307. // Args returns an interface slice containing the arguments of this
  3308. // invocation.
  3309. func (c UsersStoreIsUsernameUsedFuncCall) Args() []interface{} {
  3310. return []interface{}{c.Arg0, c.Arg1, c.Arg2}
  3311. }
  3312. // Results returns an interface slice containing the results of this
  3313. // invocation.
  3314. func (c UsersStoreIsUsernameUsedFuncCall) Results() []interface{} {
  3315. return []interface{}{c.Result0}
  3316. }
  3317. // UsersStoreListFunc describes the behavior when the List method of the
  3318. // parent MockUsersStore instance is invoked.
  3319. type UsersStoreListFunc struct {
  3320. defaultHook func(context.Context, int, int) ([]*db.User, error)
  3321. hooks []func(context.Context, int, int) ([]*db.User, error)
  3322. history []UsersStoreListFuncCall
  3323. mutex sync.Mutex
  3324. }
  3325. // List delegates to the next hook function in the queue and stores the
  3326. // parameter and result values of this invocation.
  3327. func (m *MockUsersStore) List(v0 context.Context, v1 int, v2 int) ([]*db.User, error) {
  3328. r0, r1 := m.ListFunc.nextHook()(v0, v1, v2)
  3329. m.ListFunc.appendCall(UsersStoreListFuncCall{v0, v1, v2, r0, r1})
  3330. return r0, r1
  3331. }
  3332. // SetDefaultHook sets function that is called when the List method of the
  3333. // parent MockUsersStore instance is invoked and the hook queue is empty.
  3334. func (f *UsersStoreListFunc) SetDefaultHook(hook func(context.Context, int, int) ([]*db.User, error)) {
  3335. f.defaultHook = hook
  3336. }
  3337. // PushHook adds a function to the end of hook queue. Each invocation of the
  3338. // List method of the parent MockUsersStore instance invokes the hook at the
  3339. // front of the queue and discards it. After the queue is empty, the default
  3340. // hook function is invoked for any future action.
  3341. func (f *UsersStoreListFunc) PushHook(hook func(context.Context, int, int) ([]*db.User, error)) {
  3342. f.mutex.Lock()
  3343. f.hooks = append(f.hooks, hook)
  3344. f.mutex.Unlock()
  3345. }
  3346. // SetDefaultReturn calls SetDefaultHook with a function that returns the
  3347. // given values.
  3348. func (f *UsersStoreListFunc) SetDefaultReturn(r0 []*db.User, r1 error) {
  3349. f.SetDefaultHook(func(context.Context, int, int) ([]*db.User, error) {
  3350. return r0, r1
  3351. })
  3352. }
  3353. // PushReturn calls PushHook with a function that returns the given values.
  3354. func (f *UsersStoreListFunc) PushReturn(r0 []*db.User, r1 error) {
  3355. f.PushHook(func(context.Context, int, int) ([]*db.User, error) {
  3356. return r0, r1
  3357. })
  3358. }
  3359. func (f *UsersStoreListFunc) nextHook() func(context.Context, int, int) ([]*db.User, error) {
  3360. f.mutex.Lock()
  3361. defer f.mutex.Unlock()
  3362. if len(f.hooks) == 0 {
  3363. return f.defaultHook
  3364. }
  3365. hook := f.hooks[0]
  3366. f.hooks = f.hooks[1:]
  3367. return hook
  3368. }
  3369. func (f *UsersStoreListFunc) appendCall(r0 UsersStoreListFuncCall) {
  3370. f.mutex.Lock()
  3371. f.history = append(f.history, r0)
  3372. f.mutex.Unlock()
  3373. }
  3374. // History returns a sequence of UsersStoreListFuncCall objects describing
  3375. // the invocations of this function.
  3376. func (f *UsersStoreListFunc) History() []UsersStoreListFuncCall {
  3377. f.mutex.Lock()
  3378. history := make([]UsersStoreListFuncCall, len(f.history))
  3379. copy(history, f.history)
  3380. f.mutex.Unlock()
  3381. return history
  3382. }
  3383. // UsersStoreListFuncCall is an object that describes an invocation of
  3384. // method List on an instance of MockUsersStore.
  3385. type UsersStoreListFuncCall struct {
  3386. // Arg0 is the value of the 1st argument passed to this method
  3387. // invocation.
  3388. Arg0 context.Context
  3389. // Arg1 is the value of the 2nd argument passed to this method
  3390. // invocation.
  3391. Arg1 int
  3392. // Arg2 is the value of the 3rd argument passed to this method
  3393. // invocation.
  3394. Arg2 int
  3395. // Result0 is the value of the 1st result returned from this method
  3396. // invocation.
  3397. Result0 []*db.User
  3398. // Result1 is the value of the 2nd result returned from this method
  3399. // invocation.
  3400. Result1 error
  3401. }
  3402. // Args returns an interface slice containing the arguments of this
  3403. // invocation.
  3404. func (c UsersStoreListFuncCall) Args() []interface{} {
  3405. return []interface{}{c.Arg0, c.Arg1, c.Arg2}
  3406. }
  3407. // Results returns an interface slice containing the results of this
  3408. // invocation.
  3409. func (c UsersStoreListFuncCall) Results() []interface{} {
  3410. return []interface{}{c.Result0, c.Result1}
  3411. }
  3412. // UsersStoreListFollowersFunc describes the behavior when the ListFollowers
  3413. // method of the parent MockUsersStore instance is invoked.
  3414. type UsersStoreListFollowersFunc struct {
  3415. defaultHook func(context.Context, int64, int, int) ([]*db.User, error)
  3416. hooks []func(context.Context, int64, int, int) ([]*db.User, error)
  3417. history []UsersStoreListFollowersFuncCall
  3418. mutex sync.Mutex
  3419. }
  3420. // ListFollowers delegates to the next hook function in the queue and stores
  3421. // the parameter and result values of this invocation.
  3422. func (m *MockUsersStore) ListFollowers(v0 context.Context, v1 int64, v2 int, v3 int) ([]*db.User, error) {
  3423. r0, r1 := m.ListFollowersFunc.nextHook()(v0, v1, v2, v3)
  3424. m.ListFollowersFunc.appendCall(UsersStoreListFollowersFuncCall{v0, v1, v2, v3, r0, r1})
  3425. return r0, r1
  3426. }
  3427. // SetDefaultHook sets function that is called when the ListFollowers method
  3428. // of the parent MockUsersStore instance is invoked and the hook queue is
  3429. // empty.
  3430. func (f *UsersStoreListFollowersFunc) SetDefaultHook(hook func(context.Context, int64, int, int) ([]*db.User, error)) {
  3431. f.defaultHook = hook
  3432. }
  3433. // PushHook adds a function to the end of hook queue. Each invocation of the
  3434. // ListFollowers method of the parent MockUsersStore instance invokes the
  3435. // hook at the front of the queue and discards it. After the queue is empty,
  3436. // the default hook function is invoked for any future action.
  3437. func (f *UsersStoreListFollowersFunc) PushHook(hook func(context.Context, int64, int, int) ([]*db.User, error)) {
  3438. f.mutex.Lock()
  3439. f.hooks = append(f.hooks, hook)
  3440. f.mutex.Unlock()
  3441. }
  3442. // SetDefaultReturn calls SetDefaultHook with a function that returns the
  3443. // given values.
  3444. func (f *UsersStoreListFollowersFunc) SetDefaultReturn(r0 []*db.User, r1 error) {
  3445. f.SetDefaultHook(func(context.Context, int64, int, int) ([]*db.User, error) {
  3446. return r0, r1
  3447. })
  3448. }
  3449. // PushReturn calls PushHook with a function that returns the given values.
  3450. func (f *UsersStoreListFollowersFunc) PushReturn(r0 []*db.User, r1 error) {
  3451. f.PushHook(func(context.Context, int64, int, int) ([]*db.User, error) {
  3452. return r0, r1
  3453. })
  3454. }
  3455. func (f *UsersStoreListFollowersFunc) nextHook() func(context.Context, int64, int, int) ([]*db.User, error) {
  3456. f.mutex.Lock()
  3457. defer f.mutex.Unlock()
  3458. if len(f.hooks) == 0 {
  3459. return f.defaultHook
  3460. }
  3461. hook := f.hooks[0]
  3462. f.hooks = f.hooks[1:]
  3463. return hook
  3464. }
  3465. func (f *UsersStoreListFollowersFunc) appendCall(r0 UsersStoreListFollowersFuncCall) {
  3466. f.mutex.Lock()
  3467. f.history = append(f.history, r0)
  3468. f.mutex.Unlock()
  3469. }
  3470. // History returns a sequence of UsersStoreListFollowersFuncCall objects
  3471. // describing the invocations of this function.
  3472. func (f *UsersStoreListFollowersFunc) History() []UsersStoreListFollowersFuncCall {
  3473. f.mutex.Lock()
  3474. history := make([]UsersStoreListFollowersFuncCall, len(f.history))
  3475. copy(history, f.history)
  3476. f.mutex.Unlock()
  3477. return history
  3478. }
  3479. // UsersStoreListFollowersFuncCall is an object that describes an invocation
  3480. // of method ListFollowers on an instance of MockUsersStore.
  3481. type UsersStoreListFollowersFuncCall struct {
  3482. // Arg0 is the value of the 1st argument passed to this method
  3483. // invocation.
  3484. Arg0 context.Context
  3485. // Arg1 is the value of the 2nd argument passed to this method
  3486. // invocation.
  3487. Arg1 int64
  3488. // Arg2 is the value of the 3rd argument passed to this method
  3489. // invocation.
  3490. Arg2 int
  3491. // Arg3 is the value of the 4th argument passed to this method
  3492. // invocation.
  3493. Arg3 int
  3494. // Result0 is the value of the 1st result returned from this method
  3495. // invocation.
  3496. Result0 []*db.User
  3497. // Result1 is the value of the 2nd result returned from this method
  3498. // invocation.
  3499. Result1 error
  3500. }
  3501. // Args returns an interface slice containing the arguments of this
  3502. // invocation.
  3503. func (c UsersStoreListFollowersFuncCall) Args() []interface{} {
  3504. return []interface{}{c.Arg0, c.Arg1, c.Arg2, c.Arg3}
  3505. }
  3506. // Results returns an interface slice containing the results of this
  3507. // invocation.
  3508. func (c UsersStoreListFollowersFuncCall) Results() []interface{} {
  3509. return []interface{}{c.Result0, c.Result1}
  3510. }
  3511. // UsersStoreListFollowingsFunc describes the behavior when the
  3512. // ListFollowings method of the parent MockUsersStore instance is invoked.
  3513. type UsersStoreListFollowingsFunc struct {
  3514. defaultHook func(context.Context, int64, int, int) ([]*db.User, error)
  3515. hooks []func(context.Context, int64, int, int) ([]*db.User, error)
  3516. history []UsersStoreListFollowingsFuncCall
  3517. mutex sync.Mutex
  3518. }
  3519. // ListFollowings delegates to the next hook function in the queue and
  3520. // stores the parameter and result values of this invocation.
  3521. func (m *MockUsersStore) ListFollowings(v0 context.Context, v1 int64, v2 int, v3 int) ([]*db.User, error) {
  3522. r0, r1 := m.ListFollowingsFunc.nextHook()(v0, v1, v2, v3)
  3523. m.ListFollowingsFunc.appendCall(UsersStoreListFollowingsFuncCall{v0, v1, v2, v3, r0, r1})
  3524. return r0, r1
  3525. }
  3526. // SetDefaultHook sets function that is called when the ListFollowings
  3527. // method of the parent MockUsersStore instance is invoked and the hook
  3528. // queue is empty.
  3529. func (f *UsersStoreListFollowingsFunc) SetDefaultHook(hook func(context.Context, int64, int, int) ([]*db.User, error)) {
  3530. f.defaultHook = hook
  3531. }
  3532. // PushHook adds a function to the end of hook queue. Each invocation of the
  3533. // ListFollowings method of the parent MockUsersStore instance invokes the
  3534. // hook at the front of the queue and discards it. After the queue is empty,
  3535. // the default hook function is invoked for any future action.
  3536. func (f *UsersStoreListFollowingsFunc) PushHook(hook func(context.Context, int64, int, int) ([]*db.User, error)) {
  3537. f.mutex.Lock()
  3538. f.hooks = append(f.hooks, hook)
  3539. f.mutex.Unlock()
  3540. }
  3541. // SetDefaultReturn calls SetDefaultHook with a function that returns the
  3542. // given values.
  3543. func (f *UsersStoreListFollowingsFunc) SetDefaultReturn(r0 []*db.User, r1 error) {
  3544. f.SetDefaultHook(func(context.Context, int64, int, int) ([]*db.User, error) {
  3545. return r0, r1
  3546. })
  3547. }
  3548. // PushReturn calls PushHook with a function that returns the given values.
  3549. func (f *UsersStoreListFollowingsFunc) PushReturn(r0 []*db.User, r1 error) {
  3550. f.PushHook(func(context.Context, int64, int, int) ([]*db.User, error) {
  3551. return r0, r1
  3552. })
  3553. }
  3554. func (f *UsersStoreListFollowingsFunc) nextHook() func(context.Context, int64, int, int) ([]*db.User, error) {
  3555. f.mutex.Lock()
  3556. defer f.mutex.Unlock()
  3557. if len(f.hooks) == 0 {
  3558. return f.defaultHook
  3559. }
  3560. hook := f.hooks[0]
  3561. f.hooks = f.hooks[1:]
  3562. return hook
  3563. }
  3564. func (f *UsersStoreListFollowingsFunc) appendCall(r0 UsersStoreListFollowingsFuncCall) {
  3565. f.mutex.Lock()
  3566. f.history = append(f.history, r0)
  3567. f.mutex.Unlock()
  3568. }
  3569. // History returns a sequence of UsersStoreListFollowingsFuncCall objects
  3570. // describing the invocations of this function.
  3571. func (f *UsersStoreListFollowingsFunc) History() []UsersStoreListFollowingsFuncCall {
  3572. f.mutex.Lock()
  3573. history := make([]UsersStoreListFollowingsFuncCall, len(f.history))
  3574. copy(history, f.history)
  3575. f.mutex.Unlock()
  3576. return history
  3577. }
  3578. // UsersStoreListFollowingsFuncCall is an object that describes an
  3579. // invocation of method ListFollowings on an instance of MockUsersStore.
  3580. type UsersStoreListFollowingsFuncCall struct {
  3581. // Arg0 is the value of the 1st argument passed to this method
  3582. // invocation.
  3583. Arg0 context.Context
  3584. // Arg1 is the value of the 2nd argument passed to this method
  3585. // invocation.
  3586. Arg1 int64
  3587. // Arg2 is the value of the 3rd argument passed to this method
  3588. // invocation.
  3589. Arg2 int
  3590. // Arg3 is the value of the 4th argument passed to this method
  3591. // invocation.
  3592. Arg3 int
  3593. // Result0 is the value of the 1st result returned from this method
  3594. // invocation.
  3595. Result0 []*db.User
  3596. // Result1 is the value of the 2nd result returned from this method
  3597. // invocation.
  3598. Result1 error
  3599. }
  3600. // Args returns an interface slice containing the arguments of this
  3601. // invocation.
  3602. func (c UsersStoreListFollowingsFuncCall) Args() []interface{} {
  3603. return []interface{}{c.Arg0, c.Arg1, c.Arg2, c.Arg3}
  3604. }
  3605. // Results returns an interface slice containing the results of this
  3606. // invocation.
  3607. func (c UsersStoreListFollowingsFuncCall) Results() []interface{} {
  3608. return []interface{}{c.Result0, c.Result1}
  3609. }
  3610. // UsersStoreUpdateFunc describes the behavior when the Update method of the
  3611. // parent MockUsersStore instance is invoked.
  3612. type UsersStoreUpdateFunc struct {
  3613. defaultHook func(context.Context, int64, db.UpdateUserOptions) error
  3614. hooks []func(context.Context, int64, db.UpdateUserOptions) error
  3615. history []UsersStoreUpdateFuncCall
  3616. mutex sync.Mutex
  3617. }
  3618. // Update delegates to the next hook function in the queue and stores the
  3619. // parameter and result values of this invocation.
  3620. func (m *MockUsersStore) Update(v0 context.Context, v1 int64, v2 db.UpdateUserOptions) error {
  3621. r0 := m.UpdateFunc.nextHook()(v0, v1, v2)
  3622. m.UpdateFunc.appendCall(UsersStoreUpdateFuncCall{v0, v1, v2, r0})
  3623. return r0
  3624. }
  3625. // SetDefaultHook sets function that is called when the Update method of the
  3626. // parent MockUsersStore instance is invoked and the hook queue is empty.
  3627. func (f *UsersStoreUpdateFunc) SetDefaultHook(hook func(context.Context, int64, db.UpdateUserOptions) error) {
  3628. f.defaultHook = hook
  3629. }
  3630. // PushHook adds a function to the end of hook queue. Each invocation of the
  3631. // Update method of the parent MockUsersStore instance invokes the hook at
  3632. // the front of the queue and discards it. After the queue is empty, the
  3633. // default hook function is invoked for any future action.
  3634. func (f *UsersStoreUpdateFunc) PushHook(hook func(context.Context, int64, db.UpdateUserOptions) error) {
  3635. f.mutex.Lock()
  3636. f.hooks = append(f.hooks, hook)
  3637. f.mutex.Unlock()
  3638. }
  3639. // SetDefaultReturn calls SetDefaultHook with a function that returns the
  3640. // given values.
  3641. func (f *UsersStoreUpdateFunc) SetDefaultReturn(r0 error) {
  3642. f.SetDefaultHook(func(context.Context, int64, db.UpdateUserOptions) error {
  3643. return r0
  3644. })
  3645. }
  3646. // PushReturn calls PushHook with a function that returns the given values.
  3647. func (f *UsersStoreUpdateFunc) PushReturn(r0 error) {
  3648. f.PushHook(func(context.Context, int64, db.UpdateUserOptions) error {
  3649. return r0
  3650. })
  3651. }
  3652. func (f *UsersStoreUpdateFunc) nextHook() func(context.Context, int64, db.UpdateUserOptions) error {
  3653. f.mutex.Lock()
  3654. defer f.mutex.Unlock()
  3655. if len(f.hooks) == 0 {
  3656. return f.defaultHook
  3657. }
  3658. hook := f.hooks[0]
  3659. f.hooks = f.hooks[1:]
  3660. return hook
  3661. }
  3662. func (f *UsersStoreUpdateFunc) appendCall(r0 UsersStoreUpdateFuncCall) {
  3663. f.mutex.Lock()
  3664. f.history = append(f.history, r0)
  3665. f.mutex.Unlock()
  3666. }
  3667. // History returns a sequence of UsersStoreUpdateFuncCall objects describing
  3668. // the invocations of this function.
  3669. func (f *UsersStoreUpdateFunc) History() []UsersStoreUpdateFuncCall {
  3670. f.mutex.Lock()
  3671. history := make([]UsersStoreUpdateFuncCall, len(f.history))
  3672. copy(history, f.history)
  3673. f.mutex.Unlock()
  3674. return history
  3675. }
  3676. // UsersStoreUpdateFuncCall is an object that describes an invocation of
  3677. // method Update on an instance of MockUsersStore.
  3678. type UsersStoreUpdateFuncCall struct {
  3679. // Arg0 is the value of the 1st argument passed to this method
  3680. // invocation.
  3681. Arg0 context.Context
  3682. // Arg1 is the value of the 2nd argument passed to this method
  3683. // invocation.
  3684. Arg1 int64
  3685. // Arg2 is the value of the 3rd argument passed to this method
  3686. // invocation.
  3687. Arg2 db.UpdateUserOptions
  3688. // Result0 is the value of the 1st result returned from this method
  3689. // invocation.
  3690. Result0 error
  3691. }
  3692. // Args returns an interface slice containing the arguments of this
  3693. // invocation.
  3694. func (c UsersStoreUpdateFuncCall) Args() []interface{} {
  3695. return []interface{}{c.Arg0, c.Arg1, c.Arg2}
  3696. }
  3697. // Results returns an interface slice containing the results of this
  3698. // invocation.
  3699. func (c UsersStoreUpdateFuncCall) Results() []interface{} {
  3700. return []interface{}{c.Result0}
  3701. }
  3702. // UsersStoreUseCustomAvatarFunc describes the behavior when the
  3703. // UseCustomAvatar method of the parent MockUsersStore instance is invoked.
  3704. type UsersStoreUseCustomAvatarFunc struct {
  3705. defaultHook func(context.Context, int64, []byte) error
  3706. hooks []func(context.Context, int64, []byte) error
  3707. history []UsersStoreUseCustomAvatarFuncCall
  3708. mutex sync.Mutex
  3709. }
  3710. // UseCustomAvatar delegates to the next hook function in the queue and
  3711. // stores the parameter and result values of this invocation.
  3712. func (m *MockUsersStore) UseCustomAvatar(v0 context.Context, v1 int64, v2 []byte) error {
  3713. r0 := m.UseCustomAvatarFunc.nextHook()(v0, v1, v2)
  3714. m.UseCustomAvatarFunc.appendCall(UsersStoreUseCustomAvatarFuncCall{v0, v1, v2, r0})
  3715. return r0
  3716. }
  3717. // SetDefaultHook sets function that is called when the UseCustomAvatar
  3718. // method of the parent MockUsersStore instance is invoked and the hook
  3719. // queue is empty.
  3720. func (f *UsersStoreUseCustomAvatarFunc) SetDefaultHook(hook func(context.Context, int64, []byte) error) {
  3721. f.defaultHook = hook
  3722. }
  3723. // PushHook adds a function to the end of hook queue. Each invocation of the
  3724. // UseCustomAvatar method of the parent MockUsersStore instance invokes the
  3725. // hook at the front of the queue and discards it. After the queue is empty,
  3726. // the default hook function is invoked for any future action.
  3727. func (f *UsersStoreUseCustomAvatarFunc) PushHook(hook func(context.Context, int64, []byte) error) {
  3728. f.mutex.Lock()
  3729. f.hooks = append(f.hooks, hook)
  3730. f.mutex.Unlock()
  3731. }
  3732. // SetDefaultReturn calls SetDefaultHook with a function that returns the
  3733. // given values.
  3734. func (f *UsersStoreUseCustomAvatarFunc) SetDefaultReturn(r0 error) {
  3735. f.SetDefaultHook(func(context.Context, int64, []byte) error {
  3736. return r0
  3737. })
  3738. }
  3739. // PushReturn calls PushHook with a function that returns the given values.
  3740. func (f *UsersStoreUseCustomAvatarFunc) PushReturn(r0 error) {
  3741. f.PushHook(func(context.Context, int64, []byte) error {
  3742. return r0
  3743. })
  3744. }
  3745. func (f *UsersStoreUseCustomAvatarFunc) nextHook() func(context.Context, int64, []byte) error {
  3746. f.mutex.Lock()
  3747. defer f.mutex.Unlock()
  3748. if len(f.hooks) == 0 {
  3749. return f.defaultHook
  3750. }
  3751. hook := f.hooks[0]
  3752. f.hooks = f.hooks[1:]
  3753. return hook
  3754. }
  3755. func (f *UsersStoreUseCustomAvatarFunc) appendCall(r0 UsersStoreUseCustomAvatarFuncCall) {
  3756. f.mutex.Lock()
  3757. f.history = append(f.history, r0)
  3758. f.mutex.Unlock()
  3759. }
  3760. // History returns a sequence of UsersStoreUseCustomAvatarFuncCall objects
  3761. // describing the invocations of this function.
  3762. func (f *UsersStoreUseCustomAvatarFunc) History() []UsersStoreUseCustomAvatarFuncCall {
  3763. f.mutex.Lock()
  3764. history := make([]UsersStoreUseCustomAvatarFuncCall, len(f.history))
  3765. copy(history, f.history)
  3766. f.mutex.Unlock()
  3767. return history
  3768. }
  3769. // UsersStoreUseCustomAvatarFuncCall is an object that describes an
  3770. // invocation of method UseCustomAvatar on an instance of MockUsersStore.
  3771. type UsersStoreUseCustomAvatarFuncCall struct {
  3772. // Arg0 is the value of the 1st argument passed to this method
  3773. // invocation.
  3774. Arg0 context.Context
  3775. // Arg1 is the value of the 2nd argument passed to this method
  3776. // invocation.
  3777. Arg1 int64
  3778. // Arg2 is the value of the 3rd argument passed to this method
  3779. // invocation.
  3780. Arg2 []byte
  3781. // Result0 is the value of the 1st result returned from this method
  3782. // invocation.
  3783. Result0 error
  3784. }
  3785. // Args returns an interface slice containing the arguments of this
  3786. // invocation.
  3787. func (c UsersStoreUseCustomAvatarFuncCall) Args() []interface{} {
  3788. return []interface{}{c.Arg0, c.Arg1, c.Arg2}
  3789. }
  3790. // Results returns an interface slice containing the results of this
  3791. // invocation.
  3792. func (c UsersStoreUseCustomAvatarFuncCall) Results() []interface{} {
  3793. return []interface{}{c.Result0}
  3794. }