mocks.go 51 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485
  1. // Code generated by go-mockgen 1.2.0; DO NOT EDIT.
  2. package db
  3. import (
  4. "context"
  5. "sync"
  6. lfsutil "gogs.io/gogs/internal/lfsutil"
  7. )
  8. // MockAccessTokensStore is a mock implementation of the AccessTokensStore
  9. // interface (from the package gogs.io/gogs/internal/db) used for unit
  10. // testing.
  11. type MockAccessTokensStore struct {
  12. // CreateFunc is an instance of a mock function object controlling the
  13. // behavior of the method Create.
  14. CreateFunc *AccessTokensStoreCreateFunc
  15. // DeleteByIDFunc is an instance of a mock function object controlling
  16. // the behavior of the method DeleteByID.
  17. DeleteByIDFunc *AccessTokensStoreDeleteByIDFunc
  18. // GetBySHA1Func is an instance of a mock function object controlling
  19. // the behavior of the method GetBySHA1.
  20. GetBySHA1Func *AccessTokensStoreGetBySHA1Func
  21. // ListFunc is an instance of a mock function object controlling the
  22. // behavior of the method List.
  23. ListFunc *AccessTokensStoreListFunc
  24. // TouchFunc is an instance of a mock function object controlling the
  25. // behavior of the method Touch.
  26. TouchFunc *AccessTokensStoreTouchFunc
  27. }
  28. // NewMockAccessTokensStore creates a new mock of the AccessTokensStore
  29. // interface. All methods return zero values for all results, unless
  30. // overwritten.
  31. func NewMockAccessTokensStore() *MockAccessTokensStore {
  32. return &MockAccessTokensStore{
  33. CreateFunc: &AccessTokensStoreCreateFunc{
  34. defaultHook: func(context.Context, int64, string) (r0 *AccessToken, r1 error) {
  35. return
  36. },
  37. },
  38. DeleteByIDFunc: &AccessTokensStoreDeleteByIDFunc{
  39. defaultHook: func(context.Context, int64, int64) (r0 error) {
  40. return
  41. },
  42. },
  43. GetBySHA1Func: &AccessTokensStoreGetBySHA1Func{
  44. defaultHook: func(context.Context, string) (r0 *AccessToken, r1 error) {
  45. return
  46. },
  47. },
  48. ListFunc: &AccessTokensStoreListFunc{
  49. defaultHook: func(context.Context, int64) (r0 []*AccessToken, r1 error) {
  50. return
  51. },
  52. },
  53. TouchFunc: &AccessTokensStoreTouchFunc{
  54. defaultHook: func(context.Context, int64) (r0 error) {
  55. return
  56. },
  57. },
  58. }
  59. }
  60. // NewStrictMockAccessTokensStore creates a new mock of the
  61. // AccessTokensStore interface. All methods panic on invocation, unless
  62. // overwritten.
  63. func NewStrictMockAccessTokensStore() *MockAccessTokensStore {
  64. return &MockAccessTokensStore{
  65. CreateFunc: &AccessTokensStoreCreateFunc{
  66. defaultHook: func(context.Context, int64, string) (*AccessToken, error) {
  67. panic("unexpected invocation of MockAccessTokensStore.Create")
  68. },
  69. },
  70. DeleteByIDFunc: &AccessTokensStoreDeleteByIDFunc{
  71. defaultHook: func(context.Context, int64, int64) error {
  72. panic("unexpected invocation of MockAccessTokensStore.DeleteByID")
  73. },
  74. },
  75. GetBySHA1Func: &AccessTokensStoreGetBySHA1Func{
  76. defaultHook: func(context.Context, string) (*AccessToken, error) {
  77. panic("unexpected invocation of MockAccessTokensStore.GetBySHA1")
  78. },
  79. },
  80. ListFunc: &AccessTokensStoreListFunc{
  81. defaultHook: func(context.Context, int64) ([]*AccessToken, error) {
  82. panic("unexpected invocation of MockAccessTokensStore.List")
  83. },
  84. },
  85. TouchFunc: &AccessTokensStoreTouchFunc{
  86. defaultHook: func(context.Context, int64) error {
  87. panic("unexpected invocation of MockAccessTokensStore.Touch")
  88. },
  89. },
  90. }
  91. }
  92. // NewMockAccessTokensStoreFrom creates a new mock of the
  93. // MockAccessTokensStore interface. All methods delegate to the given
  94. // implementation, unless overwritten.
  95. func NewMockAccessTokensStoreFrom(i AccessTokensStore) *MockAccessTokensStore {
  96. return &MockAccessTokensStore{
  97. CreateFunc: &AccessTokensStoreCreateFunc{
  98. defaultHook: i.Create,
  99. },
  100. DeleteByIDFunc: &AccessTokensStoreDeleteByIDFunc{
  101. defaultHook: i.DeleteByID,
  102. },
  103. GetBySHA1Func: &AccessTokensStoreGetBySHA1Func{
  104. defaultHook: i.GetBySHA1,
  105. },
  106. ListFunc: &AccessTokensStoreListFunc{
  107. defaultHook: i.List,
  108. },
  109. TouchFunc: &AccessTokensStoreTouchFunc{
  110. defaultHook: i.Touch,
  111. },
  112. }
  113. }
  114. // AccessTokensStoreCreateFunc describes the behavior when the Create method
  115. // of the parent MockAccessTokensStore instance is invoked.
  116. type AccessTokensStoreCreateFunc struct {
  117. defaultHook func(context.Context, int64, string) (*AccessToken, error)
  118. hooks []func(context.Context, int64, string) (*AccessToken, error)
  119. history []AccessTokensStoreCreateFuncCall
  120. mutex sync.Mutex
  121. }
  122. // Create delegates to the next hook function in the queue and stores the
  123. // parameter and result values of this invocation.
  124. func (m *MockAccessTokensStore) Create(v0 context.Context, v1 int64, v2 string) (*AccessToken, error) {
  125. r0, r1 := m.CreateFunc.nextHook()(v0, v1, v2)
  126. m.CreateFunc.appendCall(AccessTokensStoreCreateFuncCall{v0, v1, v2, r0, r1})
  127. return r0, r1
  128. }
  129. // SetDefaultHook sets function that is called when the Create method of the
  130. // parent MockAccessTokensStore instance is invoked and the hook queue is
  131. // empty.
  132. func (f *AccessTokensStoreCreateFunc) SetDefaultHook(hook func(context.Context, int64, string) (*AccessToken, error)) {
  133. f.defaultHook = hook
  134. }
  135. // PushHook adds a function to the end of hook queue. Each invocation of the
  136. // Create method of the parent MockAccessTokensStore instance invokes the
  137. // hook at the front of the queue and discards it. After the queue is empty,
  138. // the default hook function is invoked for any future action.
  139. func (f *AccessTokensStoreCreateFunc) PushHook(hook func(context.Context, int64, string) (*AccessToken, error)) {
  140. f.mutex.Lock()
  141. f.hooks = append(f.hooks, hook)
  142. f.mutex.Unlock()
  143. }
  144. // SetDefaultReturn calls SetDefaultHook with a function that returns the
  145. // given values.
  146. func (f *AccessTokensStoreCreateFunc) SetDefaultReturn(r0 *AccessToken, r1 error) {
  147. f.SetDefaultHook(func(context.Context, int64, string) (*AccessToken, error) {
  148. return r0, r1
  149. })
  150. }
  151. // PushReturn calls PushHook with a function that returns the given values.
  152. func (f *AccessTokensStoreCreateFunc) PushReturn(r0 *AccessToken, r1 error) {
  153. f.PushHook(func(context.Context, int64, string) (*AccessToken, error) {
  154. return r0, r1
  155. })
  156. }
  157. func (f *AccessTokensStoreCreateFunc) nextHook() func(context.Context, int64, string) (*AccessToken, error) {
  158. f.mutex.Lock()
  159. defer f.mutex.Unlock()
  160. if len(f.hooks) == 0 {
  161. return f.defaultHook
  162. }
  163. hook := f.hooks[0]
  164. f.hooks = f.hooks[1:]
  165. return hook
  166. }
  167. func (f *AccessTokensStoreCreateFunc) appendCall(r0 AccessTokensStoreCreateFuncCall) {
  168. f.mutex.Lock()
  169. f.history = append(f.history, r0)
  170. f.mutex.Unlock()
  171. }
  172. // History returns a sequence of AccessTokensStoreCreateFuncCall objects
  173. // describing the invocations of this function.
  174. func (f *AccessTokensStoreCreateFunc) History() []AccessTokensStoreCreateFuncCall {
  175. f.mutex.Lock()
  176. history := make([]AccessTokensStoreCreateFuncCall, len(f.history))
  177. copy(history, f.history)
  178. f.mutex.Unlock()
  179. return history
  180. }
  181. // AccessTokensStoreCreateFuncCall is an object that describes an invocation
  182. // of method Create on an instance of MockAccessTokensStore.
  183. type AccessTokensStoreCreateFuncCall struct {
  184. // Arg0 is the value of the 1st argument passed to this method
  185. // invocation.
  186. Arg0 context.Context
  187. // Arg1 is the value of the 2nd argument passed to this method
  188. // invocation.
  189. Arg1 int64
  190. // Arg2 is the value of the 3rd argument passed to this method
  191. // invocation.
  192. Arg2 string
  193. // Result0 is the value of the 1st result returned from this method
  194. // invocation.
  195. Result0 *AccessToken
  196. // Result1 is the value of the 2nd result returned from this method
  197. // invocation.
  198. Result1 error
  199. }
  200. // Args returns an interface slice containing the arguments of this
  201. // invocation.
  202. func (c AccessTokensStoreCreateFuncCall) Args() []interface{} {
  203. return []interface{}{c.Arg0, c.Arg1, c.Arg2}
  204. }
  205. // Results returns an interface slice containing the results of this
  206. // invocation.
  207. func (c AccessTokensStoreCreateFuncCall) Results() []interface{} {
  208. return []interface{}{c.Result0, c.Result1}
  209. }
  210. // AccessTokensStoreDeleteByIDFunc describes the behavior when the
  211. // DeleteByID method of the parent MockAccessTokensStore instance is
  212. // invoked.
  213. type AccessTokensStoreDeleteByIDFunc struct {
  214. defaultHook func(context.Context, int64, int64) error
  215. hooks []func(context.Context, int64, int64) error
  216. history []AccessTokensStoreDeleteByIDFuncCall
  217. mutex sync.Mutex
  218. }
  219. // DeleteByID delegates to the next hook function in the queue and stores
  220. // the parameter and result values of this invocation.
  221. func (m *MockAccessTokensStore) DeleteByID(v0 context.Context, v1 int64, v2 int64) error {
  222. r0 := m.DeleteByIDFunc.nextHook()(v0, v1, v2)
  223. m.DeleteByIDFunc.appendCall(AccessTokensStoreDeleteByIDFuncCall{v0, v1, v2, r0})
  224. return r0
  225. }
  226. // SetDefaultHook sets function that is called when the DeleteByID method of
  227. // the parent MockAccessTokensStore instance is invoked and the hook queue
  228. // is empty.
  229. func (f *AccessTokensStoreDeleteByIDFunc) SetDefaultHook(hook func(context.Context, int64, int64) error) {
  230. f.defaultHook = hook
  231. }
  232. // PushHook adds a function to the end of hook queue. Each invocation of the
  233. // DeleteByID method of the parent MockAccessTokensStore instance invokes
  234. // the hook at the front of the queue and discards it. After the queue is
  235. // empty, the default hook function is invoked for any future action.
  236. func (f *AccessTokensStoreDeleteByIDFunc) PushHook(hook func(context.Context, int64, int64) error) {
  237. f.mutex.Lock()
  238. f.hooks = append(f.hooks, hook)
  239. f.mutex.Unlock()
  240. }
  241. // SetDefaultReturn calls SetDefaultHook with a function that returns the
  242. // given values.
  243. func (f *AccessTokensStoreDeleteByIDFunc) SetDefaultReturn(r0 error) {
  244. f.SetDefaultHook(func(context.Context, int64, int64) error {
  245. return r0
  246. })
  247. }
  248. // PushReturn calls PushHook with a function that returns the given values.
  249. func (f *AccessTokensStoreDeleteByIDFunc) PushReturn(r0 error) {
  250. f.PushHook(func(context.Context, int64, int64) error {
  251. return r0
  252. })
  253. }
  254. func (f *AccessTokensStoreDeleteByIDFunc) nextHook() func(context.Context, int64, int64) error {
  255. f.mutex.Lock()
  256. defer f.mutex.Unlock()
  257. if len(f.hooks) == 0 {
  258. return f.defaultHook
  259. }
  260. hook := f.hooks[0]
  261. f.hooks = f.hooks[1:]
  262. return hook
  263. }
  264. func (f *AccessTokensStoreDeleteByIDFunc) appendCall(r0 AccessTokensStoreDeleteByIDFuncCall) {
  265. f.mutex.Lock()
  266. f.history = append(f.history, r0)
  267. f.mutex.Unlock()
  268. }
  269. // History returns a sequence of AccessTokensStoreDeleteByIDFuncCall objects
  270. // describing the invocations of this function.
  271. func (f *AccessTokensStoreDeleteByIDFunc) History() []AccessTokensStoreDeleteByIDFuncCall {
  272. f.mutex.Lock()
  273. history := make([]AccessTokensStoreDeleteByIDFuncCall, len(f.history))
  274. copy(history, f.history)
  275. f.mutex.Unlock()
  276. return history
  277. }
  278. // AccessTokensStoreDeleteByIDFuncCall is an object that describes an
  279. // invocation of method DeleteByID on an instance of MockAccessTokensStore.
  280. type AccessTokensStoreDeleteByIDFuncCall struct {
  281. // Arg0 is the value of the 1st argument passed to this method
  282. // invocation.
  283. Arg0 context.Context
  284. // Arg1 is the value of the 2nd argument passed to this method
  285. // invocation.
  286. Arg1 int64
  287. // Arg2 is the value of the 3rd argument passed to this method
  288. // invocation.
  289. Arg2 int64
  290. // Result0 is the value of the 1st result returned from this method
  291. // invocation.
  292. Result0 error
  293. }
  294. // Args returns an interface slice containing the arguments of this
  295. // invocation.
  296. func (c AccessTokensStoreDeleteByIDFuncCall) Args() []interface{} {
  297. return []interface{}{c.Arg0, c.Arg1, c.Arg2}
  298. }
  299. // Results returns an interface slice containing the results of this
  300. // invocation.
  301. func (c AccessTokensStoreDeleteByIDFuncCall) Results() []interface{} {
  302. return []interface{}{c.Result0}
  303. }
  304. // AccessTokensStoreGetBySHA1Func describes the behavior when the GetBySHA1
  305. // method of the parent MockAccessTokensStore instance is invoked.
  306. type AccessTokensStoreGetBySHA1Func struct {
  307. defaultHook func(context.Context, string) (*AccessToken, error)
  308. hooks []func(context.Context, string) (*AccessToken, error)
  309. history []AccessTokensStoreGetBySHA1FuncCall
  310. mutex sync.Mutex
  311. }
  312. // GetBySHA1 delegates to the next hook function in the queue and stores the
  313. // parameter and result values of this invocation.
  314. func (m *MockAccessTokensStore) GetBySHA1(v0 context.Context, v1 string) (*AccessToken, error) {
  315. r0, r1 := m.GetBySHA1Func.nextHook()(v0, v1)
  316. m.GetBySHA1Func.appendCall(AccessTokensStoreGetBySHA1FuncCall{v0, v1, r0, r1})
  317. return r0, r1
  318. }
  319. // SetDefaultHook sets function that is called when the GetBySHA1 method of
  320. // the parent MockAccessTokensStore instance is invoked and the hook queue
  321. // is empty.
  322. func (f *AccessTokensStoreGetBySHA1Func) SetDefaultHook(hook func(context.Context, string) (*AccessToken, error)) {
  323. f.defaultHook = hook
  324. }
  325. // PushHook adds a function to the end of hook queue. Each invocation of the
  326. // GetBySHA1 method of the parent MockAccessTokensStore instance invokes the
  327. // hook at the front of the queue and discards it. After the queue is empty,
  328. // the default hook function is invoked for any future action.
  329. func (f *AccessTokensStoreGetBySHA1Func) PushHook(hook func(context.Context, string) (*AccessToken, error)) {
  330. f.mutex.Lock()
  331. f.hooks = append(f.hooks, hook)
  332. f.mutex.Unlock()
  333. }
  334. // SetDefaultReturn calls SetDefaultHook with a function that returns the
  335. // given values.
  336. func (f *AccessTokensStoreGetBySHA1Func) SetDefaultReturn(r0 *AccessToken, r1 error) {
  337. f.SetDefaultHook(func(context.Context, string) (*AccessToken, error) {
  338. return r0, r1
  339. })
  340. }
  341. // PushReturn calls PushHook with a function that returns the given values.
  342. func (f *AccessTokensStoreGetBySHA1Func) PushReturn(r0 *AccessToken, r1 error) {
  343. f.PushHook(func(context.Context, string) (*AccessToken, error) {
  344. return r0, r1
  345. })
  346. }
  347. func (f *AccessTokensStoreGetBySHA1Func) nextHook() func(context.Context, string) (*AccessToken, error) {
  348. f.mutex.Lock()
  349. defer f.mutex.Unlock()
  350. if len(f.hooks) == 0 {
  351. return f.defaultHook
  352. }
  353. hook := f.hooks[0]
  354. f.hooks = f.hooks[1:]
  355. return hook
  356. }
  357. func (f *AccessTokensStoreGetBySHA1Func) appendCall(r0 AccessTokensStoreGetBySHA1FuncCall) {
  358. f.mutex.Lock()
  359. f.history = append(f.history, r0)
  360. f.mutex.Unlock()
  361. }
  362. // History returns a sequence of AccessTokensStoreGetBySHA1FuncCall objects
  363. // describing the invocations of this function.
  364. func (f *AccessTokensStoreGetBySHA1Func) History() []AccessTokensStoreGetBySHA1FuncCall {
  365. f.mutex.Lock()
  366. history := make([]AccessTokensStoreGetBySHA1FuncCall, len(f.history))
  367. copy(history, f.history)
  368. f.mutex.Unlock()
  369. return history
  370. }
  371. // AccessTokensStoreGetBySHA1FuncCall is an object that describes an
  372. // invocation of method GetBySHA1 on an instance of MockAccessTokensStore.
  373. type AccessTokensStoreGetBySHA1FuncCall struct {
  374. // Arg0 is the value of the 1st argument passed to this method
  375. // invocation.
  376. Arg0 context.Context
  377. // Arg1 is the value of the 2nd argument passed to this method
  378. // invocation.
  379. Arg1 string
  380. // Result0 is the value of the 1st result returned from this method
  381. // invocation.
  382. Result0 *AccessToken
  383. // Result1 is the value of the 2nd result returned from this method
  384. // invocation.
  385. Result1 error
  386. }
  387. // Args returns an interface slice containing the arguments of this
  388. // invocation.
  389. func (c AccessTokensStoreGetBySHA1FuncCall) Args() []interface{} {
  390. return []interface{}{c.Arg0, c.Arg1}
  391. }
  392. // Results returns an interface slice containing the results of this
  393. // invocation.
  394. func (c AccessTokensStoreGetBySHA1FuncCall) Results() []interface{} {
  395. return []interface{}{c.Result0, c.Result1}
  396. }
  397. // AccessTokensStoreListFunc describes the behavior when the List method of
  398. // the parent MockAccessTokensStore instance is invoked.
  399. type AccessTokensStoreListFunc struct {
  400. defaultHook func(context.Context, int64) ([]*AccessToken, error)
  401. hooks []func(context.Context, int64) ([]*AccessToken, error)
  402. history []AccessTokensStoreListFuncCall
  403. mutex sync.Mutex
  404. }
  405. // List delegates to the next hook function in the queue and stores the
  406. // parameter and result values of this invocation.
  407. func (m *MockAccessTokensStore) List(v0 context.Context, v1 int64) ([]*AccessToken, error) {
  408. r0, r1 := m.ListFunc.nextHook()(v0, v1)
  409. m.ListFunc.appendCall(AccessTokensStoreListFuncCall{v0, v1, r0, r1})
  410. return r0, r1
  411. }
  412. // SetDefaultHook sets function that is called when the List method of the
  413. // parent MockAccessTokensStore instance is invoked and the hook queue is
  414. // empty.
  415. func (f *AccessTokensStoreListFunc) SetDefaultHook(hook func(context.Context, int64) ([]*AccessToken, error)) {
  416. f.defaultHook = hook
  417. }
  418. // PushHook adds a function to the end of hook queue. Each invocation of the
  419. // List method of the parent MockAccessTokensStore instance invokes the hook
  420. // at the front of the queue and discards it. After the queue is empty, the
  421. // default hook function is invoked for any future action.
  422. func (f *AccessTokensStoreListFunc) PushHook(hook func(context.Context, int64) ([]*AccessToken, error)) {
  423. f.mutex.Lock()
  424. f.hooks = append(f.hooks, hook)
  425. f.mutex.Unlock()
  426. }
  427. // SetDefaultReturn calls SetDefaultHook with a function that returns the
  428. // given values.
  429. func (f *AccessTokensStoreListFunc) SetDefaultReturn(r0 []*AccessToken, r1 error) {
  430. f.SetDefaultHook(func(context.Context, int64) ([]*AccessToken, error) {
  431. return r0, r1
  432. })
  433. }
  434. // PushReturn calls PushHook with a function that returns the given values.
  435. func (f *AccessTokensStoreListFunc) PushReturn(r0 []*AccessToken, r1 error) {
  436. f.PushHook(func(context.Context, int64) ([]*AccessToken, error) {
  437. return r0, r1
  438. })
  439. }
  440. func (f *AccessTokensStoreListFunc) nextHook() func(context.Context, int64) ([]*AccessToken, error) {
  441. f.mutex.Lock()
  442. defer f.mutex.Unlock()
  443. if len(f.hooks) == 0 {
  444. return f.defaultHook
  445. }
  446. hook := f.hooks[0]
  447. f.hooks = f.hooks[1:]
  448. return hook
  449. }
  450. func (f *AccessTokensStoreListFunc) appendCall(r0 AccessTokensStoreListFuncCall) {
  451. f.mutex.Lock()
  452. f.history = append(f.history, r0)
  453. f.mutex.Unlock()
  454. }
  455. // History returns a sequence of AccessTokensStoreListFuncCall objects
  456. // describing the invocations of this function.
  457. func (f *AccessTokensStoreListFunc) History() []AccessTokensStoreListFuncCall {
  458. f.mutex.Lock()
  459. history := make([]AccessTokensStoreListFuncCall, len(f.history))
  460. copy(history, f.history)
  461. f.mutex.Unlock()
  462. return history
  463. }
  464. // AccessTokensStoreListFuncCall is an object that describes an invocation
  465. // of method List on an instance of MockAccessTokensStore.
  466. type AccessTokensStoreListFuncCall struct {
  467. // Arg0 is the value of the 1st argument passed to this method
  468. // invocation.
  469. Arg0 context.Context
  470. // Arg1 is the value of the 2nd argument passed to this method
  471. // invocation.
  472. Arg1 int64
  473. // Result0 is the value of the 1st result returned from this method
  474. // invocation.
  475. Result0 []*AccessToken
  476. // Result1 is the value of the 2nd result returned from this method
  477. // invocation.
  478. Result1 error
  479. }
  480. // Args returns an interface slice containing the arguments of this
  481. // invocation.
  482. func (c AccessTokensStoreListFuncCall) Args() []interface{} {
  483. return []interface{}{c.Arg0, c.Arg1}
  484. }
  485. // Results returns an interface slice containing the results of this
  486. // invocation.
  487. func (c AccessTokensStoreListFuncCall) Results() []interface{} {
  488. return []interface{}{c.Result0, c.Result1}
  489. }
  490. // AccessTokensStoreTouchFunc describes the behavior when the Touch method
  491. // of the parent MockAccessTokensStore instance is invoked.
  492. type AccessTokensStoreTouchFunc struct {
  493. defaultHook func(context.Context, int64) error
  494. hooks []func(context.Context, int64) error
  495. history []AccessTokensStoreTouchFuncCall
  496. mutex sync.Mutex
  497. }
  498. // Touch delegates to the next hook function in the queue and stores the
  499. // parameter and result values of this invocation.
  500. func (m *MockAccessTokensStore) Touch(v0 context.Context, v1 int64) error {
  501. r0 := m.TouchFunc.nextHook()(v0, v1)
  502. m.TouchFunc.appendCall(AccessTokensStoreTouchFuncCall{v0, v1, r0})
  503. return r0
  504. }
  505. // SetDefaultHook sets function that is called when the Touch method of the
  506. // parent MockAccessTokensStore instance is invoked and the hook queue is
  507. // empty.
  508. func (f *AccessTokensStoreTouchFunc) SetDefaultHook(hook func(context.Context, int64) error) {
  509. f.defaultHook = hook
  510. }
  511. // PushHook adds a function to the end of hook queue. Each invocation of the
  512. // Touch method of the parent MockAccessTokensStore instance invokes the
  513. // hook at the front of the queue and discards it. After the queue is empty,
  514. // the default hook function is invoked for any future action.
  515. func (f *AccessTokensStoreTouchFunc) PushHook(hook func(context.Context, int64) error) {
  516. f.mutex.Lock()
  517. f.hooks = append(f.hooks, hook)
  518. f.mutex.Unlock()
  519. }
  520. // SetDefaultReturn calls SetDefaultHook with a function that returns the
  521. // given values.
  522. func (f *AccessTokensStoreTouchFunc) SetDefaultReturn(r0 error) {
  523. f.SetDefaultHook(func(context.Context, int64) error {
  524. return r0
  525. })
  526. }
  527. // PushReturn calls PushHook with a function that returns the given values.
  528. func (f *AccessTokensStoreTouchFunc) PushReturn(r0 error) {
  529. f.PushHook(func(context.Context, int64) error {
  530. return r0
  531. })
  532. }
  533. func (f *AccessTokensStoreTouchFunc) nextHook() func(context.Context, int64) error {
  534. f.mutex.Lock()
  535. defer f.mutex.Unlock()
  536. if len(f.hooks) == 0 {
  537. return f.defaultHook
  538. }
  539. hook := f.hooks[0]
  540. f.hooks = f.hooks[1:]
  541. return hook
  542. }
  543. func (f *AccessTokensStoreTouchFunc) appendCall(r0 AccessTokensStoreTouchFuncCall) {
  544. f.mutex.Lock()
  545. f.history = append(f.history, r0)
  546. f.mutex.Unlock()
  547. }
  548. // History returns a sequence of AccessTokensStoreTouchFuncCall objects
  549. // describing the invocations of this function.
  550. func (f *AccessTokensStoreTouchFunc) History() []AccessTokensStoreTouchFuncCall {
  551. f.mutex.Lock()
  552. history := make([]AccessTokensStoreTouchFuncCall, len(f.history))
  553. copy(history, f.history)
  554. f.mutex.Unlock()
  555. return history
  556. }
  557. // AccessTokensStoreTouchFuncCall is an object that describes an invocation
  558. // of method Touch on an instance of MockAccessTokensStore.
  559. type AccessTokensStoreTouchFuncCall struct {
  560. // Arg0 is the value of the 1st argument passed to this method
  561. // invocation.
  562. Arg0 context.Context
  563. // Arg1 is the value of the 2nd argument passed to this method
  564. // invocation.
  565. Arg1 int64
  566. // Result0 is the value of the 1st result returned from this method
  567. // invocation.
  568. Result0 error
  569. }
  570. // Args returns an interface slice containing the arguments of this
  571. // invocation.
  572. func (c AccessTokensStoreTouchFuncCall) Args() []interface{} {
  573. return []interface{}{c.Arg0, c.Arg1}
  574. }
  575. // Results returns an interface slice containing the results of this
  576. // invocation.
  577. func (c AccessTokensStoreTouchFuncCall) Results() []interface{} {
  578. return []interface{}{c.Result0}
  579. }
  580. // MockLFSStore is a mock implementation of the LFSStore interface (from the
  581. // package gogs.io/gogs/internal/db) used for unit testing.
  582. type MockLFSStore struct {
  583. // CreateObjectFunc is an instance of a mock function object controlling
  584. // the behavior of the method CreateObject.
  585. CreateObjectFunc *LFSStoreCreateObjectFunc
  586. // GetObjectByOIDFunc is an instance of a mock function object
  587. // controlling the behavior of the method GetObjectByOID.
  588. GetObjectByOIDFunc *LFSStoreGetObjectByOIDFunc
  589. // GetObjectsByOIDsFunc is an instance of a mock function object
  590. // controlling the behavior of the method GetObjectsByOIDs.
  591. GetObjectsByOIDsFunc *LFSStoreGetObjectsByOIDsFunc
  592. }
  593. // NewMockLFSStore creates a new mock of the LFSStore interface. All methods
  594. // return zero values for all results, unless overwritten.
  595. func NewMockLFSStore() *MockLFSStore {
  596. return &MockLFSStore{
  597. CreateObjectFunc: &LFSStoreCreateObjectFunc{
  598. defaultHook: func(context.Context, int64, lfsutil.OID, int64, lfsutil.Storage) (r0 error) {
  599. return
  600. },
  601. },
  602. GetObjectByOIDFunc: &LFSStoreGetObjectByOIDFunc{
  603. defaultHook: func(context.Context, int64, lfsutil.OID) (r0 *LFSObject, r1 error) {
  604. return
  605. },
  606. },
  607. GetObjectsByOIDsFunc: &LFSStoreGetObjectsByOIDsFunc{
  608. defaultHook: func(context.Context, int64, ...lfsutil.OID) (r0 []*LFSObject, r1 error) {
  609. return
  610. },
  611. },
  612. }
  613. }
  614. // NewStrictMockLFSStore creates a new mock of the LFSStore interface. All
  615. // methods panic on invocation, unless overwritten.
  616. func NewStrictMockLFSStore() *MockLFSStore {
  617. return &MockLFSStore{
  618. CreateObjectFunc: &LFSStoreCreateObjectFunc{
  619. defaultHook: func(context.Context, int64, lfsutil.OID, int64, lfsutil.Storage) error {
  620. panic("unexpected invocation of MockLFSStore.CreateObject")
  621. },
  622. },
  623. GetObjectByOIDFunc: &LFSStoreGetObjectByOIDFunc{
  624. defaultHook: func(context.Context, int64, lfsutil.OID) (*LFSObject, error) {
  625. panic("unexpected invocation of MockLFSStore.GetObjectByOID")
  626. },
  627. },
  628. GetObjectsByOIDsFunc: &LFSStoreGetObjectsByOIDsFunc{
  629. defaultHook: func(context.Context, int64, ...lfsutil.OID) ([]*LFSObject, error) {
  630. panic("unexpected invocation of MockLFSStore.GetObjectsByOIDs")
  631. },
  632. },
  633. }
  634. }
  635. // NewMockLFSStoreFrom creates a new mock of the MockLFSStore interface. All
  636. // methods delegate to the given implementation, unless overwritten.
  637. func NewMockLFSStoreFrom(i LFSStore) *MockLFSStore {
  638. return &MockLFSStore{
  639. CreateObjectFunc: &LFSStoreCreateObjectFunc{
  640. defaultHook: i.CreateObject,
  641. },
  642. GetObjectByOIDFunc: &LFSStoreGetObjectByOIDFunc{
  643. defaultHook: i.GetObjectByOID,
  644. },
  645. GetObjectsByOIDsFunc: &LFSStoreGetObjectsByOIDsFunc{
  646. defaultHook: i.GetObjectsByOIDs,
  647. },
  648. }
  649. }
  650. // LFSStoreCreateObjectFunc describes the behavior when the CreateObject
  651. // method of the parent MockLFSStore instance is invoked.
  652. type LFSStoreCreateObjectFunc struct {
  653. defaultHook func(context.Context, int64, lfsutil.OID, int64, lfsutil.Storage) error
  654. hooks []func(context.Context, int64, lfsutil.OID, int64, lfsutil.Storage) error
  655. history []LFSStoreCreateObjectFuncCall
  656. mutex sync.Mutex
  657. }
  658. // CreateObject delegates to the next hook function in the queue and stores
  659. // the parameter and result values of this invocation.
  660. func (m *MockLFSStore) CreateObject(v0 context.Context, v1 int64, v2 lfsutil.OID, v3 int64, v4 lfsutil.Storage) error {
  661. r0 := m.CreateObjectFunc.nextHook()(v0, v1, v2, v3, v4)
  662. m.CreateObjectFunc.appendCall(LFSStoreCreateObjectFuncCall{v0, v1, v2, v3, v4, r0})
  663. return r0
  664. }
  665. // SetDefaultHook sets function that is called when the CreateObject method
  666. // of the parent MockLFSStore instance is invoked and the hook queue is
  667. // empty.
  668. func (f *LFSStoreCreateObjectFunc) SetDefaultHook(hook func(context.Context, int64, lfsutil.OID, int64, lfsutil.Storage) error) {
  669. f.defaultHook = hook
  670. }
  671. // PushHook adds a function to the end of hook queue. Each invocation of the
  672. // CreateObject method of the parent MockLFSStore instance invokes the hook
  673. // at the front of the queue and discards it. After the queue is empty, the
  674. // default hook function is invoked for any future action.
  675. func (f *LFSStoreCreateObjectFunc) PushHook(hook func(context.Context, int64, lfsutil.OID, int64, lfsutil.Storage) error) {
  676. f.mutex.Lock()
  677. f.hooks = append(f.hooks, hook)
  678. f.mutex.Unlock()
  679. }
  680. // SetDefaultReturn calls SetDefaultHook with a function that returns the
  681. // given values.
  682. func (f *LFSStoreCreateObjectFunc) SetDefaultReturn(r0 error) {
  683. f.SetDefaultHook(func(context.Context, int64, lfsutil.OID, int64, lfsutil.Storage) error {
  684. return r0
  685. })
  686. }
  687. // PushReturn calls PushHook with a function that returns the given values.
  688. func (f *LFSStoreCreateObjectFunc) PushReturn(r0 error) {
  689. f.PushHook(func(context.Context, int64, lfsutil.OID, int64, lfsutil.Storage) error {
  690. return r0
  691. })
  692. }
  693. func (f *LFSStoreCreateObjectFunc) nextHook() func(context.Context, int64, lfsutil.OID, int64, lfsutil.Storage) error {
  694. f.mutex.Lock()
  695. defer f.mutex.Unlock()
  696. if len(f.hooks) == 0 {
  697. return f.defaultHook
  698. }
  699. hook := f.hooks[0]
  700. f.hooks = f.hooks[1:]
  701. return hook
  702. }
  703. func (f *LFSStoreCreateObjectFunc) appendCall(r0 LFSStoreCreateObjectFuncCall) {
  704. f.mutex.Lock()
  705. f.history = append(f.history, r0)
  706. f.mutex.Unlock()
  707. }
  708. // History returns a sequence of LFSStoreCreateObjectFuncCall objects
  709. // describing the invocations of this function.
  710. func (f *LFSStoreCreateObjectFunc) History() []LFSStoreCreateObjectFuncCall {
  711. f.mutex.Lock()
  712. history := make([]LFSStoreCreateObjectFuncCall, len(f.history))
  713. copy(history, f.history)
  714. f.mutex.Unlock()
  715. return history
  716. }
  717. // LFSStoreCreateObjectFuncCall is an object that describes an invocation of
  718. // method CreateObject on an instance of MockLFSStore.
  719. type LFSStoreCreateObjectFuncCall struct {
  720. // Arg0 is the value of the 1st argument passed to this method
  721. // invocation.
  722. Arg0 context.Context
  723. // Arg1 is the value of the 2nd argument passed to this method
  724. // invocation.
  725. Arg1 int64
  726. // Arg2 is the value of the 3rd argument passed to this method
  727. // invocation.
  728. Arg2 lfsutil.OID
  729. // Arg3 is the value of the 4th argument passed to this method
  730. // invocation.
  731. Arg3 int64
  732. // Arg4 is the value of the 5th argument passed to this method
  733. // invocation.
  734. Arg4 lfsutil.Storage
  735. // Result0 is the value of the 1st result returned from this method
  736. // invocation.
  737. Result0 error
  738. }
  739. // Args returns an interface slice containing the arguments of this
  740. // invocation.
  741. func (c LFSStoreCreateObjectFuncCall) Args() []interface{} {
  742. return []interface{}{c.Arg0, c.Arg1, c.Arg2, c.Arg3, c.Arg4}
  743. }
  744. // Results returns an interface slice containing the results of this
  745. // invocation.
  746. func (c LFSStoreCreateObjectFuncCall) Results() []interface{} {
  747. return []interface{}{c.Result0}
  748. }
  749. // LFSStoreGetObjectByOIDFunc describes the behavior when the GetObjectByOID
  750. // method of the parent MockLFSStore instance is invoked.
  751. type LFSStoreGetObjectByOIDFunc struct {
  752. defaultHook func(context.Context, int64, lfsutil.OID) (*LFSObject, error)
  753. hooks []func(context.Context, int64, lfsutil.OID) (*LFSObject, error)
  754. history []LFSStoreGetObjectByOIDFuncCall
  755. mutex sync.Mutex
  756. }
  757. // GetObjectByOID delegates to the next hook function in the queue and
  758. // stores the parameter and result values of this invocation.
  759. func (m *MockLFSStore) GetObjectByOID(v0 context.Context, v1 int64, v2 lfsutil.OID) (*LFSObject, error) {
  760. r0, r1 := m.GetObjectByOIDFunc.nextHook()(v0, v1, v2)
  761. m.GetObjectByOIDFunc.appendCall(LFSStoreGetObjectByOIDFuncCall{v0, v1, v2, r0, r1})
  762. return r0, r1
  763. }
  764. // SetDefaultHook sets function that is called when the GetObjectByOID
  765. // method of the parent MockLFSStore instance is invoked and the hook queue
  766. // is empty.
  767. func (f *LFSStoreGetObjectByOIDFunc) SetDefaultHook(hook func(context.Context, int64, lfsutil.OID) (*LFSObject, error)) {
  768. f.defaultHook = hook
  769. }
  770. // PushHook adds a function to the end of hook queue. Each invocation of the
  771. // GetObjectByOID method of the parent MockLFSStore instance invokes the
  772. // hook at the front of the queue and discards it. After the queue is empty,
  773. // the default hook function is invoked for any future action.
  774. func (f *LFSStoreGetObjectByOIDFunc) PushHook(hook func(context.Context, int64, lfsutil.OID) (*LFSObject, error)) {
  775. f.mutex.Lock()
  776. f.hooks = append(f.hooks, hook)
  777. f.mutex.Unlock()
  778. }
  779. // SetDefaultReturn calls SetDefaultHook with a function that returns the
  780. // given values.
  781. func (f *LFSStoreGetObjectByOIDFunc) SetDefaultReturn(r0 *LFSObject, r1 error) {
  782. f.SetDefaultHook(func(context.Context, int64, lfsutil.OID) (*LFSObject, error) {
  783. return r0, r1
  784. })
  785. }
  786. // PushReturn calls PushHook with a function that returns the given values.
  787. func (f *LFSStoreGetObjectByOIDFunc) PushReturn(r0 *LFSObject, r1 error) {
  788. f.PushHook(func(context.Context, int64, lfsutil.OID) (*LFSObject, error) {
  789. return r0, r1
  790. })
  791. }
  792. func (f *LFSStoreGetObjectByOIDFunc) nextHook() func(context.Context, int64, lfsutil.OID) (*LFSObject, error) {
  793. f.mutex.Lock()
  794. defer f.mutex.Unlock()
  795. if len(f.hooks) == 0 {
  796. return f.defaultHook
  797. }
  798. hook := f.hooks[0]
  799. f.hooks = f.hooks[1:]
  800. return hook
  801. }
  802. func (f *LFSStoreGetObjectByOIDFunc) appendCall(r0 LFSStoreGetObjectByOIDFuncCall) {
  803. f.mutex.Lock()
  804. f.history = append(f.history, r0)
  805. f.mutex.Unlock()
  806. }
  807. // History returns a sequence of LFSStoreGetObjectByOIDFuncCall objects
  808. // describing the invocations of this function.
  809. func (f *LFSStoreGetObjectByOIDFunc) History() []LFSStoreGetObjectByOIDFuncCall {
  810. f.mutex.Lock()
  811. history := make([]LFSStoreGetObjectByOIDFuncCall, len(f.history))
  812. copy(history, f.history)
  813. f.mutex.Unlock()
  814. return history
  815. }
  816. // LFSStoreGetObjectByOIDFuncCall is an object that describes an invocation
  817. // of method GetObjectByOID on an instance of MockLFSStore.
  818. type LFSStoreGetObjectByOIDFuncCall struct {
  819. // Arg0 is the value of the 1st argument passed to this method
  820. // invocation.
  821. Arg0 context.Context
  822. // Arg1 is the value of the 2nd argument passed to this method
  823. // invocation.
  824. Arg1 int64
  825. // Arg2 is the value of the 3rd argument passed to this method
  826. // invocation.
  827. Arg2 lfsutil.OID
  828. // Result0 is the value of the 1st result returned from this method
  829. // invocation.
  830. Result0 *LFSObject
  831. // Result1 is the value of the 2nd result returned from this method
  832. // invocation.
  833. Result1 error
  834. }
  835. // Args returns an interface slice containing the arguments of this
  836. // invocation.
  837. func (c LFSStoreGetObjectByOIDFuncCall) Args() []interface{} {
  838. return []interface{}{c.Arg0, c.Arg1, c.Arg2}
  839. }
  840. // Results returns an interface slice containing the results of this
  841. // invocation.
  842. func (c LFSStoreGetObjectByOIDFuncCall) Results() []interface{} {
  843. return []interface{}{c.Result0, c.Result1}
  844. }
  845. // LFSStoreGetObjectsByOIDsFunc describes the behavior when the
  846. // GetObjectsByOIDs method of the parent MockLFSStore instance is invoked.
  847. type LFSStoreGetObjectsByOIDsFunc struct {
  848. defaultHook func(context.Context, int64, ...lfsutil.OID) ([]*LFSObject, error)
  849. hooks []func(context.Context, int64, ...lfsutil.OID) ([]*LFSObject, error)
  850. history []LFSStoreGetObjectsByOIDsFuncCall
  851. mutex sync.Mutex
  852. }
  853. // GetObjectsByOIDs delegates to the next hook function in the queue and
  854. // stores the parameter and result values of this invocation.
  855. func (m *MockLFSStore) GetObjectsByOIDs(v0 context.Context, v1 int64, v2 ...lfsutil.OID) ([]*LFSObject, error) {
  856. r0, r1 := m.GetObjectsByOIDsFunc.nextHook()(v0, v1, v2...)
  857. m.GetObjectsByOIDsFunc.appendCall(LFSStoreGetObjectsByOIDsFuncCall{v0, v1, v2, r0, r1})
  858. return r0, r1
  859. }
  860. // SetDefaultHook sets function that is called when the GetObjectsByOIDs
  861. // method of the parent MockLFSStore instance is invoked and the hook queue
  862. // is empty.
  863. func (f *LFSStoreGetObjectsByOIDsFunc) SetDefaultHook(hook func(context.Context, int64, ...lfsutil.OID) ([]*LFSObject, error)) {
  864. f.defaultHook = hook
  865. }
  866. // PushHook adds a function to the end of hook queue. Each invocation of the
  867. // GetObjectsByOIDs method of the parent MockLFSStore instance invokes the
  868. // hook at the front of the queue and discards it. After the queue is empty,
  869. // the default hook function is invoked for any future action.
  870. func (f *LFSStoreGetObjectsByOIDsFunc) PushHook(hook func(context.Context, int64, ...lfsutil.OID) ([]*LFSObject, error)) {
  871. f.mutex.Lock()
  872. f.hooks = append(f.hooks, hook)
  873. f.mutex.Unlock()
  874. }
  875. // SetDefaultReturn calls SetDefaultHook with a function that returns the
  876. // given values.
  877. func (f *LFSStoreGetObjectsByOIDsFunc) SetDefaultReturn(r0 []*LFSObject, r1 error) {
  878. f.SetDefaultHook(func(context.Context, int64, ...lfsutil.OID) ([]*LFSObject, error) {
  879. return r0, r1
  880. })
  881. }
  882. // PushReturn calls PushHook with a function that returns the given values.
  883. func (f *LFSStoreGetObjectsByOIDsFunc) PushReturn(r0 []*LFSObject, r1 error) {
  884. f.PushHook(func(context.Context, int64, ...lfsutil.OID) ([]*LFSObject, error) {
  885. return r0, r1
  886. })
  887. }
  888. func (f *LFSStoreGetObjectsByOIDsFunc) nextHook() func(context.Context, int64, ...lfsutil.OID) ([]*LFSObject, error) {
  889. f.mutex.Lock()
  890. defer f.mutex.Unlock()
  891. if len(f.hooks) == 0 {
  892. return f.defaultHook
  893. }
  894. hook := f.hooks[0]
  895. f.hooks = f.hooks[1:]
  896. return hook
  897. }
  898. func (f *LFSStoreGetObjectsByOIDsFunc) appendCall(r0 LFSStoreGetObjectsByOIDsFuncCall) {
  899. f.mutex.Lock()
  900. f.history = append(f.history, r0)
  901. f.mutex.Unlock()
  902. }
  903. // History returns a sequence of LFSStoreGetObjectsByOIDsFuncCall objects
  904. // describing the invocations of this function.
  905. func (f *LFSStoreGetObjectsByOIDsFunc) History() []LFSStoreGetObjectsByOIDsFuncCall {
  906. f.mutex.Lock()
  907. history := make([]LFSStoreGetObjectsByOIDsFuncCall, len(f.history))
  908. copy(history, f.history)
  909. f.mutex.Unlock()
  910. return history
  911. }
  912. // LFSStoreGetObjectsByOIDsFuncCall is an object that describes an
  913. // invocation of method GetObjectsByOIDs on an instance of MockLFSStore.
  914. type LFSStoreGetObjectsByOIDsFuncCall struct {
  915. // Arg0 is the value of the 1st argument passed to this method
  916. // invocation.
  917. Arg0 context.Context
  918. // Arg1 is the value of the 2nd argument passed to this method
  919. // invocation.
  920. Arg1 int64
  921. // Arg2 is a slice containing the values of the variadic arguments
  922. // passed to this method invocation.
  923. Arg2 []lfsutil.OID
  924. // Result0 is the value of the 1st result returned from this method
  925. // invocation.
  926. Result0 []*LFSObject
  927. // Result1 is the value of the 2nd result returned from this method
  928. // invocation.
  929. Result1 error
  930. }
  931. // Args returns an interface slice containing the arguments of this
  932. // invocation. The variadic slice argument is flattened in this array such
  933. // that one positional argument and three variadic arguments would result in
  934. // a slice of four, not two.
  935. func (c LFSStoreGetObjectsByOIDsFuncCall) Args() []interface{} {
  936. trailing := []interface{}{}
  937. for _, val := range c.Arg2 {
  938. trailing = append(trailing, val)
  939. }
  940. return append([]interface{}{c.Arg0, c.Arg1}, trailing...)
  941. }
  942. // Results returns an interface slice containing the results of this
  943. // invocation.
  944. func (c LFSStoreGetObjectsByOIDsFuncCall) Results() []interface{} {
  945. return []interface{}{c.Result0, c.Result1}
  946. }
  947. // MockPermsStore is a mock implementation of the PermsStore interface (from
  948. // the package gogs.io/gogs/internal/db) used for unit testing.
  949. type MockPermsStore struct {
  950. // AccessModeFunc is an instance of a mock function object controlling
  951. // the behavior of the method AccessMode.
  952. AccessModeFunc *PermsStoreAccessModeFunc
  953. // AuthorizeFunc is an instance of a mock function object controlling
  954. // the behavior of the method Authorize.
  955. AuthorizeFunc *PermsStoreAuthorizeFunc
  956. // SetRepoPermsFunc is an instance of a mock function object controlling
  957. // the behavior of the method SetRepoPerms.
  958. SetRepoPermsFunc *PermsStoreSetRepoPermsFunc
  959. }
  960. // NewMockPermsStore creates a new mock of the PermsStore interface. All
  961. // methods return zero values for all results, unless overwritten.
  962. func NewMockPermsStore() *MockPermsStore {
  963. return &MockPermsStore{
  964. AccessModeFunc: &PermsStoreAccessModeFunc{
  965. defaultHook: func(context.Context, int64, int64, AccessModeOptions) (r0 AccessMode) {
  966. return
  967. },
  968. },
  969. AuthorizeFunc: &PermsStoreAuthorizeFunc{
  970. defaultHook: func(context.Context, int64, int64, AccessMode, AccessModeOptions) (r0 bool) {
  971. return
  972. },
  973. },
  974. SetRepoPermsFunc: &PermsStoreSetRepoPermsFunc{
  975. defaultHook: func(context.Context, int64, map[int64]AccessMode) (r0 error) {
  976. return
  977. },
  978. },
  979. }
  980. }
  981. // NewStrictMockPermsStore creates a new mock of the PermsStore interface.
  982. // All methods panic on invocation, unless overwritten.
  983. func NewStrictMockPermsStore() *MockPermsStore {
  984. return &MockPermsStore{
  985. AccessModeFunc: &PermsStoreAccessModeFunc{
  986. defaultHook: func(context.Context, int64, int64, AccessModeOptions) AccessMode {
  987. panic("unexpected invocation of MockPermsStore.AccessMode")
  988. },
  989. },
  990. AuthorizeFunc: &PermsStoreAuthorizeFunc{
  991. defaultHook: func(context.Context, int64, int64, AccessMode, AccessModeOptions) bool {
  992. panic("unexpected invocation of MockPermsStore.Authorize")
  993. },
  994. },
  995. SetRepoPermsFunc: &PermsStoreSetRepoPermsFunc{
  996. defaultHook: func(context.Context, int64, map[int64]AccessMode) error {
  997. panic("unexpected invocation of MockPermsStore.SetRepoPerms")
  998. },
  999. },
  1000. }
  1001. }
  1002. // NewMockPermsStoreFrom creates a new mock of the MockPermsStore interface.
  1003. // All methods delegate to the given implementation, unless overwritten.
  1004. func NewMockPermsStoreFrom(i PermsStore) *MockPermsStore {
  1005. return &MockPermsStore{
  1006. AccessModeFunc: &PermsStoreAccessModeFunc{
  1007. defaultHook: i.AccessMode,
  1008. },
  1009. AuthorizeFunc: &PermsStoreAuthorizeFunc{
  1010. defaultHook: i.Authorize,
  1011. },
  1012. SetRepoPermsFunc: &PermsStoreSetRepoPermsFunc{
  1013. defaultHook: i.SetRepoPerms,
  1014. },
  1015. }
  1016. }
  1017. // PermsStoreAccessModeFunc describes the behavior when the AccessMode
  1018. // method of the parent MockPermsStore instance is invoked.
  1019. type PermsStoreAccessModeFunc struct {
  1020. defaultHook func(context.Context, int64, int64, AccessModeOptions) AccessMode
  1021. hooks []func(context.Context, int64, int64, AccessModeOptions) AccessMode
  1022. history []PermsStoreAccessModeFuncCall
  1023. mutex sync.Mutex
  1024. }
  1025. // AccessMode delegates to the next hook function in the queue and stores
  1026. // the parameter and result values of this invocation.
  1027. func (m *MockPermsStore) AccessMode(v0 context.Context, v1 int64, v2 int64, v3 AccessModeOptions) AccessMode {
  1028. r0 := m.AccessModeFunc.nextHook()(v0, v1, v2, v3)
  1029. m.AccessModeFunc.appendCall(PermsStoreAccessModeFuncCall{v0, v1, v2, v3, r0})
  1030. return r0
  1031. }
  1032. // SetDefaultHook sets function that is called when the AccessMode method of
  1033. // the parent MockPermsStore instance is invoked and the hook queue is
  1034. // empty.
  1035. func (f *PermsStoreAccessModeFunc) SetDefaultHook(hook func(context.Context, int64, int64, AccessModeOptions) AccessMode) {
  1036. f.defaultHook = hook
  1037. }
  1038. // PushHook adds a function to the end of hook queue. Each invocation of the
  1039. // AccessMode method of the parent MockPermsStore instance invokes the hook
  1040. // at the front of the queue and discards it. After the queue is empty, the
  1041. // default hook function is invoked for any future action.
  1042. func (f *PermsStoreAccessModeFunc) PushHook(hook func(context.Context, int64, int64, AccessModeOptions) AccessMode) {
  1043. f.mutex.Lock()
  1044. f.hooks = append(f.hooks, hook)
  1045. f.mutex.Unlock()
  1046. }
  1047. // SetDefaultReturn calls SetDefaultHook with a function that returns the
  1048. // given values.
  1049. func (f *PermsStoreAccessModeFunc) SetDefaultReturn(r0 AccessMode) {
  1050. f.SetDefaultHook(func(context.Context, int64, int64, AccessModeOptions) AccessMode {
  1051. return r0
  1052. })
  1053. }
  1054. // PushReturn calls PushHook with a function that returns the given values.
  1055. func (f *PermsStoreAccessModeFunc) PushReturn(r0 AccessMode) {
  1056. f.PushHook(func(context.Context, int64, int64, AccessModeOptions) AccessMode {
  1057. return r0
  1058. })
  1059. }
  1060. func (f *PermsStoreAccessModeFunc) nextHook() func(context.Context, int64, int64, AccessModeOptions) AccessMode {
  1061. f.mutex.Lock()
  1062. defer f.mutex.Unlock()
  1063. if len(f.hooks) == 0 {
  1064. return f.defaultHook
  1065. }
  1066. hook := f.hooks[0]
  1067. f.hooks = f.hooks[1:]
  1068. return hook
  1069. }
  1070. func (f *PermsStoreAccessModeFunc) appendCall(r0 PermsStoreAccessModeFuncCall) {
  1071. f.mutex.Lock()
  1072. f.history = append(f.history, r0)
  1073. f.mutex.Unlock()
  1074. }
  1075. // History returns a sequence of PermsStoreAccessModeFuncCall objects
  1076. // describing the invocations of this function.
  1077. func (f *PermsStoreAccessModeFunc) History() []PermsStoreAccessModeFuncCall {
  1078. f.mutex.Lock()
  1079. history := make([]PermsStoreAccessModeFuncCall, len(f.history))
  1080. copy(history, f.history)
  1081. f.mutex.Unlock()
  1082. return history
  1083. }
  1084. // PermsStoreAccessModeFuncCall is an object that describes an invocation of
  1085. // method AccessMode on an instance of MockPermsStore.
  1086. type PermsStoreAccessModeFuncCall struct {
  1087. // Arg0 is the value of the 1st argument passed to this method
  1088. // invocation.
  1089. Arg0 context.Context
  1090. // Arg1 is the value of the 2nd argument passed to this method
  1091. // invocation.
  1092. Arg1 int64
  1093. // Arg2 is the value of the 3rd argument passed to this method
  1094. // invocation.
  1095. Arg2 int64
  1096. // Arg3 is the value of the 4th argument passed to this method
  1097. // invocation.
  1098. Arg3 AccessModeOptions
  1099. // Result0 is the value of the 1st result returned from this method
  1100. // invocation.
  1101. Result0 AccessMode
  1102. }
  1103. // Args returns an interface slice containing the arguments of this
  1104. // invocation.
  1105. func (c PermsStoreAccessModeFuncCall) Args() []interface{} {
  1106. return []interface{}{c.Arg0, c.Arg1, c.Arg2, c.Arg3}
  1107. }
  1108. // Results returns an interface slice containing the results of this
  1109. // invocation.
  1110. func (c PermsStoreAccessModeFuncCall) Results() []interface{} {
  1111. return []interface{}{c.Result0}
  1112. }
  1113. // PermsStoreAuthorizeFunc describes the behavior when the Authorize method
  1114. // of the parent MockPermsStore instance is invoked.
  1115. type PermsStoreAuthorizeFunc struct {
  1116. defaultHook func(context.Context, int64, int64, AccessMode, AccessModeOptions) bool
  1117. hooks []func(context.Context, int64, int64, AccessMode, AccessModeOptions) bool
  1118. history []PermsStoreAuthorizeFuncCall
  1119. mutex sync.Mutex
  1120. }
  1121. // Authorize delegates to the next hook function in the queue and stores the
  1122. // parameter and result values of this invocation.
  1123. func (m *MockPermsStore) Authorize(v0 context.Context, v1 int64, v2 int64, v3 AccessMode, v4 AccessModeOptions) bool {
  1124. r0 := m.AuthorizeFunc.nextHook()(v0, v1, v2, v3, v4)
  1125. m.AuthorizeFunc.appendCall(PermsStoreAuthorizeFuncCall{v0, v1, v2, v3, v4, r0})
  1126. return r0
  1127. }
  1128. // SetDefaultHook sets function that is called when the Authorize method of
  1129. // the parent MockPermsStore instance is invoked and the hook queue is
  1130. // empty.
  1131. func (f *PermsStoreAuthorizeFunc) SetDefaultHook(hook func(context.Context, int64, int64, AccessMode, AccessModeOptions) bool) {
  1132. f.defaultHook = hook
  1133. }
  1134. // PushHook adds a function to the end of hook queue. Each invocation of the
  1135. // Authorize method of the parent MockPermsStore instance invokes the hook
  1136. // at the front of the queue and discards it. After the queue is empty, the
  1137. // default hook function is invoked for any future action.
  1138. func (f *PermsStoreAuthorizeFunc) PushHook(hook func(context.Context, int64, int64, AccessMode, AccessModeOptions) bool) {
  1139. f.mutex.Lock()
  1140. f.hooks = append(f.hooks, hook)
  1141. f.mutex.Unlock()
  1142. }
  1143. // SetDefaultReturn calls SetDefaultHook with a function that returns the
  1144. // given values.
  1145. func (f *PermsStoreAuthorizeFunc) SetDefaultReturn(r0 bool) {
  1146. f.SetDefaultHook(func(context.Context, int64, int64, AccessMode, AccessModeOptions) bool {
  1147. return r0
  1148. })
  1149. }
  1150. // PushReturn calls PushHook with a function that returns the given values.
  1151. func (f *PermsStoreAuthorizeFunc) PushReturn(r0 bool) {
  1152. f.PushHook(func(context.Context, int64, int64, AccessMode, AccessModeOptions) bool {
  1153. return r0
  1154. })
  1155. }
  1156. func (f *PermsStoreAuthorizeFunc) nextHook() func(context.Context, int64, int64, AccessMode, AccessModeOptions) bool {
  1157. f.mutex.Lock()
  1158. defer f.mutex.Unlock()
  1159. if len(f.hooks) == 0 {
  1160. return f.defaultHook
  1161. }
  1162. hook := f.hooks[0]
  1163. f.hooks = f.hooks[1:]
  1164. return hook
  1165. }
  1166. func (f *PermsStoreAuthorizeFunc) appendCall(r0 PermsStoreAuthorizeFuncCall) {
  1167. f.mutex.Lock()
  1168. f.history = append(f.history, r0)
  1169. f.mutex.Unlock()
  1170. }
  1171. // History returns a sequence of PermsStoreAuthorizeFuncCall objects
  1172. // describing the invocations of this function.
  1173. func (f *PermsStoreAuthorizeFunc) History() []PermsStoreAuthorizeFuncCall {
  1174. f.mutex.Lock()
  1175. history := make([]PermsStoreAuthorizeFuncCall, len(f.history))
  1176. copy(history, f.history)
  1177. f.mutex.Unlock()
  1178. return history
  1179. }
  1180. // PermsStoreAuthorizeFuncCall is an object that describes an invocation of
  1181. // method Authorize on an instance of MockPermsStore.
  1182. type PermsStoreAuthorizeFuncCall struct {
  1183. // Arg0 is the value of the 1st argument passed to this method
  1184. // invocation.
  1185. Arg0 context.Context
  1186. // Arg1 is the value of the 2nd argument passed to this method
  1187. // invocation.
  1188. Arg1 int64
  1189. // Arg2 is the value of the 3rd argument passed to this method
  1190. // invocation.
  1191. Arg2 int64
  1192. // Arg3 is the value of the 4th argument passed to this method
  1193. // invocation.
  1194. Arg3 AccessMode
  1195. // Arg4 is the value of the 5th argument passed to this method
  1196. // invocation.
  1197. Arg4 AccessModeOptions
  1198. // Result0 is the value of the 1st result returned from this method
  1199. // invocation.
  1200. Result0 bool
  1201. }
  1202. // Args returns an interface slice containing the arguments of this
  1203. // invocation.
  1204. func (c PermsStoreAuthorizeFuncCall) Args() []interface{} {
  1205. return []interface{}{c.Arg0, c.Arg1, c.Arg2, c.Arg3, c.Arg4}
  1206. }
  1207. // Results returns an interface slice containing the results of this
  1208. // invocation.
  1209. func (c PermsStoreAuthorizeFuncCall) Results() []interface{} {
  1210. return []interface{}{c.Result0}
  1211. }
  1212. // PermsStoreSetRepoPermsFunc describes the behavior when the SetRepoPerms
  1213. // method of the parent MockPermsStore instance is invoked.
  1214. type PermsStoreSetRepoPermsFunc struct {
  1215. defaultHook func(context.Context, int64, map[int64]AccessMode) error
  1216. hooks []func(context.Context, int64, map[int64]AccessMode) error
  1217. history []PermsStoreSetRepoPermsFuncCall
  1218. mutex sync.Mutex
  1219. }
  1220. // SetRepoPerms delegates to the next hook function in the queue and stores
  1221. // the parameter and result values of this invocation.
  1222. func (m *MockPermsStore) SetRepoPerms(v0 context.Context, v1 int64, v2 map[int64]AccessMode) error {
  1223. r0 := m.SetRepoPermsFunc.nextHook()(v0, v1, v2)
  1224. m.SetRepoPermsFunc.appendCall(PermsStoreSetRepoPermsFuncCall{v0, v1, v2, r0})
  1225. return r0
  1226. }
  1227. // SetDefaultHook sets function that is called when the SetRepoPerms method
  1228. // of the parent MockPermsStore instance is invoked and the hook queue is
  1229. // empty.
  1230. func (f *PermsStoreSetRepoPermsFunc) SetDefaultHook(hook func(context.Context, int64, map[int64]AccessMode) error) {
  1231. f.defaultHook = hook
  1232. }
  1233. // PushHook adds a function to the end of hook queue. Each invocation of the
  1234. // SetRepoPerms method of the parent MockPermsStore instance invokes the
  1235. // hook at the front of the queue and discards it. After the queue is empty,
  1236. // the default hook function is invoked for any future action.
  1237. func (f *PermsStoreSetRepoPermsFunc) PushHook(hook func(context.Context, int64, map[int64]AccessMode) error) {
  1238. f.mutex.Lock()
  1239. f.hooks = append(f.hooks, hook)
  1240. f.mutex.Unlock()
  1241. }
  1242. // SetDefaultReturn calls SetDefaultHook with a function that returns the
  1243. // given values.
  1244. func (f *PermsStoreSetRepoPermsFunc) SetDefaultReturn(r0 error) {
  1245. f.SetDefaultHook(func(context.Context, int64, map[int64]AccessMode) error {
  1246. return r0
  1247. })
  1248. }
  1249. // PushReturn calls PushHook with a function that returns the given values.
  1250. func (f *PermsStoreSetRepoPermsFunc) PushReturn(r0 error) {
  1251. f.PushHook(func(context.Context, int64, map[int64]AccessMode) error {
  1252. return r0
  1253. })
  1254. }
  1255. func (f *PermsStoreSetRepoPermsFunc) nextHook() func(context.Context, int64, map[int64]AccessMode) error {
  1256. f.mutex.Lock()
  1257. defer f.mutex.Unlock()
  1258. if len(f.hooks) == 0 {
  1259. return f.defaultHook
  1260. }
  1261. hook := f.hooks[0]
  1262. f.hooks = f.hooks[1:]
  1263. return hook
  1264. }
  1265. func (f *PermsStoreSetRepoPermsFunc) appendCall(r0 PermsStoreSetRepoPermsFuncCall) {
  1266. f.mutex.Lock()
  1267. f.history = append(f.history, r0)
  1268. f.mutex.Unlock()
  1269. }
  1270. // History returns a sequence of PermsStoreSetRepoPermsFuncCall objects
  1271. // describing the invocations of this function.
  1272. func (f *PermsStoreSetRepoPermsFunc) History() []PermsStoreSetRepoPermsFuncCall {
  1273. f.mutex.Lock()
  1274. history := make([]PermsStoreSetRepoPermsFuncCall, len(f.history))
  1275. copy(history, f.history)
  1276. f.mutex.Unlock()
  1277. return history
  1278. }
  1279. // PermsStoreSetRepoPermsFuncCall is an object that describes an invocation
  1280. // of method SetRepoPerms on an instance of MockPermsStore.
  1281. type PermsStoreSetRepoPermsFuncCall struct {
  1282. // Arg0 is the value of the 1st argument passed to this method
  1283. // invocation.
  1284. Arg0 context.Context
  1285. // Arg1 is the value of the 2nd argument passed to this method
  1286. // invocation.
  1287. Arg1 int64
  1288. // Arg2 is the value of the 3rd argument passed to this method
  1289. // invocation.
  1290. Arg2 map[int64]AccessMode
  1291. // Result0 is the value of the 1st result returned from this method
  1292. // invocation.
  1293. Result0 error
  1294. }
  1295. // Args returns an interface slice containing the arguments of this
  1296. // invocation.
  1297. func (c PermsStoreSetRepoPermsFuncCall) Args() []interface{} {
  1298. return []interface{}{c.Arg0, c.Arg1, c.Arg2}
  1299. }
  1300. // Results returns an interface slice containing the results of this
  1301. // invocation.
  1302. func (c PermsStoreSetRepoPermsFuncCall) Results() []interface{} {
  1303. return []interface{}{c.Result0}
  1304. }