mocks_test.go 138 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067
  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. // GetByUsernameFunc is an instance of a mock function object
  2037. // controlling the behavior of the method GetByUsername.
  2038. GetByUsernameFunc *UsersStoreGetByUsernameFunc
  2039. // HasForkedRepositoryFunc is an instance of a mock function object
  2040. // controlling the behavior of the method HasForkedRepository.
  2041. HasForkedRepositoryFunc *UsersStoreHasForkedRepositoryFunc
  2042. // IsUsernameUsedFunc is an instance of a mock function object
  2043. // controlling the behavior of the method IsUsernameUsed.
  2044. IsUsernameUsedFunc *UsersStoreIsUsernameUsedFunc
  2045. // ListFunc is an instance of a mock function object controlling the
  2046. // behavior of the method List.
  2047. ListFunc *UsersStoreListFunc
  2048. // ListFollowersFunc is an instance of a mock function object
  2049. // controlling the behavior of the method ListFollowers.
  2050. ListFollowersFunc *UsersStoreListFollowersFunc
  2051. // ListFollowingsFunc is an instance of a mock function object
  2052. // controlling the behavior of the method ListFollowings.
  2053. ListFollowingsFunc *UsersStoreListFollowingsFunc
  2054. // UseCustomAvatarFunc is an instance of a mock function object
  2055. // controlling the behavior of the method UseCustomAvatar.
  2056. UseCustomAvatarFunc *UsersStoreUseCustomAvatarFunc
  2057. }
  2058. // NewMockUsersStore creates a new mock of the UsersStore interface. All
  2059. // methods return zero values for all results, unless overwritten.
  2060. func NewMockUsersStore() *MockUsersStore {
  2061. return &MockUsersStore{
  2062. AuthenticateFunc: &UsersStoreAuthenticateFunc{
  2063. defaultHook: func(context.Context, string, string, int64) (r0 *db.User, r1 error) {
  2064. return
  2065. },
  2066. },
  2067. ChangeUsernameFunc: &UsersStoreChangeUsernameFunc{
  2068. defaultHook: func(context.Context, int64, string) (r0 error) {
  2069. return
  2070. },
  2071. },
  2072. CountFunc: &UsersStoreCountFunc{
  2073. defaultHook: func(context.Context) (r0 int64) {
  2074. return
  2075. },
  2076. },
  2077. CreateFunc: &UsersStoreCreateFunc{
  2078. defaultHook: func(context.Context, string, string, db.CreateUserOptions) (r0 *db.User, r1 error) {
  2079. return
  2080. },
  2081. },
  2082. DeleteCustomAvatarFunc: &UsersStoreDeleteCustomAvatarFunc{
  2083. defaultHook: func(context.Context, int64) (r0 error) {
  2084. return
  2085. },
  2086. },
  2087. GetByEmailFunc: &UsersStoreGetByEmailFunc{
  2088. defaultHook: func(context.Context, string) (r0 *db.User, r1 error) {
  2089. return
  2090. },
  2091. },
  2092. GetByIDFunc: &UsersStoreGetByIDFunc{
  2093. defaultHook: func(context.Context, int64) (r0 *db.User, r1 error) {
  2094. return
  2095. },
  2096. },
  2097. GetByUsernameFunc: &UsersStoreGetByUsernameFunc{
  2098. defaultHook: func(context.Context, string) (r0 *db.User, r1 error) {
  2099. return
  2100. },
  2101. },
  2102. HasForkedRepositoryFunc: &UsersStoreHasForkedRepositoryFunc{
  2103. defaultHook: func(context.Context, int64, int64) (r0 bool) {
  2104. return
  2105. },
  2106. },
  2107. IsUsernameUsedFunc: &UsersStoreIsUsernameUsedFunc{
  2108. defaultHook: func(context.Context, string) (r0 bool) {
  2109. return
  2110. },
  2111. },
  2112. ListFunc: &UsersStoreListFunc{
  2113. defaultHook: func(context.Context, int, int) (r0 []*db.User, r1 error) {
  2114. return
  2115. },
  2116. },
  2117. ListFollowersFunc: &UsersStoreListFollowersFunc{
  2118. defaultHook: func(context.Context, int64, int, int) (r0 []*db.User, r1 error) {
  2119. return
  2120. },
  2121. },
  2122. ListFollowingsFunc: &UsersStoreListFollowingsFunc{
  2123. defaultHook: func(context.Context, int64, int, int) (r0 []*db.User, r1 error) {
  2124. return
  2125. },
  2126. },
  2127. UseCustomAvatarFunc: &UsersStoreUseCustomAvatarFunc{
  2128. defaultHook: func(context.Context, int64, []byte) (r0 error) {
  2129. return
  2130. },
  2131. },
  2132. }
  2133. }
  2134. // NewStrictMockUsersStore creates a new mock of the UsersStore interface.
  2135. // All methods panic on invocation, unless overwritten.
  2136. func NewStrictMockUsersStore() *MockUsersStore {
  2137. return &MockUsersStore{
  2138. AuthenticateFunc: &UsersStoreAuthenticateFunc{
  2139. defaultHook: func(context.Context, string, string, int64) (*db.User, error) {
  2140. panic("unexpected invocation of MockUsersStore.Authenticate")
  2141. },
  2142. },
  2143. ChangeUsernameFunc: &UsersStoreChangeUsernameFunc{
  2144. defaultHook: func(context.Context, int64, string) error {
  2145. panic("unexpected invocation of MockUsersStore.ChangeUsername")
  2146. },
  2147. },
  2148. CountFunc: &UsersStoreCountFunc{
  2149. defaultHook: func(context.Context) int64 {
  2150. panic("unexpected invocation of MockUsersStore.Count")
  2151. },
  2152. },
  2153. CreateFunc: &UsersStoreCreateFunc{
  2154. defaultHook: func(context.Context, string, string, db.CreateUserOptions) (*db.User, error) {
  2155. panic("unexpected invocation of MockUsersStore.Create")
  2156. },
  2157. },
  2158. DeleteCustomAvatarFunc: &UsersStoreDeleteCustomAvatarFunc{
  2159. defaultHook: func(context.Context, int64) error {
  2160. panic("unexpected invocation of MockUsersStore.DeleteCustomAvatar")
  2161. },
  2162. },
  2163. GetByEmailFunc: &UsersStoreGetByEmailFunc{
  2164. defaultHook: func(context.Context, string) (*db.User, error) {
  2165. panic("unexpected invocation of MockUsersStore.GetByEmail")
  2166. },
  2167. },
  2168. GetByIDFunc: &UsersStoreGetByIDFunc{
  2169. defaultHook: func(context.Context, int64) (*db.User, error) {
  2170. panic("unexpected invocation of MockUsersStore.GetByID")
  2171. },
  2172. },
  2173. GetByUsernameFunc: &UsersStoreGetByUsernameFunc{
  2174. defaultHook: func(context.Context, string) (*db.User, error) {
  2175. panic("unexpected invocation of MockUsersStore.GetByUsername")
  2176. },
  2177. },
  2178. HasForkedRepositoryFunc: &UsersStoreHasForkedRepositoryFunc{
  2179. defaultHook: func(context.Context, int64, int64) bool {
  2180. panic("unexpected invocation of MockUsersStore.HasForkedRepository")
  2181. },
  2182. },
  2183. IsUsernameUsedFunc: &UsersStoreIsUsernameUsedFunc{
  2184. defaultHook: func(context.Context, string) bool {
  2185. panic("unexpected invocation of MockUsersStore.IsUsernameUsed")
  2186. },
  2187. },
  2188. ListFunc: &UsersStoreListFunc{
  2189. defaultHook: func(context.Context, int, int) ([]*db.User, error) {
  2190. panic("unexpected invocation of MockUsersStore.List")
  2191. },
  2192. },
  2193. ListFollowersFunc: &UsersStoreListFollowersFunc{
  2194. defaultHook: func(context.Context, int64, int, int) ([]*db.User, error) {
  2195. panic("unexpected invocation of MockUsersStore.ListFollowers")
  2196. },
  2197. },
  2198. ListFollowingsFunc: &UsersStoreListFollowingsFunc{
  2199. defaultHook: func(context.Context, int64, int, int) ([]*db.User, error) {
  2200. panic("unexpected invocation of MockUsersStore.ListFollowings")
  2201. },
  2202. },
  2203. UseCustomAvatarFunc: &UsersStoreUseCustomAvatarFunc{
  2204. defaultHook: func(context.Context, int64, []byte) error {
  2205. panic("unexpected invocation of MockUsersStore.UseCustomAvatar")
  2206. },
  2207. },
  2208. }
  2209. }
  2210. // NewMockUsersStoreFrom creates a new mock of the MockUsersStore interface.
  2211. // All methods delegate to the given implementation, unless overwritten.
  2212. func NewMockUsersStoreFrom(i db.UsersStore) *MockUsersStore {
  2213. return &MockUsersStore{
  2214. AuthenticateFunc: &UsersStoreAuthenticateFunc{
  2215. defaultHook: i.Authenticate,
  2216. },
  2217. ChangeUsernameFunc: &UsersStoreChangeUsernameFunc{
  2218. defaultHook: i.ChangeUsername,
  2219. },
  2220. CountFunc: &UsersStoreCountFunc{
  2221. defaultHook: i.Count,
  2222. },
  2223. CreateFunc: &UsersStoreCreateFunc{
  2224. defaultHook: i.Create,
  2225. },
  2226. DeleteCustomAvatarFunc: &UsersStoreDeleteCustomAvatarFunc{
  2227. defaultHook: i.DeleteCustomAvatar,
  2228. },
  2229. GetByEmailFunc: &UsersStoreGetByEmailFunc{
  2230. defaultHook: i.GetByEmail,
  2231. },
  2232. GetByIDFunc: &UsersStoreGetByIDFunc{
  2233. defaultHook: i.GetByID,
  2234. },
  2235. GetByUsernameFunc: &UsersStoreGetByUsernameFunc{
  2236. defaultHook: i.GetByUsername,
  2237. },
  2238. HasForkedRepositoryFunc: &UsersStoreHasForkedRepositoryFunc{
  2239. defaultHook: i.HasForkedRepository,
  2240. },
  2241. IsUsernameUsedFunc: &UsersStoreIsUsernameUsedFunc{
  2242. defaultHook: i.IsUsernameUsed,
  2243. },
  2244. ListFunc: &UsersStoreListFunc{
  2245. defaultHook: i.List,
  2246. },
  2247. ListFollowersFunc: &UsersStoreListFollowersFunc{
  2248. defaultHook: i.ListFollowers,
  2249. },
  2250. ListFollowingsFunc: &UsersStoreListFollowingsFunc{
  2251. defaultHook: i.ListFollowings,
  2252. },
  2253. UseCustomAvatarFunc: &UsersStoreUseCustomAvatarFunc{
  2254. defaultHook: i.UseCustomAvatar,
  2255. },
  2256. }
  2257. }
  2258. // UsersStoreAuthenticateFunc describes the behavior when the Authenticate
  2259. // method of the parent MockUsersStore instance is invoked.
  2260. type UsersStoreAuthenticateFunc struct {
  2261. defaultHook func(context.Context, string, string, int64) (*db.User, error)
  2262. hooks []func(context.Context, string, string, int64) (*db.User, error)
  2263. history []UsersStoreAuthenticateFuncCall
  2264. mutex sync.Mutex
  2265. }
  2266. // Authenticate delegates to the next hook function in the queue and stores
  2267. // the parameter and result values of this invocation.
  2268. func (m *MockUsersStore) Authenticate(v0 context.Context, v1 string, v2 string, v3 int64) (*db.User, error) {
  2269. r0, r1 := m.AuthenticateFunc.nextHook()(v0, v1, v2, v3)
  2270. m.AuthenticateFunc.appendCall(UsersStoreAuthenticateFuncCall{v0, v1, v2, v3, r0, r1})
  2271. return r0, r1
  2272. }
  2273. // SetDefaultHook sets function that is called when the Authenticate method
  2274. // of the parent MockUsersStore instance is invoked and the hook queue is
  2275. // empty.
  2276. func (f *UsersStoreAuthenticateFunc) SetDefaultHook(hook func(context.Context, string, string, int64) (*db.User, error)) {
  2277. f.defaultHook = hook
  2278. }
  2279. // PushHook adds a function to the end of hook queue. Each invocation of the
  2280. // Authenticate method of the parent MockUsersStore instance invokes the
  2281. // hook at the front of the queue and discards it. After the queue is empty,
  2282. // the default hook function is invoked for any future action.
  2283. func (f *UsersStoreAuthenticateFunc) PushHook(hook func(context.Context, string, string, int64) (*db.User, error)) {
  2284. f.mutex.Lock()
  2285. f.hooks = append(f.hooks, hook)
  2286. f.mutex.Unlock()
  2287. }
  2288. // SetDefaultReturn calls SetDefaultHook with a function that returns the
  2289. // given values.
  2290. func (f *UsersStoreAuthenticateFunc) SetDefaultReturn(r0 *db.User, r1 error) {
  2291. f.SetDefaultHook(func(context.Context, string, string, int64) (*db.User, error) {
  2292. return r0, r1
  2293. })
  2294. }
  2295. // PushReturn calls PushHook with a function that returns the given values.
  2296. func (f *UsersStoreAuthenticateFunc) PushReturn(r0 *db.User, r1 error) {
  2297. f.PushHook(func(context.Context, string, string, int64) (*db.User, error) {
  2298. return r0, r1
  2299. })
  2300. }
  2301. func (f *UsersStoreAuthenticateFunc) nextHook() func(context.Context, string, string, int64) (*db.User, error) {
  2302. f.mutex.Lock()
  2303. defer f.mutex.Unlock()
  2304. if len(f.hooks) == 0 {
  2305. return f.defaultHook
  2306. }
  2307. hook := f.hooks[0]
  2308. f.hooks = f.hooks[1:]
  2309. return hook
  2310. }
  2311. func (f *UsersStoreAuthenticateFunc) appendCall(r0 UsersStoreAuthenticateFuncCall) {
  2312. f.mutex.Lock()
  2313. f.history = append(f.history, r0)
  2314. f.mutex.Unlock()
  2315. }
  2316. // History returns a sequence of UsersStoreAuthenticateFuncCall objects
  2317. // describing the invocations of this function.
  2318. func (f *UsersStoreAuthenticateFunc) History() []UsersStoreAuthenticateFuncCall {
  2319. f.mutex.Lock()
  2320. history := make([]UsersStoreAuthenticateFuncCall, len(f.history))
  2321. copy(history, f.history)
  2322. f.mutex.Unlock()
  2323. return history
  2324. }
  2325. // UsersStoreAuthenticateFuncCall is an object that describes an invocation
  2326. // of method Authenticate on an instance of MockUsersStore.
  2327. type UsersStoreAuthenticateFuncCall struct {
  2328. // Arg0 is the value of the 1st argument passed to this method
  2329. // invocation.
  2330. Arg0 context.Context
  2331. // Arg1 is the value of the 2nd argument passed to this method
  2332. // invocation.
  2333. Arg1 string
  2334. // Arg2 is the value of the 3rd argument passed to this method
  2335. // invocation.
  2336. Arg2 string
  2337. // Arg3 is the value of the 4th argument passed to this method
  2338. // invocation.
  2339. Arg3 int64
  2340. // Result0 is the value of the 1st result returned from this method
  2341. // invocation.
  2342. Result0 *db.User
  2343. // Result1 is the value of the 2nd result returned from this method
  2344. // invocation.
  2345. Result1 error
  2346. }
  2347. // Args returns an interface slice containing the arguments of this
  2348. // invocation.
  2349. func (c UsersStoreAuthenticateFuncCall) Args() []interface{} {
  2350. return []interface{}{c.Arg0, c.Arg1, c.Arg2, c.Arg3}
  2351. }
  2352. // Results returns an interface slice containing the results of this
  2353. // invocation.
  2354. func (c UsersStoreAuthenticateFuncCall) Results() []interface{} {
  2355. return []interface{}{c.Result0, c.Result1}
  2356. }
  2357. // UsersStoreChangeUsernameFunc describes the behavior when the
  2358. // ChangeUsername method of the parent MockUsersStore instance is invoked.
  2359. type UsersStoreChangeUsernameFunc struct {
  2360. defaultHook func(context.Context, int64, string) error
  2361. hooks []func(context.Context, int64, string) error
  2362. history []UsersStoreChangeUsernameFuncCall
  2363. mutex sync.Mutex
  2364. }
  2365. // ChangeUsername delegates to the next hook function in the queue and
  2366. // stores the parameter and result values of this invocation.
  2367. func (m *MockUsersStore) ChangeUsername(v0 context.Context, v1 int64, v2 string) error {
  2368. r0 := m.ChangeUsernameFunc.nextHook()(v0, v1, v2)
  2369. m.ChangeUsernameFunc.appendCall(UsersStoreChangeUsernameFuncCall{v0, v1, v2, r0})
  2370. return r0
  2371. }
  2372. // SetDefaultHook sets function that is called when the ChangeUsername
  2373. // method of the parent MockUsersStore instance is invoked and the hook
  2374. // queue is empty.
  2375. func (f *UsersStoreChangeUsernameFunc) SetDefaultHook(hook func(context.Context, int64, string) error) {
  2376. f.defaultHook = hook
  2377. }
  2378. // PushHook adds a function to the end of hook queue. Each invocation of the
  2379. // ChangeUsername method of the parent MockUsersStore instance invokes the
  2380. // hook at the front of the queue and discards it. After the queue is empty,
  2381. // the default hook function is invoked for any future action.
  2382. func (f *UsersStoreChangeUsernameFunc) PushHook(hook func(context.Context, int64, string) error) {
  2383. f.mutex.Lock()
  2384. f.hooks = append(f.hooks, hook)
  2385. f.mutex.Unlock()
  2386. }
  2387. // SetDefaultReturn calls SetDefaultHook with a function that returns the
  2388. // given values.
  2389. func (f *UsersStoreChangeUsernameFunc) SetDefaultReturn(r0 error) {
  2390. f.SetDefaultHook(func(context.Context, int64, string) error {
  2391. return r0
  2392. })
  2393. }
  2394. // PushReturn calls PushHook with a function that returns the given values.
  2395. func (f *UsersStoreChangeUsernameFunc) PushReturn(r0 error) {
  2396. f.PushHook(func(context.Context, int64, string) error {
  2397. return r0
  2398. })
  2399. }
  2400. func (f *UsersStoreChangeUsernameFunc) nextHook() func(context.Context, int64, string) error {
  2401. f.mutex.Lock()
  2402. defer f.mutex.Unlock()
  2403. if len(f.hooks) == 0 {
  2404. return f.defaultHook
  2405. }
  2406. hook := f.hooks[0]
  2407. f.hooks = f.hooks[1:]
  2408. return hook
  2409. }
  2410. func (f *UsersStoreChangeUsernameFunc) appendCall(r0 UsersStoreChangeUsernameFuncCall) {
  2411. f.mutex.Lock()
  2412. f.history = append(f.history, r0)
  2413. f.mutex.Unlock()
  2414. }
  2415. // History returns a sequence of UsersStoreChangeUsernameFuncCall objects
  2416. // describing the invocations of this function.
  2417. func (f *UsersStoreChangeUsernameFunc) History() []UsersStoreChangeUsernameFuncCall {
  2418. f.mutex.Lock()
  2419. history := make([]UsersStoreChangeUsernameFuncCall, len(f.history))
  2420. copy(history, f.history)
  2421. f.mutex.Unlock()
  2422. return history
  2423. }
  2424. // UsersStoreChangeUsernameFuncCall is an object that describes an
  2425. // invocation of method ChangeUsername on an instance of MockUsersStore.
  2426. type UsersStoreChangeUsernameFuncCall struct {
  2427. // Arg0 is the value of the 1st argument passed to this method
  2428. // invocation.
  2429. Arg0 context.Context
  2430. // Arg1 is the value of the 2nd argument passed to this method
  2431. // invocation.
  2432. Arg1 int64
  2433. // Arg2 is the value of the 3rd argument passed to this method
  2434. // invocation.
  2435. Arg2 string
  2436. // Result0 is the value of the 1st result returned from this method
  2437. // invocation.
  2438. Result0 error
  2439. }
  2440. // Args returns an interface slice containing the arguments of this
  2441. // invocation.
  2442. func (c UsersStoreChangeUsernameFuncCall) Args() []interface{} {
  2443. return []interface{}{c.Arg0, c.Arg1, c.Arg2}
  2444. }
  2445. // Results returns an interface slice containing the results of this
  2446. // invocation.
  2447. func (c UsersStoreChangeUsernameFuncCall) Results() []interface{} {
  2448. return []interface{}{c.Result0}
  2449. }
  2450. // UsersStoreCountFunc describes the behavior when the Count method of the
  2451. // parent MockUsersStore instance is invoked.
  2452. type UsersStoreCountFunc struct {
  2453. defaultHook func(context.Context) int64
  2454. hooks []func(context.Context) int64
  2455. history []UsersStoreCountFuncCall
  2456. mutex sync.Mutex
  2457. }
  2458. // Count delegates to the next hook function in the queue and stores the
  2459. // parameter and result values of this invocation.
  2460. func (m *MockUsersStore) Count(v0 context.Context) int64 {
  2461. r0 := m.CountFunc.nextHook()(v0)
  2462. m.CountFunc.appendCall(UsersStoreCountFuncCall{v0, r0})
  2463. return r0
  2464. }
  2465. // SetDefaultHook sets function that is called when the Count method of the
  2466. // parent MockUsersStore instance is invoked and the hook queue is empty.
  2467. func (f *UsersStoreCountFunc) SetDefaultHook(hook func(context.Context) int64) {
  2468. f.defaultHook = hook
  2469. }
  2470. // PushHook adds a function to the end of hook queue. Each invocation of the
  2471. // Count method of the parent MockUsersStore instance invokes the hook at
  2472. // the front of the queue and discards it. After the queue is empty, the
  2473. // default hook function is invoked for any future action.
  2474. func (f *UsersStoreCountFunc) PushHook(hook func(context.Context) int64) {
  2475. f.mutex.Lock()
  2476. f.hooks = append(f.hooks, hook)
  2477. f.mutex.Unlock()
  2478. }
  2479. // SetDefaultReturn calls SetDefaultHook with a function that returns the
  2480. // given values.
  2481. func (f *UsersStoreCountFunc) SetDefaultReturn(r0 int64) {
  2482. f.SetDefaultHook(func(context.Context) int64 {
  2483. return r0
  2484. })
  2485. }
  2486. // PushReturn calls PushHook with a function that returns the given values.
  2487. func (f *UsersStoreCountFunc) PushReturn(r0 int64) {
  2488. f.PushHook(func(context.Context) int64 {
  2489. return r0
  2490. })
  2491. }
  2492. func (f *UsersStoreCountFunc) nextHook() func(context.Context) int64 {
  2493. f.mutex.Lock()
  2494. defer f.mutex.Unlock()
  2495. if len(f.hooks) == 0 {
  2496. return f.defaultHook
  2497. }
  2498. hook := f.hooks[0]
  2499. f.hooks = f.hooks[1:]
  2500. return hook
  2501. }
  2502. func (f *UsersStoreCountFunc) appendCall(r0 UsersStoreCountFuncCall) {
  2503. f.mutex.Lock()
  2504. f.history = append(f.history, r0)
  2505. f.mutex.Unlock()
  2506. }
  2507. // History returns a sequence of UsersStoreCountFuncCall objects describing
  2508. // the invocations of this function.
  2509. func (f *UsersStoreCountFunc) History() []UsersStoreCountFuncCall {
  2510. f.mutex.Lock()
  2511. history := make([]UsersStoreCountFuncCall, len(f.history))
  2512. copy(history, f.history)
  2513. f.mutex.Unlock()
  2514. return history
  2515. }
  2516. // UsersStoreCountFuncCall is an object that describes an invocation of
  2517. // method Count on an instance of MockUsersStore.
  2518. type UsersStoreCountFuncCall struct {
  2519. // Arg0 is the value of the 1st argument passed to this method
  2520. // invocation.
  2521. Arg0 context.Context
  2522. // Result0 is the value of the 1st result returned from this method
  2523. // invocation.
  2524. Result0 int64
  2525. }
  2526. // Args returns an interface slice containing the arguments of this
  2527. // invocation.
  2528. func (c UsersStoreCountFuncCall) Args() []interface{} {
  2529. return []interface{}{c.Arg0}
  2530. }
  2531. // Results returns an interface slice containing the results of this
  2532. // invocation.
  2533. func (c UsersStoreCountFuncCall) Results() []interface{} {
  2534. return []interface{}{c.Result0}
  2535. }
  2536. // UsersStoreCreateFunc describes the behavior when the Create method of the
  2537. // parent MockUsersStore instance is invoked.
  2538. type UsersStoreCreateFunc struct {
  2539. defaultHook func(context.Context, string, string, db.CreateUserOptions) (*db.User, error)
  2540. hooks []func(context.Context, string, string, db.CreateUserOptions) (*db.User, error)
  2541. history []UsersStoreCreateFuncCall
  2542. mutex sync.Mutex
  2543. }
  2544. // Create delegates to the next hook function in the queue and stores the
  2545. // parameter and result values of this invocation.
  2546. func (m *MockUsersStore) Create(v0 context.Context, v1 string, v2 string, v3 db.CreateUserOptions) (*db.User, error) {
  2547. r0, r1 := m.CreateFunc.nextHook()(v0, v1, v2, v3)
  2548. m.CreateFunc.appendCall(UsersStoreCreateFuncCall{v0, v1, v2, v3, r0, r1})
  2549. return r0, r1
  2550. }
  2551. // SetDefaultHook sets function that is called when the Create method of the
  2552. // parent MockUsersStore instance is invoked and the hook queue is empty.
  2553. func (f *UsersStoreCreateFunc) SetDefaultHook(hook func(context.Context, string, string, db.CreateUserOptions) (*db.User, error)) {
  2554. f.defaultHook = hook
  2555. }
  2556. // PushHook adds a function to the end of hook queue. Each invocation of the
  2557. // Create method of the parent MockUsersStore instance invokes the hook at
  2558. // the front of the queue and discards it. After the queue is empty, the
  2559. // default hook function is invoked for any future action.
  2560. func (f *UsersStoreCreateFunc) PushHook(hook func(context.Context, string, string, db.CreateUserOptions) (*db.User, error)) {
  2561. f.mutex.Lock()
  2562. f.hooks = append(f.hooks, hook)
  2563. f.mutex.Unlock()
  2564. }
  2565. // SetDefaultReturn calls SetDefaultHook with a function that returns the
  2566. // given values.
  2567. func (f *UsersStoreCreateFunc) SetDefaultReturn(r0 *db.User, r1 error) {
  2568. f.SetDefaultHook(func(context.Context, string, string, db.CreateUserOptions) (*db.User, error) {
  2569. return r0, r1
  2570. })
  2571. }
  2572. // PushReturn calls PushHook with a function that returns the given values.
  2573. func (f *UsersStoreCreateFunc) PushReturn(r0 *db.User, r1 error) {
  2574. f.PushHook(func(context.Context, string, string, db.CreateUserOptions) (*db.User, error) {
  2575. return r0, r1
  2576. })
  2577. }
  2578. func (f *UsersStoreCreateFunc) nextHook() func(context.Context, string, string, db.CreateUserOptions) (*db.User, error) {
  2579. f.mutex.Lock()
  2580. defer f.mutex.Unlock()
  2581. if len(f.hooks) == 0 {
  2582. return f.defaultHook
  2583. }
  2584. hook := f.hooks[0]
  2585. f.hooks = f.hooks[1:]
  2586. return hook
  2587. }
  2588. func (f *UsersStoreCreateFunc) appendCall(r0 UsersStoreCreateFuncCall) {
  2589. f.mutex.Lock()
  2590. f.history = append(f.history, r0)
  2591. f.mutex.Unlock()
  2592. }
  2593. // History returns a sequence of UsersStoreCreateFuncCall objects describing
  2594. // the invocations of this function.
  2595. func (f *UsersStoreCreateFunc) History() []UsersStoreCreateFuncCall {
  2596. f.mutex.Lock()
  2597. history := make([]UsersStoreCreateFuncCall, len(f.history))
  2598. copy(history, f.history)
  2599. f.mutex.Unlock()
  2600. return history
  2601. }
  2602. // UsersStoreCreateFuncCall is an object that describes an invocation of
  2603. // method Create on an instance of MockUsersStore.
  2604. type UsersStoreCreateFuncCall struct {
  2605. // Arg0 is the value of the 1st argument passed to this method
  2606. // invocation.
  2607. Arg0 context.Context
  2608. // Arg1 is the value of the 2nd argument passed to this method
  2609. // invocation.
  2610. Arg1 string
  2611. // Arg2 is the value of the 3rd argument passed to this method
  2612. // invocation.
  2613. Arg2 string
  2614. // Arg3 is the value of the 4th argument passed to this method
  2615. // invocation.
  2616. Arg3 db.CreateUserOptions
  2617. // Result0 is the value of the 1st result returned from this method
  2618. // invocation.
  2619. Result0 *db.User
  2620. // Result1 is the value of the 2nd result returned from this method
  2621. // invocation.
  2622. Result1 error
  2623. }
  2624. // Args returns an interface slice containing the arguments of this
  2625. // invocation.
  2626. func (c UsersStoreCreateFuncCall) Args() []interface{} {
  2627. return []interface{}{c.Arg0, c.Arg1, c.Arg2, c.Arg3}
  2628. }
  2629. // Results returns an interface slice containing the results of this
  2630. // invocation.
  2631. func (c UsersStoreCreateFuncCall) Results() []interface{} {
  2632. return []interface{}{c.Result0, c.Result1}
  2633. }
  2634. // UsersStoreDeleteCustomAvatarFunc describes the behavior when the
  2635. // DeleteCustomAvatar method of the parent MockUsersStore instance is
  2636. // invoked.
  2637. type UsersStoreDeleteCustomAvatarFunc struct {
  2638. defaultHook func(context.Context, int64) error
  2639. hooks []func(context.Context, int64) error
  2640. history []UsersStoreDeleteCustomAvatarFuncCall
  2641. mutex sync.Mutex
  2642. }
  2643. // DeleteCustomAvatar delegates to the next hook function in the queue and
  2644. // stores the parameter and result values of this invocation.
  2645. func (m *MockUsersStore) DeleteCustomAvatar(v0 context.Context, v1 int64) error {
  2646. r0 := m.DeleteCustomAvatarFunc.nextHook()(v0, v1)
  2647. m.DeleteCustomAvatarFunc.appendCall(UsersStoreDeleteCustomAvatarFuncCall{v0, v1, r0})
  2648. return r0
  2649. }
  2650. // SetDefaultHook sets function that is called when the DeleteCustomAvatar
  2651. // method of the parent MockUsersStore instance is invoked and the hook
  2652. // queue is empty.
  2653. func (f *UsersStoreDeleteCustomAvatarFunc) SetDefaultHook(hook func(context.Context, int64) error) {
  2654. f.defaultHook = hook
  2655. }
  2656. // PushHook adds a function to the end of hook queue. Each invocation of the
  2657. // DeleteCustomAvatar method of the parent MockUsersStore instance invokes
  2658. // the hook at the front of the queue and discards it. After the queue is
  2659. // empty, the default hook function is invoked for any future action.
  2660. func (f *UsersStoreDeleteCustomAvatarFunc) PushHook(hook func(context.Context, int64) error) {
  2661. f.mutex.Lock()
  2662. f.hooks = append(f.hooks, hook)
  2663. f.mutex.Unlock()
  2664. }
  2665. // SetDefaultReturn calls SetDefaultHook with a function that returns the
  2666. // given values.
  2667. func (f *UsersStoreDeleteCustomAvatarFunc) SetDefaultReturn(r0 error) {
  2668. f.SetDefaultHook(func(context.Context, int64) error {
  2669. return r0
  2670. })
  2671. }
  2672. // PushReturn calls PushHook with a function that returns the given values.
  2673. func (f *UsersStoreDeleteCustomAvatarFunc) PushReturn(r0 error) {
  2674. f.PushHook(func(context.Context, int64) error {
  2675. return r0
  2676. })
  2677. }
  2678. func (f *UsersStoreDeleteCustomAvatarFunc) nextHook() func(context.Context, int64) error {
  2679. f.mutex.Lock()
  2680. defer f.mutex.Unlock()
  2681. if len(f.hooks) == 0 {
  2682. return f.defaultHook
  2683. }
  2684. hook := f.hooks[0]
  2685. f.hooks = f.hooks[1:]
  2686. return hook
  2687. }
  2688. func (f *UsersStoreDeleteCustomAvatarFunc) appendCall(r0 UsersStoreDeleteCustomAvatarFuncCall) {
  2689. f.mutex.Lock()
  2690. f.history = append(f.history, r0)
  2691. f.mutex.Unlock()
  2692. }
  2693. // History returns a sequence of UsersStoreDeleteCustomAvatarFuncCall
  2694. // objects describing the invocations of this function.
  2695. func (f *UsersStoreDeleteCustomAvatarFunc) History() []UsersStoreDeleteCustomAvatarFuncCall {
  2696. f.mutex.Lock()
  2697. history := make([]UsersStoreDeleteCustomAvatarFuncCall, len(f.history))
  2698. copy(history, f.history)
  2699. f.mutex.Unlock()
  2700. return history
  2701. }
  2702. // UsersStoreDeleteCustomAvatarFuncCall is an object that describes an
  2703. // invocation of method DeleteCustomAvatar on an instance of MockUsersStore.
  2704. type UsersStoreDeleteCustomAvatarFuncCall struct {
  2705. // Arg0 is the value of the 1st argument passed to this method
  2706. // invocation.
  2707. Arg0 context.Context
  2708. // Arg1 is the value of the 2nd argument passed to this method
  2709. // invocation.
  2710. Arg1 int64
  2711. // Result0 is the value of the 1st result returned from this method
  2712. // invocation.
  2713. Result0 error
  2714. }
  2715. // Args returns an interface slice containing the arguments of this
  2716. // invocation.
  2717. func (c UsersStoreDeleteCustomAvatarFuncCall) Args() []interface{} {
  2718. return []interface{}{c.Arg0, c.Arg1}
  2719. }
  2720. // Results returns an interface slice containing the results of this
  2721. // invocation.
  2722. func (c UsersStoreDeleteCustomAvatarFuncCall) Results() []interface{} {
  2723. return []interface{}{c.Result0}
  2724. }
  2725. // UsersStoreGetByEmailFunc describes the behavior when the GetByEmail
  2726. // method of the parent MockUsersStore instance is invoked.
  2727. type UsersStoreGetByEmailFunc struct {
  2728. defaultHook func(context.Context, string) (*db.User, error)
  2729. hooks []func(context.Context, string) (*db.User, error)
  2730. history []UsersStoreGetByEmailFuncCall
  2731. mutex sync.Mutex
  2732. }
  2733. // GetByEmail delegates to the next hook function in the queue and stores
  2734. // the parameter and result values of this invocation.
  2735. func (m *MockUsersStore) GetByEmail(v0 context.Context, v1 string) (*db.User, error) {
  2736. r0, r1 := m.GetByEmailFunc.nextHook()(v0, v1)
  2737. m.GetByEmailFunc.appendCall(UsersStoreGetByEmailFuncCall{v0, v1, r0, r1})
  2738. return r0, r1
  2739. }
  2740. // SetDefaultHook sets function that is called when the GetByEmail method of
  2741. // the parent MockUsersStore instance is invoked and the hook queue is
  2742. // empty.
  2743. func (f *UsersStoreGetByEmailFunc) SetDefaultHook(hook func(context.Context, string) (*db.User, error)) {
  2744. f.defaultHook = hook
  2745. }
  2746. // PushHook adds a function to the end of hook queue. Each invocation of the
  2747. // GetByEmail method of the parent MockUsersStore instance invokes the hook
  2748. // at the front of the queue and discards it. After the queue is empty, the
  2749. // default hook function is invoked for any future action.
  2750. func (f *UsersStoreGetByEmailFunc) PushHook(hook func(context.Context, string) (*db.User, error)) {
  2751. f.mutex.Lock()
  2752. f.hooks = append(f.hooks, hook)
  2753. f.mutex.Unlock()
  2754. }
  2755. // SetDefaultReturn calls SetDefaultHook with a function that returns the
  2756. // given values.
  2757. func (f *UsersStoreGetByEmailFunc) SetDefaultReturn(r0 *db.User, r1 error) {
  2758. f.SetDefaultHook(func(context.Context, string) (*db.User, error) {
  2759. return r0, r1
  2760. })
  2761. }
  2762. // PushReturn calls PushHook with a function that returns the given values.
  2763. func (f *UsersStoreGetByEmailFunc) PushReturn(r0 *db.User, r1 error) {
  2764. f.PushHook(func(context.Context, string) (*db.User, error) {
  2765. return r0, r1
  2766. })
  2767. }
  2768. func (f *UsersStoreGetByEmailFunc) nextHook() func(context.Context, string) (*db.User, error) {
  2769. f.mutex.Lock()
  2770. defer f.mutex.Unlock()
  2771. if len(f.hooks) == 0 {
  2772. return f.defaultHook
  2773. }
  2774. hook := f.hooks[0]
  2775. f.hooks = f.hooks[1:]
  2776. return hook
  2777. }
  2778. func (f *UsersStoreGetByEmailFunc) appendCall(r0 UsersStoreGetByEmailFuncCall) {
  2779. f.mutex.Lock()
  2780. f.history = append(f.history, r0)
  2781. f.mutex.Unlock()
  2782. }
  2783. // History returns a sequence of UsersStoreGetByEmailFuncCall objects
  2784. // describing the invocations of this function.
  2785. func (f *UsersStoreGetByEmailFunc) History() []UsersStoreGetByEmailFuncCall {
  2786. f.mutex.Lock()
  2787. history := make([]UsersStoreGetByEmailFuncCall, len(f.history))
  2788. copy(history, f.history)
  2789. f.mutex.Unlock()
  2790. return history
  2791. }
  2792. // UsersStoreGetByEmailFuncCall is an object that describes an invocation of
  2793. // method GetByEmail on an instance of MockUsersStore.
  2794. type UsersStoreGetByEmailFuncCall struct {
  2795. // Arg0 is the value of the 1st argument passed to this method
  2796. // invocation.
  2797. Arg0 context.Context
  2798. // Arg1 is the value of the 2nd argument passed to this method
  2799. // invocation.
  2800. Arg1 string
  2801. // Result0 is the value of the 1st result returned from this method
  2802. // invocation.
  2803. Result0 *db.User
  2804. // Result1 is the value of the 2nd result returned from this method
  2805. // invocation.
  2806. Result1 error
  2807. }
  2808. // Args returns an interface slice containing the arguments of this
  2809. // invocation.
  2810. func (c UsersStoreGetByEmailFuncCall) Args() []interface{} {
  2811. return []interface{}{c.Arg0, c.Arg1}
  2812. }
  2813. // Results returns an interface slice containing the results of this
  2814. // invocation.
  2815. func (c UsersStoreGetByEmailFuncCall) Results() []interface{} {
  2816. return []interface{}{c.Result0, c.Result1}
  2817. }
  2818. // UsersStoreGetByIDFunc describes the behavior when the GetByID method of
  2819. // the parent MockUsersStore instance is invoked.
  2820. type UsersStoreGetByIDFunc struct {
  2821. defaultHook func(context.Context, int64) (*db.User, error)
  2822. hooks []func(context.Context, int64) (*db.User, error)
  2823. history []UsersStoreGetByIDFuncCall
  2824. mutex sync.Mutex
  2825. }
  2826. // GetByID delegates to the next hook function in the queue and stores the
  2827. // parameter and result values of this invocation.
  2828. func (m *MockUsersStore) GetByID(v0 context.Context, v1 int64) (*db.User, error) {
  2829. r0, r1 := m.GetByIDFunc.nextHook()(v0, v1)
  2830. m.GetByIDFunc.appendCall(UsersStoreGetByIDFuncCall{v0, v1, r0, r1})
  2831. return r0, r1
  2832. }
  2833. // SetDefaultHook sets function that is called when the GetByID method of
  2834. // the parent MockUsersStore instance is invoked and the hook queue is
  2835. // empty.
  2836. func (f *UsersStoreGetByIDFunc) SetDefaultHook(hook func(context.Context, int64) (*db.User, error)) {
  2837. f.defaultHook = hook
  2838. }
  2839. // PushHook adds a function to the end of hook queue. Each invocation of the
  2840. // GetByID method of the parent MockUsersStore instance invokes the hook at
  2841. // the front of the queue and discards it. After the queue is empty, the
  2842. // default hook function is invoked for any future action.
  2843. func (f *UsersStoreGetByIDFunc) PushHook(hook func(context.Context, int64) (*db.User, error)) {
  2844. f.mutex.Lock()
  2845. f.hooks = append(f.hooks, hook)
  2846. f.mutex.Unlock()
  2847. }
  2848. // SetDefaultReturn calls SetDefaultHook with a function that returns the
  2849. // given values.
  2850. func (f *UsersStoreGetByIDFunc) SetDefaultReturn(r0 *db.User, r1 error) {
  2851. f.SetDefaultHook(func(context.Context, int64) (*db.User, error) {
  2852. return r0, r1
  2853. })
  2854. }
  2855. // PushReturn calls PushHook with a function that returns the given values.
  2856. func (f *UsersStoreGetByIDFunc) PushReturn(r0 *db.User, r1 error) {
  2857. f.PushHook(func(context.Context, int64) (*db.User, error) {
  2858. return r0, r1
  2859. })
  2860. }
  2861. func (f *UsersStoreGetByIDFunc) nextHook() func(context.Context, int64) (*db.User, error) {
  2862. f.mutex.Lock()
  2863. defer f.mutex.Unlock()
  2864. if len(f.hooks) == 0 {
  2865. return f.defaultHook
  2866. }
  2867. hook := f.hooks[0]
  2868. f.hooks = f.hooks[1:]
  2869. return hook
  2870. }
  2871. func (f *UsersStoreGetByIDFunc) appendCall(r0 UsersStoreGetByIDFuncCall) {
  2872. f.mutex.Lock()
  2873. f.history = append(f.history, r0)
  2874. f.mutex.Unlock()
  2875. }
  2876. // History returns a sequence of UsersStoreGetByIDFuncCall objects
  2877. // describing the invocations of this function.
  2878. func (f *UsersStoreGetByIDFunc) History() []UsersStoreGetByIDFuncCall {
  2879. f.mutex.Lock()
  2880. history := make([]UsersStoreGetByIDFuncCall, len(f.history))
  2881. copy(history, f.history)
  2882. f.mutex.Unlock()
  2883. return history
  2884. }
  2885. // UsersStoreGetByIDFuncCall is an object that describes an invocation of
  2886. // method GetByID on an instance of MockUsersStore.
  2887. type UsersStoreGetByIDFuncCall struct {
  2888. // Arg0 is the value of the 1st argument passed to this method
  2889. // invocation.
  2890. Arg0 context.Context
  2891. // Arg1 is the value of the 2nd argument passed to this method
  2892. // invocation.
  2893. Arg1 int64
  2894. // Result0 is the value of the 1st result returned from this method
  2895. // invocation.
  2896. Result0 *db.User
  2897. // Result1 is the value of the 2nd result returned from this method
  2898. // invocation.
  2899. Result1 error
  2900. }
  2901. // Args returns an interface slice containing the arguments of this
  2902. // invocation.
  2903. func (c UsersStoreGetByIDFuncCall) Args() []interface{} {
  2904. return []interface{}{c.Arg0, c.Arg1}
  2905. }
  2906. // Results returns an interface slice containing the results of this
  2907. // invocation.
  2908. func (c UsersStoreGetByIDFuncCall) Results() []interface{} {
  2909. return []interface{}{c.Result0, c.Result1}
  2910. }
  2911. // UsersStoreGetByUsernameFunc describes the behavior when the GetByUsername
  2912. // method of the parent MockUsersStore instance is invoked.
  2913. type UsersStoreGetByUsernameFunc struct {
  2914. defaultHook func(context.Context, string) (*db.User, error)
  2915. hooks []func(context.Context, string) (*db.User, error)
  2916. history []UsersStoreGetByUsernameFuncCall
  2917. mutex sync.Mutex
  2918. }
  2919. // GetByUsername delegates to the next hook function in the queue and stores
  2920. // the parameter and result values of this invocation.
  2921. func (m *MockUsersStore) GetByUsername(v0 context.Context, v1 string) (*db.User, error) {
  2922. r0, r1 := m.GetByUsernameFunc.nextHook()(v0, v1)
  2923. m.GetByUsernameFunc.appendCall(UsersStoreGetByUsernameFuncCall{v0, v1, r0, r1})
  2924. return r0, r1
  2925. }
  2926. // SetDefaultHook sets function that is called when the GetByUsername method
  2927. // of the parent MockUsersStore instance is invoked and the hook queue is
  2928. // empty.
  2929. func (f *UsersStoreGetByUsernameFunc) SetDefaultHook(hook func(context.Context, string) (*db.User, error)) {
  2930. f.defaultHook = hook
  2931. }
  2932. // PushHook adds a function to the end of hook queue. Each invocation of the
  2933. // GetByUsername method of the parent MockUsersStore instance invokes the
  2934. // hook at the front of the queue and discards it. After the queue is empty,
  2935. // the default hook function is invoked for any future action.
  2936. func (f *UsersStoreGetByUsernameFunc) PushHook(hook func(context.Context, string) (*db.User, error)) {
  2937. f.mutex.Lock()
  2938. f.hooks = append(f.hooks, hook)
  2939. f.mutex.Unlock()
  2940. }
  2941. // SetDefaultReturn calls SetDefaultHook with a function that returns the
  2942. // given values.
  2943. func (f *UsersStoreGetByUsernameFunc) SetDefaultReturn(r0 *db.User, r1 error) {
  2944. f.SetDefaultHook(func(context.Context, string) (*db.User, error) {
  2945. return r0, r1
  2946. })
  2947. }
  2948. // PushReturn calls PushHook with a function that returns the given values.
  2949. func (f *UsersStoreGetByUsernameFunc) PushReturn(r0 *db.User, r1 error) {
  2950. f.PushHook(func(context.Context, string) (*db.User, error) {
  2951. return r0, r1
  2952. })
  2953. }
  2954. func (f *UsersStoreGetByUsernameFunc) nextHook() func(context.Context, string) (*db.User, error) {
  2955. f.mutex.Lock()
  2956. defer f.mutex.Unlock()
  2957. if len(f.hooks) == 0 {
  2958. return f.defaultHook
  2959. }
  2960. hook := f.hooks[0]
  2961. f.hooks = f.hooks[1:]
  2962. return hook
  2963. }
  2964. func (f *UsersStoreGetByUsernameFunc) appendCall(r0 UsersStoreGetByUsernameFuncCall) {
  2965. f.mutex.Lock()
  2966. f.history = append(f.history, r0)
  2967. f.mutex.Unlock()
  2968. }
  2969. // History returns a sequence of UsersStoreGetByUsernameFuncCall objects
  2970. // describing the invocations of this function.
  2971. func (f *UsersStoreGetByUsernameFunc) History() []UsersStoreGetByUsernameFuncCall {
  2972. f.mutex.Lock()
  2973. history := make([]UsersStoreGetByUsernameFuncCall, len(f.history))
  2974. copy(history, f.history)
  2975. f.mutex.Unlock()
  2976. return history
  2977. }
  2978. // UsersStoreGetByUsernameFuncCall is an object that describes an invocation
  2979. // of method GetByUsername on an instance of MockUsersStore.
  2980. type UsersStoreGetByUsernameFuncCall struct {
  2981. // Arg0 is the value of the 1st argument passed to this method
  2982. // invocation.
  2983. Arg0 context.Context
  2984. // Arg1 is the value of the 2nd argument passed to this method
  2985. // invocation.
  2986. Arg1 string
  2987. // Result0 is the value of the 1st result returned from this method
  2988. // invocation.
  2989. Result0 *db.User
  2990. // Result1 is the value of the 2nd result returned from this method
  2991. // invocation.
  2992. Result1 error
  2993. }
  2994. // Args returns an interface slice containing the arguments of this
  2995. // invocation.
  2996. func (c UsersStoreGetByUsernameFuncCall) Args() []interface{} {
  2997. return []interface{}{c.Arg0, c.Arg1}
  2998. }
  2999. // Results returns an interface slice containing the results of this
  3000. // invocation.
  3001. func (c UsersStoreGetByUsernameFuncCall) Results() []interface{} {
  3002. return []interface{}{c.Result0, c.Result1}
  3003. }
  3004. // UsersStoreHasForkedRepositoryFunc describes the behavior when the
  3005. // HasForkedRepository method of the parent MockUsersStore instance is
  3006. // invoked.
  3007. type UsersStoreHasForkedRepositoryFunc struct {
  3008. defaultHook func(context.Context, int64, int64) bool
  3009. hooks []func(context.Context, int64, int64) bool
  3010. history []UsersStoreHasForkedRepositoryFuncCall
  3011. mutex sync.Mutex
  3012. }
  3013. // HasForkedRepository delegates to the next hook function in the queue and
  3014. // stores the parameter and result values of this invocation.
  3015. func (m *MockUsersStore) HasForkedRepository(v0 context.Context, v1 int64, v2 int64) bool {
  3016. r0 := m.HasForkedRepositoryFunc.nextHook()(v0, v1, v2)
  3017. m.HasForkedRepositoryFunc.appendCall(UsersStoreHasForkedRepositoryFuncCall{v0, v1, v2, r0})
  3018. return r0
  3019. }
  3020. // SetDefaultHook sets function that is called when the HasForkedRepository
  3021. // method of the parent MockUsersStore instance is invoked and the hook
  3022. // queue is empty.
  3023. func (f *UsersStoreHasForkedRepositoryFunc) SetDefaultHook(hook func(context.Context, int64, int64) bool) {
  3024. f.defaultHook = hook
  3025. }
  3026. // PushHook adds a function to the end of hook queue. Each invocation of the
  3027. // HasForkedRepository method of the parent MockUsersStore instance invokes
  3028. // the hook at the front of the queue and discards it. After the queue is
  3029. // empty, the default hook function is invoked for any future action.
  3030. func (f *UsersStoreHasForkedRepositoryFunc) PushHook(hook func(context.Context, int64, int64) bool) {
  3031. f.mutex.Lock()
  3032. f.hooks = append(f.hooks, hook)
  3033. f.mutex.Unlock()
  3034. }
  3035. // SetDefaultReturn calls SetDefaultHook with a function that returns the
  3036. // given values.
  3037. func (f *UsersStoreHasForkedRepositoryFunc) SetDefaultReturn(r0 bool) {
  3038. f.SetDefaultHook(func(context.Context, int64, int64) bool {
  3039. return r0
  3040. })
  3041. }
  3042. // PushReturn calls PushHook with a function that returns the given values.
  3043. func (f *UsersStoreHasForkedRepositoryFunc) PushReturn(r0 bool) {
  3044. f.PushHook(func(context.Context, int64, int64) bool {
  3045. return r0
  3046. })
  3047. }
  3048. func (f *UsersStoreHasForkedRepositoryFunc) nextHook() func(context.Context, int64, int64) bool {
  3049. f.mutex.Lock()
  3050. defer f.mutex.Unlock()
  3051. if len(f.hooks) == 0 {
  3052. return f.defaultHook
  3053. }
  3054. hook := f.hooks[0]
  3055. f.hooks = f.hooks[1:]
  3056. return hook
  3057. }
  3058. func (f *UsersStoreHasForkedRepositoryFunc) appendCall(r0 UsersStoreHasForkedRepositoryFuncCall) {
  3059. f.mutex.Lock()
  3060. f.history = append(f.history, r0)
  3061. f.mutex.Unlock()
  3062. }
  3063. // History returns a sequence of UsersStoreHasForkedRepositoryFuncCall
  3064. // objects describing the invocations of this function.
  3065. func (f *UsersStoreHasForkedRepositoryFunc) History() []UsersStoreHasForkedRepositoryFuncCall {
  3066. f.mutex.Lock()
  3067. history := make([]UsersStoreHasForkedRepositoryFuncCall, len(f.history))
  3068. copy(history, f.history)
  3069. f.mutex.Unlock()
  3070. return history
  3071. }
  3072. // UsersStoreHasForkedRepositoryFuncCall is an object that describes an
  3073. // invocation of method HasForkedRepository on an instance of
  3074. // MockUsersStore.
  3075. type UsersStoreHasForkedRepositoryFuncCall struct {
  3076. // Arg0 is the value of the 1st argument passed to this method
  3077. // invocation.
  3078. Arg0 context.Context
  3079. // Arg1 is the value of the 2nd argument passed to this method
  3080. // invocation.
  3081. Arg1 int64
  3082. // Arg2 is the value of the 3rd argument passed to this method
  3083. // invocation.
  3084. Arg2 int64
  3085. // Result0 is the value of the 1st result returned from this method
  3086. // invocation.
  3087. Result0 bool
  3088. }
  3089. // Args returns an interface slice containing the arguments of this
  3090. // invocation.
  3091. func (c UsersStoreHasForkedRepositoryFuncCall) Args() []interface{} {
  3092. return []interface{}{c.Arg0, c.Arg1, c.Arg2}
  3093. }
  3094. // Results returns an interface slice containing the results of this
  3095. // invocation.
  3096. func (c UsersStoreHasForkedRepositoryFuncCall) Results() []interface{} {
  3097. return []interface{}{c.Result0}
  3098. }
  3099. // UsersStoreIsUsernameUsedFunc describes the behavior when the
  3100. // IsUsernameUsed method of the parent MockUsersStore instance is invoked.
  3101. type UsersStoreIsUsernameUsedFunc struct {
  3102. defaultHook func(context.Context, string) bool
  3103. hooks []func(context.Context, string) bool
  3104. history []UsersStoreIsUsernameUsedFuncCall
  3105. mutex sync.Mutex
  3106. }
  3107. // IsUsernameUsed delegates to the next hook function in the queue and
  3108. // stores the parameter and result values of this invocation.
  3109. func (m *MockUsersStore) IsUsernameUsed(v0 context.Context, v1 string) bool {
  3110. r0 := m.IsUsernameUsedFunc.nextHook()(v0, v1)
  3111. m.IsUsernameUsedFunc.appendCall(UsersStoreIsUsernameUsedFuncCall{v0, v1, r0})
  3112. return r0
  3113. }
  3114. // SetDefaultHook sets function that is called when the IsUsernameUsed
  3115. // method of the parent MockUsersStore instance is invoked and the hook
  3116. // queue is empty.
  3117. func (f *UsersStoreIsUsernameUsedFunc) SetDefaultHook(hook func(context.Context, string) bool) {
  3118. f.defaultHook = hook
  3119. }
  3120. // PushHook adds a function to the end of hook queue. Each invocation of the
  3121. // IsUsernameUsed method of the parent MockUsersStore instance invokes the
  3122. // hook at the front of the queue and discards it. After the queue is empty,
  3123. // the default hook function is invoked for any future action.
  3124. func (f *UsersStoreIsUsernameUsedFunc) PushHook(hook func(context.Context, string) bool) {
  3125. f.mutex.Lock()
  3126. f.hooks = append(f.hooks, hook)
  3127. f.mutex.Unlock()
  3128. }
  3129. // SetDefaultReturn calls SetDefaultHook with a function that returns the
  3130. // given values.
  3131. func (f *UsersStoreIsUsernameUsedFunc) SetDefaultReturn(r0 bool) {
  3132. f.SetDefaultHook(func(context.Context, string) bool {
  3133. return r0
  3134. })
  3135. }
  3136. // PushReturn calls PushHook with a function that returns the given values.
  3137. func (f *UsersStoreIsUsernameUsedFunc) PushReturn(r0 bool) {
  3138. f.PushHook(func(context.Context, string) bool {
  3139. return r0
  3140. })
  3141. }
  3142. func (f *UsersStoreIsUsernameUsedFunc) nextHook() func(context.Context, string) bool {
  3143. f.mutex.Lock()
  3144. defer f.mutex.Unlock()
  3145. if len(f.hooks) == 0 {
  3146. return f.defaultHook
  3147. }
  3148. hook := f.hooks[0]
  3149. f.hooks = f.hooks[1:]
  3150. return hook
  3151. }
  3152. func (f *UsersStoreIsUsernameUsedFunc) appendCall(r0 UsersStoreIsUsernameUsedFuncCall) {
  3153. f.mutex.Lock()
  3154. f.history = append(f.history, r0)
  3155. f.mutex.Unlock()
  3156. }
  3157. // History returns a sequence of UsersStoreIsUsernameUsedFuncCall objects
  3158. // describing the invocations of this function.
  3159. func (f *UsersStoreIsUsernameUsedFunc) History() []UsersStoreIsUsernameUsedFuncCall {
  3160. f.mutex.Lock()
  3161. history := make([]UsersStoreIsUsernameUsedFuncCall, len(f.history))
  3162. copy(history, f.history)
  3163. f.mutex.Unlock()
  3164. return history
  3165. }
  3166. // UsersStoreIsUsernameUsedFuncCall is an object that describes an
  3167. // invocation of method IsUsernameUsed on an instance of MockUsersStore.
  3168. type UsersStoreIsUsernameUsedFuncCall struct {
  3169. // Arg0 is the value of the 1st argument passed to this method
  3170. // invocation.
  3171. Arg0 context.Context
  3172. // Arg1 is the value of the 2nd argument passed to this method
  3173. // invocation.
  3174. Arg1 string
  3175. // Result0 is the value of the 1st result returned from this method
  3176. // invocation.
  3177. Result0 bool
  3178. }
  3179. // Args returns an interface slice containing the arguments of this
  3180. // invocation.
  3181. func (c UsersStoreIsUsernameUsedFuncCall) Args() []interface{} {
  3182. return []interface{}{c.Arg0, c.Arg1}
  3183. }
  3184. // Results returns an interface slice containing the results of this
  3185. // invocation.
  3186. func (c UsersStoreIsUsernameUsedFuncCall) Results() []interface{} {
  3187. return []interface{}{c.Result0}
  3188. }
  3189. // UsersStoreListFunc describes the behavior when the List method of the
  3190. // parent MockUsersStore instance is invoked.
  3191. type UsersStoreListFunc struct {
  3192. defaultHook func(context.Context, int, int) ([]*db.User, error)
  3193. hooks []func(context.Context, int, int) ([]*db.User, error)
  3194. history []UsersStoreListFuncCall
  3195. mutex sync.Mutex
  3196. }
  3197. // List delegates to the next hook function in the queue and stores the
  3198. // parameter and result values of this invocation.
  3199. func (m *MockUsersStore) List(v0 context.Context, v1 int, v2 int) ([]*db.User, error) {
  3200. r0, r1 := m.ListFunc.nextHook()(v0, v1, v2)
  3201. m.ListFunc.appendCall(UsersStoreListFuncCall{v0, v1, v2, r0, r1})
  3202. return r0, r1
  3203. }
  3204. // SetDefaultHook sets function that is called when the List method of the
  3205. // parent MockUsersStore instance is invoked and the hook queue is empty.
  3206. func (f *UsersStoreListFunc) SetDefaultHook(hook func(context.Context, int, int) ([]*db.User, error)) {
  3207. f.defaultHook = hook
  3208. }
  3209. // PushHook adds a function to the end of hook queue. Each invocation of the
  3210. // List method of the parent MockUsersStore instance invokes the hook at the
  3211. // front of the queue and discards it. After the queue is empty, the default
  3212. // hook function is invoked for any future action.
  3213. func (f *UsersStoreListFunc) PushHook(hook func(context.Context, int, int) ([]*db.User, error)) {
  3214. f.mutex.Lock()
  3215. f.hooks = append(f.hooks, hook)
  3216. f.mutex.Unlock()
  3217. }
  3218. // SetDefaultReturn calls SetDefaultHook with a function that returns the
  3219. // given values.
  3220. func (f *UsersStoreListFunc) SetDefaultReturn(r0 []*db.User, r1 error) {
  3221. f.SetDefaultHook(func(context.Context, int, int) ([]*db.User, error) {
  3222. return r0, r1
  3223. })
  3224. }
  3225. // PushReturn calls PushHook with a function that returns the given values.
  3226. func (f *UsersStoreListFunc) PushReturn(r0 []*db.User, r1 error) {
  3227. f.PushHook(func(context.Context, int, int) ([]*db.User, error) {
  3228. return r0, r1
  3229. })
  3230. }
  3231. func (f *UsersStoreListFunc) nextHook() func(context.Context, int, int) ([]*db.User, error) {
  3232. f.mutex.Lock()
  3233. defer f.mutex.Unlock()
  3234. if len(f.hooks) == 0 {
  3235. return f.defaultHook
  3236. }
  3237. hook := f.hooks[0]
  3238. f.hooks = f.hooks[1:]
  3239. return hook
  3240. }
  3241. func (f *UsersStoreListFunc) appendCall(r0 UsersStoreListFuncCall) {
  3242. f.mutex.Lock()
  3243. f.history = append(f.history, r0)
  3244. f.mutex.Unlock()
  3245. }
  3246. // History returns a sequence of UsersStoreListFuncCall objects describing
  3247. // the invocations of this function.
  3248. func (f *UsersStoreListFunc) History() []UsersStoreListFuncCall {
  3249. f.mutex.Lock()
  3250. history := make([]UsersStoreListFuncCall, len(f.history))
  3251. copy(history, f.history)
  3252. f.mutex.Unlock()
  3253. return history
  3254. }
  3255. // UsersStoreListFuncCall is an object that describes an invocation of
  3256. // method List on an instance of MockUsersStore.
  3257. type UsersStoreListFuncCall struct {
  3258. // Arg0 is the value of the 1st argument passed to this method
  3259. // invocation.
  3260. Arg0 context.Context
  3261. // Arg1 is the value of the 2nd argument passed to this method
  3262. // invocation.
  3263. Arg1 int
  3264. // Arg2 is the value of the 3rd argument passed to this method
  3265. // invocation.
  3266. Arg2 int
  3267. // Result0 is the value of the 1st result returned from this method
  3268. // invocation.
  3269. Result0 []*db.User
  3270. // Result1 is the value of the 2nd result returned from this method
  3271. // invocation.
  3272. Result1 error
  3273. }
  3274. // Args returns an interface slice containing the arguments of this
  3275. // invocation.
  3276. func (c UsersStoreListFuncCall) Args() []interface{} {
  3277. return []interface{}{c.Arg0, c.Arg1, c.Arg2}
  3278. }
  3279. // Results returns an interface slice containing the results of this
  3280. // invocation.
  3281. func (c UsersStoreListFuncCall) Results() []interface{} {
  3282. return []interface{}{c.Result0, c.Result1}
  3283. }
  3284. // UsersStoreListFollowersFunc describes the behavior when the ListFollowers
  3285. // method of the parent MockUsersStore instance is invoked.
  3286. type UsersStoreListFollowersFunc struct {
  3287. defaultHook func(context.Context, int64, int, int) ([]*db.User, error)
  3288. hooks []func(context.Context, int64, int, int) ([]*db.User, error)
  3289. history []UsersStoreListFollowersFuncCall
  3290. mutex sync.Mutex
  3291. }
  3292. // ListFollowers delegates to the next hook function in the queue and stores
  3293. // the parameter and result values of this invocation.
  3294. func (m *MockUsersStore) ListFollowers(v0 context.Context, v1 int64, v2 int, v3 int) ([]*db.User, error) {
  3295. r0, r1 := m.ListFollowersFunc.nextHook()(v0, v1, v2, v3)
  3296. m.ListFollowersFunc.appendCall(UsersStoreListFollowersFuncCall{v0, v1, v2, v3, r0, r1})
  3297. return r0, r1
  3298. }
  3299. // SetDefaultHook sets function that is called when the ListFollowers method
  3300. // of the parent MockUsersStore instance is invoked and the hook queue is
  3301. // empty.
  3302. func (f *UsersStoreListFollowersFunc) SetDefaultHook(hook func(context.Context, int64, int, int) ([]*db.User, error)) {
  3303. f.defaultHook = hook
  3304. }
  3305. // PushHook adds a function to the end of hook queue. Each invocation of the
  3306. // ListFollowers method of the parent MockUsersStore instance invokes the
  3307. // hook at the front of the queue and discards it. After the queue is empty,
  3308. // the default hook function is invoked for any future action.
  3309. func (f *UsersStoreListFollowersFunc) PushHook(hook func(context.Context, int64, int, int) ([]*db.User, error)) {
  3310. f.mutex.Lock()
  3311. f.hooks = append(f.hooks, hook)
  3312. f.mutex.Unlock()
  3313. }
  3314. // SetDefaultReturn calls SetDefaultHook with a function that returns the
  3315. // given values.
  3316. func (f *UsersStoreListFollowersFunc) SetDefaultReturn(r0 []*db.User, r1 error) {
  3317. f.SetDefaultHook(func(context.Context, int64, int, int) ([]*db.User, error) {
  3318. return r0, r1
  3319. })
  3320. }
  3321. // PushReturn calls PushHook with a function that returns the given values.
  3322. func (f *UsersStoreListFollowersFunc) PushReturn(r0 []*db.User, r1 error) {
  3323. f.PushHook(func(context.Context, int64, int, int) ([]*db.User, error) {
  3324. return r0, r1
  3325. })
  3326. }
  3327. func (f *UsersStoreListFollowersFunc) nextHook() func(context.Context, int64, int, int) ([]*db.User, error) {
  3328. f.mutex.Lock()
  3329. defer f.mutex.Unlock()
  3330. if len(f.hooks) == 0 {
  3331. return f.defaultHook
  3332. }
  3333. hook := f.hooks[0]
  3334. f.hooks = f.hooks[1:]
  3335. return hook
  3336. }
  3337. func (f *UsersStoreListFollowersFunc) appendCall(r0 UsersStoreListFollowersFuncCall) {
  3338. f.mutex.Lock()
  3339. f.history = append(f.history, r0)
  3340. f.mutex.Unlock()
  3341. }
  3342. // History returns a sequence of UsersStoreListFollowersFuncCall objects
  3343. // describing the invocations of this function.
  3344. func (f *UsersStoreListFollowersFunc) History() []UsersStoreListFollowersFuncCall {
  3345. f.mutex.Lock()
  3346. history := make([]UsersStoreListFollowersFuncCall, len(f.history))
  3347. copy(history, f.history)
  3348. f.mutex.Unlock()
  3349. return history
  3350. }
  3351. // UsersStoreListFollowersFuncCall is an object that describes an invocation
  3352. // of method ListFollowers on an instance of MockUsersStore.
  3353. type UsersStoreListFollowersFuncCall struct {
  3354. // Arg0 is the value of the 1st argument passed to this method
  3355. // invocation.
  3356. Arg0 context.Context
  3357. // Arg1 is the value of the 2nd argument passed to this method
  3358. // invocation.
  3359. Arg1 int64
  3360. // Arg2 is the value of the 3rd argument passed to this method
  3361. // invocation.
  3362. Arg2 int
  3363. // Arg3 is the value of the 4th argument passed to this method
  3364. // invocation.
  3365. Arg3 int
  3366. // Result0 is the value of the 1st result returned from this method
  3367. // invocation.
  3368. Result0 []*db.User
  3369. // Result1 is the value of the 2nd result returned from this method
  3370. // invocation.
  3371. Result1 error
  3372. }
  3373. // Args returns an interface slice containing the arguments of this
  3374. // invocation.
  3375. func (c UsersStoreListFollowersFuncCall) Args() []interface{} {
  3376. return []interface{}{c.Arg0, c.Arg1, c.Arg2, c.Arg3}
  3377. }
  3378. // Results returns an interface slice containing the results of this
  3379. // invocation.
  3380. func (c UsersStoreListFollowersFuncCall) Results() []interface{} {
  3381. return []interface{}{c.Result0, c.Result1}
  3382. }
  3383. // UsersStoreListFollowingsFunc describes the behavior when the
  3384. // ListFollowings method of the parent MockUsersStore instance is invoked.
  3385. type UsersStoreListFollowingsFunc struct {
  3386. defaultHook func(context.Context, int64, int, int) ([]*db.User, error)
  3387. hooks []func(context.Context, int64, int, int) ([]*db.User, error)
  3388. history []UsersStoreListFollowingsFuncCall
  3389. mutex sync.Mutex
  3390. }
  3391. // ListFollowings delegates to the next hook function in the queue and
  3392. // stores the parameter and result values of this invocation.
  3393. func (m *MockUsersStore) ListFollowings(v0 context.Context, v1 int64, v2 int, v3 int) ([]*db.User, error) {
  3394. r0, r1 := m.ListFollowingsFunc.nextHook()(v0, v1, v2, v3)
  3395. m.ListFollowingsFunc.appendCall(UsersStoreListFollowingsFuncCall{v0, v1, v2, v3, r0, r1})
  3396. return r0, r1
  3397. }
  3398. // SetDefaultHook sets function that is called when the ListFollowings
  3399. // method of the parent MockUsersStore instance is invoked and the hook
  3400. // queue is empty.
  3401. func (f *UsersStoreListFollowingsFunc) SetDefaultHook(hook func(context.Context, int64, int, int) ([]*db.User, error)) {
  3402. f.defaultHook = hook
  3403. }
  3404. // PushHook adds a function to the end of hook queue. Each invocation of the
  3405. // ListFollowings method of the parent MockUsersStore instance invokes the
  3406. // hook at the front of the queue and discards it. After the queue is empty,
  3407. // the default hook function is invoked for any future action.
  3408. func (f *UsersStoreListFollowingsFunc) PushHook(hook func(context.Context, int64, int, int) ([]*db.User, error)) {
  3409. f.mutex.Lock()
  3410. f.hooks = append(f.hooks, hook)
  3411. f.mutex.Unlock()
  3412. }
  3413. // SetDefaultReturn calls SetDefaultHook with a function that returns the
  3414. // given values.
  3415. func (f *UsersStoreListFollowingsFunc) SetDefaultReturn(r0 []*db.User, r1 error) {
  3416. f.SetDefaultHook(func(context.Context, int64, int, int) ([]*db.User, error) {
  3417. return r0, r1
  3418. })
  3419. }
  3420. // PushReturn calls PushHook with a function that returns the given values.
  3421. func (f *UsersStoreListFollowingsFunc) PushReturn(r0 []*db.User, r1 error) {
  3422. f.PushHook(func(context.Context, int64, int, int) ([]*db.User, error) {
  3423. return r0, r1
  3424. })
  3425. }
  3426. func (f *UsersStoreListFollowingsFunc) nextHook() func(context.Context, int64, int, int) ([]*db.User, error) {
  3427. f.mutex.Lock()
  3428. defer f.mutex.Unlock()
  3429. if len(f.hooks) == 0 {
  3430. return f.defaultHook
  3431. }
  3432. hook := f.hooks[0]
  3433. f.hooks = f.hooks[1:]
  3434. return hook
  3435. }
  3436. func (f *UsersStoreListFollowingsFunc) appendCall(r0 UsersStoreListFollowingsFuncCall) {
  3437. f.mutex.Lock()
  3438. f.history = append(f.history, r0)
  3439. f.mutex.Unlock()
  3440. }
  3441. // History returns a sequence of UsersStoreListFollowingsFuncCall objects
  3442. // describing the invocations of this function.
  3443. func (f *UsersStoreListFollowingsFunc) History() []UsersStoreListFollowingsFuncCall {
  3444. f.mutex.Lock()
  3445. history := make([]UsersStoreListFollowingsFuncCall, len(f.history))
  3446. copy(history, f.history)
  3447. f.mutex.Unlock()
  3448. return history
  3449. }
  3450. // UsersStoreListFollowingsFuncCall is an object that describes an
  3451. // invocation of method ListFollowings on an instance of MockUsersStore.
  3452. type UsersStoreListFollowingsFuncCall struct {
  3453. // Arg0 is the value of the 1st argument passed to this method
  3454. // invocation.
  3455. Arg0 context.Context
  3456. // Arg1 is the value of the 2nd argument passed to this method
  3457. // invocation.
  3458. Arg1 int64
  3459. // Arg2 is the value of the 3rd argument passed to this method
  3460. // invocation.
  3461. Arg2 int
  3462. // Arg3 is the value of the 4th argument passed to this method
  3463. // invocation.
  3464. Arg3 int
  3465. // Result0 is the value of the 1st result returned from this method
  3466. // invocation.
  3467. Result0 []*db.User
  3468. // Result1 is the value of the 2nd result returned from this method
  3469. // invocation.
  3470. Result1 error
  3471. }
  3472. // Args returns an interface slice containing the arguments of this
  3473. // invocation.
  3474. func (c UsersStoreListFollowingsFuncCall) Args() []interface{} {
  3475. return []interface{}{c.Arg0, c.Arg1, c.Arg2, c.Arg3}
  3476. }
  3477. // Results returns an interface slice containing the results of this
  3478. // invocation.
  3479. func (c UsersStoreListFollowingsFuncCall) Results() []interface{} {
  3480. return []interface{}{c.Result0, c.Result1}
  3481. }
  3482. // UsersStoreUseCustomAvatarFunc describes the behavior when the
  3483. // UseCustomAvatar method of the parent MockUsersStore instance is invoked.
  3484. type UsersStoreUseCustomAvatarFunc struct {
  3485. defaultHook func(context.Context, int64, []byte) error
  3486. hooks []func(context.Context, int64, []byte) error
  3487. history []UsersStoreUseCustomAvatarFuncCall
  3488. mutex sync.Mutex
  3489. }
  3490. // UseCustomAvatar delegates to the next hook function in the queue and
  3491. // stores the parameter and result values of this invocation.
  3492. func (m *MockUsersStore) UseCustomAvatar(v0 context.Context, v1 int64, v2 []byte) error {
  3493. r0 := m.UseCustomAvatarFunc.nextHook()(v0, v1, v2)
  3494. m.UseCustomAvatarFunc.appendCall(UsersStoreUseCustomAvatarFuncCall{v0, v1, v2, r0})
  3495. return r0
  3496. }
  3497. // SetDefaultHook sets function that is called when the UseCustomAvatar
  3498. // method of the parent MockUsersStore instance is invoked and the hook
  3499. // queue is empty.
  3500. func (f *UsersStoreUseCustomAvatarFunc) SetDefaultHook(hook func(context.Context, int64, []byte) error) {
  3501. f.defaultHook = hook
  3502. }
  3503. // PushHook adds a function to the end of hook queue. Each invocation of the
  3504. // UseCustomAvatar method of the parent MockUsersStore instance invokes the
  3505. // hook at the front of the queue and discards it. After the queue is empty,
  3506. // the default hook function is invoked for any future action.
  3507. func (f *UsersStoreUseCustomAvatarFunc) PushHook(hook func(context.Context, int64, []byte) error) {
  3508. f.mutex.Lock()
  3509. f.hooks = append(f.hooks, hook)
  3510. f.mutex.Unlock()
  3511. }
  3512. // SetDefaultReturn calls SetDefaultHook with a function that returns the
  3513. // given values.
  3514. func (f *UsersStoreUseCustomAvatarFunc) SetDefaultReturn(r0 error) {
  3515. f.SetDefaultHook(func(context.Context, int64, []byte) error {
  3516. return r0
  3517. })
  3518. }
  3519. // PushReturn calls PushHook with a function that returns the given values.
  3520. func (f *UsersStoreUseCustomAvatarFunc) PushReturn(r0 error) {
  3521. f.PushHook(func(context.Context, int64, []byte) error {
  3522. return r0
  3523. })
  3524. }
  3525. func (f *UsersStoreUseCustomAvatarFunc) nextHook() func(context.Context, int64, []byte) error {
  3526. f.mutex.Lock()
  3527. defer f.mutex.Unlock()
  3528. if len(f.hooks) == 0 {
  3529. return f.defaultHook
  3530. }
  3531. hook := f.hooks[0]
  3532. f.hooks = f.hooks[1:]
  3533. return hook
  3534. }
  3535. func (f *UsersStoreUseCustomAvatarFunc) appendCall(r0 UsersStoreUseCustomAvatarFuncCall) {
  3536. f.mutex.Lock()
  3537. f.history = append(f.history, r0)
  3538. f.mutex.Unlock()
  3539. }
  3540. // History returns a sequence of UsersStoreUseCustomAvatarFuncCall objects
  3541. // describing the invocations of this function.
  3542. func (f *UsersStoreUseCustomAvatarFunc) History() []UsersStoreUseCustomAvatarFuncCall {
  3543. f.mutex.Lock()
  3544. history := make([]UsersStoreUseCustomAvatarFuncCall, len(f.history))
  3545. copy(history, f.history)
  3546. f.mutex.Unlock()
  3547. return history
  3548. }
  3549. // UsersStoreUseCustomAvatarFuncCall is an object that describes an
  3550. // invocation of method UseCustomAvatar on an instance of MockUsersStore.
  3551. type UsersStoreUseCustomAvatarFuncCall struct {
  3552. // Arg0 is the value of the 1st argument passed to this method
  3553. // invocation.
  3554. Arg0 context.Context
  3555. // Arg1 is the value of the 2nd argument passed to this method
  3556. // invocation.
  3557. Arg1 int64
  3558. // Arg2 is the value of the 3rd argument passed to this method
  3559. // invocation.
  3560. Arg2 []byte
  3561. // Result0 is the value of the 1st result returned from this method
  3562. // invocation.
  3563. Result0 error
  3564. }
  3565. // Args returns an interface slice containing the arguments of this
  3566. // invocation.
  3567. func (c UsersStoreUseCustomAvatarFuncCall) Args() []interface{} {
  3568. return []interface{}{c.Arg0, c.Arg1, c.Arg2}
  3569. }
  3570. // Results returns an interface slice containing the results of this
  3571. // invocation.
  3572. func (c UsersStoreUseCustomAvatarFuncCall) Results() []interface{} {
  3573. return []interface{}{c.Result0}
  3574. }