mocks.go 36 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066
  1. // Code generated by go-mockgen 1.2.0; DO NOT EDIT.
  2. package db
  3. import (
  4. "context"
  5. "sync"
  6. )
  7. // MockAccessTokensStore is a mock implementation of the AccessTokensStore
  8. // interface (from the package gogs.io/gogs/internal/db) used for unit
  9. // testing.
  10. type MockAccessTokensStore struct {
  11. // CreateFunc is an instance of a mock function object controlling the
  12. // behavior of the method Create.
  13. CreateFunc *AccessTokensStoreCreateFunc
  14. // DeleteByIDFunc is an instance of a mock function object controlling
  15. // the behavior of the method DeleteByID.
  16. DeleteByIDFunc *AccessTokensStoreDeleteByIDFunc
  17. // GetBySHA1Func is an instance of a mock function object controlling
  18. // the behavior of the method GetBySHA1.
  19. GetBySHA1Func *AccessTokensStoreGetBySHA1Func
  20. // ListFunc is an instance of a mock function object controlling the
  21. // behavior of the method List.
  22. ListFunc *AccessTokensStoreListFunc
  23. // TouchFunc is an instance of a mock function object controlling the
  24. // behavior of the method Touch.
  25. TouchFunc *AccessTokensStoreTouchFunc
  26. }
  27. // NewMockAccessTokensStore creates a new mock of the AccessTokensStore
  28. // interface. All methods return zero values for all results, unless
  29. // overwritten.
  30. func NewMockAccessTokensStore() *MockAccessTokensStore {
  31. return &MockAccessTokensStore{
  32. CreateFunc: &AccessTokensStoreCreateFunc{
  33. defaultHook: func(context.Context, int64, string) (r0 *AccessToken, r1 error) {
  34. return
  35. },
  36. },
  37. DeleteByIDFunc: &AccessTokensStoreDeleteByIDFunc{
  38. defaultHook: func(context.Context, int64, int64) (r0 error) {
  39. return
  40. },
  41. },
  42. GetBySHA1Func: &AccessTokensStoreGetBySHA1Func{
  43. defaultHook: func(context.Context, string) (r0 *AccessToken, r1 error) {
  44. return
  45. },
  46. },
  47. ListFunc: &AccessTokensStoreListFunc{
  48. defaultHook: func(context.Context, int64) (r0 []*AccessToken, r1 error) {
  49. return
  50. },
  51. },
  52. TouchFunc: &AccessTokensStoreTouchFunc{
  53. defaultHook: func(context.Context, int64) (r0 error) {
  54. return
  55. },
  56. },
  57. }
  58. }
  59. // NewStrictMockAccessTokensStore creates a new mock of the
  60. // AccessTokensStore interface. All methods panic on invocation, unless
  61. // overwritten.
  62. func NewStrictMockAccessTokensStore() *MockAccessTokensStore {
  63. return &MockAccessTokensStore{
  64. CreateFunc: &AccessTokensStoreCreateFunc{
  65. defaultHook: func(context.Context, int64, string) (*AccessToken, error) {
  66. panic("unexpected invocation of MockAccessTokensStore.Create")
  67. },
  68. },
  69. DeleteByIDFunc: &AccessTokensStoreDeleteByIDFunc{
  70. defaultHook: func(context.Context, int64, int64) error {
  71. panic("unexpected invocation of MockAccessTokensStore.DeleteByID")
  72. },
  73. },
  74. GetBySHA1Func: &AccessTokensStoreGetBySHA1Func{
  75. defaultHook: func(context.Context, string) (*AccessToken, error) {
  76. panic("unexpected invocation of MockAccessTokensStore.GetBySHA1")
  77. },
  78. },
  79. ListFunc: &AccessTokensStoreListFunc{
  80. defaultHook: func(context.Context, int64) ([]*AccessToken, error) {
  81. panic("unexpected invocation of MockAccessTokensStore.List")
  82. },
  83. },
  84. TouchFunc: &AccessTokensStoreTouchFunc{
  85. defaultHook: func(context.Context, int64) error {
  86. panic("unexpected invocation of MockAccessTokensStore.Touch")
  87. },
  88. },
  89. }
  90. }
  91. // NewMockAccessTokensStoreFrom creates a new mock of the
  92. // MockAccessTokensStore interface. All methods delegate to the given
  93. // implementation, unless overwritten.
  94. func NewMockAccessTokensStoreFrom(i AccessTokensStore) *MockAccessTokensStore {
  95. return &MockAccessTokensStore{
  96. CreateFunc: &AccessTokensStoreCreateFunc{
  97. defaultHook: i.Create,
  98. },
  99. DeleteByIDFunc: &AccessTokensStoreDeleteByIDFunc{
  100. defaultHook: i.DeleteByID,
  101. },
  102. GetBySHA1Func: &AccessTokensStoreGetBySHA1Func{
  103. defaultHook: i.GetBySHA1,
  104. },
  105. ListFunc: &AccessTokensStoreListFunc{
  106. defaultHook: i.List,
  107. },
  108. TouchFunc: &AccessTokensStoreTouchFunc{
  109. defaultHook: i.Touch,
  110. },
  111. }
  112. }
  113. // AccessTokensStoreCreateFunc describes the behavior when the Create method
  114. // of the parent MockAccessTokensStore instance is invoked.
  115. type AccessTokensStoreCreateFunc struct {
  116. defaultHook func(context.Context, int64, string) (*AccessToken, error)
  117. hooks []func(context.Context, int64, string) (*AccessToken, error)
  118. history []AccessTokensStoreCreateFuncCall
  119. mutex sync.Mutex
  120. }
  121. // Create delegates to the next hook function in the queue and stores the
  122. // parameter and result values of this invocation.
  123. func (m *MockAccessTokensStore) Create(v0 context.Context, v1 int64, v2 string) (*AccessToken, error) {
  124. r0, r1 := m.CreateFunc.nextHook()(v0, v1, v2)
  125. m.CreateFunc.appendCall(AccessTokensStoreCreateFuncCall{v0, v1, v2, r0, r1})
  126. return r0, r1
  127. }
  128. // SetDefaultHook sets function that is called when the Create method of the
  129. // parent MockAccessTokensStore instance is invoked and the hook queue is
  130. // empty.
  131. func (f *AccessTokensStoreCreateFunc) SetDefaultHook(hook func(context.Context, int64, string) (*AccessToken, error)) {
  132. f.defaultHook = hook
  133. }
  134. // PushHook adds a function to the end of hook queue. Each invocation of the
  135. // Create method of the parent MockAccessTokensStore instance invokes the
  136. // hook at the front of the queue and discards it. After the queue is empty,
  137. // the default hook function is invoked for any future action.
  138. func (f *AccessTokensStoreCreateFunc) PushHook(hook func(context.Context, int64, string) (*AccessToken, error)) {
  139. f.mutex.Lock()
  140. f.hooks = append(f.hooks, hook)
  141. f.mutex.Unlock()
  142. }
  143. // SetDefaultReturn calls SetDefaultHook with a function that returns the
  144. // given values.
  145. func (f *AccessTokensStoreCreateFunc) SetDefaultReturn(r0 *AccessToken, r1 error) {
  146. f.SetDefaultHook(func(context.Context, int64, string) (*AccessToken, error) {
  147. return r0, r1
  148. })
  149. }
  150. // PushReturn calls PushHook with a function that returns the given values.
  151. func (f *AccessTokensStoreCreateFunc) PushReturn(r0 *AccessToken, r1 error) {
  152. f.PushHook(func(context.Context, int64, string) (*AccessToken, error) {
  153. return r0, r1
  154. })
  155. }
  156. func (f *AccessTokensStoreCreateFunc) nextHook() func(context.Context, int64, string) (*AccessToken, error) {
  157. f.mutex.Lock()
  158. defer f.mutex.Unlock()
  159. if len(f.hooks) == 0 {
  160. return f.defaultHook
  161. }
  162. hook := f.hooks[0]
  163. f.hooks = f.hooks[1:]
  164. return hook
  165. }
  166. func (f *AccessTokensStoreCreateFunc) appendCall(r0 AccessTokensStoreCreateFuncCall) {
  167. f.mutex.Lock()
  168. f.history = append(f.history, r0)
  169. f.mutex.Unlock()
  170. }
  171. // History returns a sequence of AccessTokensStoreCreateFuncCall objects
  172. // describing the invocations of this function.
  173. func (f *AccessTokensStoreCreateFunc) History() []AccessTokensStoreCreateFuncCall {
  174. f.mutex.Lock()
  175. history := make([]AccessTokensStoreCreateFuncCall, len(f.history))
  176. copy(history, f.history)
  177. f.mutex.Unlock()
  178. return history
  179. }
  180. // AccessTokensStoreCreateFuncCall is an object that describes an invocation
  181. // of method Create on an instance of MockAccessTokensStore.
  182. type AccessTokensStoreCreateFuncCall struct {
  183. // Arg0 is the value of the 1st argument passed to this method
  184. // invocation.
  185. Arg0 context.Context
  186. // Arg1 is the value of the 2nd argument passed to this method
  187. // invocation.
  188. Arg1 int64
  189. // Arg2 is the value of the 3rd argument passed to this method
  190. // invocation.
  191. Arg2 string
  192. // Result0 is the value of the 1st result returned from this method
  193. // invocation.
  194. Result0 *AccessToken
  195. // Result1 is the value of the 2nd result returned from this method
  196. // invocation.
  197. Result1 error
  198. }
  199. // Args returns an interface slice containing the arguments of this
  200. // invocation.
  201. func (c AccessTokensStoreCreateFuncCall) Args() []interface{} {
  202. return []interface{}{c.Arg0, c.Arg1, c.Arg2}
  203. }
  204. // Results returns an interface slice containing the results of this
  205. // invocation.
  206. func (c AccessTokensStoreCreateFuncCall) Results() []interface{} {
  207. return []interface{}{c.Result0, c.Result1}
  208. }
  209. // AccessTokensStoreDeleteByIDFunc describes the behavior when the
  210. // DeleteByID method of the parent MockAccessTokensStore instance is
  211. // invoked.
  212. type AccessTokensStoreDeleteByIDFunc struct {
  213. defaultHook func(context.Context, int64, int64) error
  214. hooks []func(context.Context, int64, int64) error
  215. history []AccessTokensStoreDeleteByIDFuncCall
  216. mutex sync.Mutex
  217. }
  218. // DeleteByID delegates to the next hook function in the queue and stores
  219. // the parameter and result values of this invocation.
  220. func (m *MockAccessTokensStore) DeleteByID(v0 context.Context, v1 int64, v2 int64) error {
  221. r0 := m.DeleteByIDFunc.nextHook()(v0, v1, v2)
  222. m.DeleteByIDFunc.appendCall(AccessTokensStoreDeleteByIDFuncCall{v0, v1, v2, r0})
  223. return r0
  224. }
  225. // SetDefaultHook sets function that is called when the DeleteByID method of
  226. // the parent MockAccessTokensStore instance is invoked and the hook queue
  227. // is empty.
  228. func (f *AccessTokensStoreDeleteByIDFunc) SetDefaultHook(hook func(context.Context, int64, int64) error) {
  229. f.defaultHook = hook
  230. }
  231. // PushHook adds a function to the end of hook queue. Each invocation of the
  232. // DeleteByID method of the parent MockAccessTokensStore instance invokes
  233. // the hook at the front of the queue and discards it. After the queue is
  234. // empty, the default hook function is invoked for any future action.
  235. func (f *AccessTokensStoreDeleteByIDFunc) PushHook(hook func(context.Context, int64, int64) error) {
  236. f.mutex.Lock()
  237. f.hooks = append(f.hooks, hook)
  238. f.mutex.Unlock()
  239. }
  240. // SetDefaultReturn calls SetDefaultHook with a function that returns the
  241. // given values.
  242. func (f *AccessTokensStoreDeleteByIDFunc) SetDefaultReturn(r0 error) {
  243. f.SetDefaultHook(func(context.Context, int64, int64) error {
  244. return r0
  245. })
  246. }
  247. // PushReturn calls PushHook with a function that returns the given values.
  248. func (f *AccessTokensStoreDeleteByIDFunc) PushReturn(r0 error) {
  249. f.PushHook(func(context.Context, int64, int64) error {
  250. return r0
  251. })
  252. }
  253. func (f *AccessTokensStoreDeleteByIDFunc) nextHook() func(context.Context, int64, int64) error {
  254. f.mutex.Lock()
  255. defer f.mutex.Unlock()
  256. if len(f.hooks) == 0 {
  257. return f.defaultHook
  258. }
  259. hook := f.hooks[0]
  260. f.hooks = f.hooks[1:]
  261. return hook
  262. }
  263. func (f *AccessTokensStoreDeleteByIDFunc) appendCall(r0 AccessTokensStoreDeleteByIDFuncCall) {
  264. f.mutex.Lock()
  265. f.history = append(f.history, r0)
  266. f.mutex.Unlock()
  267. }
  268. // History returns a sequence of AccessTokensStoreDeleteByIDFuncCall objects
  269. // describing the invocations of this function.
  270. func (f *AccessTokensStoreDeleteByIDFunc) History() []AccessTokensStoreDeleteByIDFuncCall {
  271. f.mutex.Lock()
  272. history := make([]AccessTokensStoreDeleteByIDFuncCall, len(f.history))
  273. copy(history, f.history)
  274. f.mutex.Unlock()
  275. return history
  276. }
  277. // AccessTokensStoreDeleteByIDFuncCall is an object that describes an
  278. // invocation of method DeleteByID on an instance of MockAccessTokensStore.
  279. type AccessTokensStoreDeleteByIDFuncCall struct {
  280. // Arg0 is the value of the 1st argument passed to this method
  281. // invocation.
  282. Arg0 context.Context
  283. // Arg1 is the value of the 2nd argument passed to this method
  284. // invocation.
  285. Arg1 int64
  286. // Arg2 is the value of the 3rd argument passed to this method
  287. // invocation.
  288. Arg2 int64
  289. // Result0 is the value of the 1st result returned from this method
  290. // invocation.
  291. Result0 error
  292. }
  293. // Args returns an interface slice containing the arguments of this
  294. // invocation.
  295. func (c AccessTokensStoreDeleteByIDFuncCall) Args() []interface{} {
  296. return []interface{}{c.Arg0, c.Arg1, c.Arg2}
  297. }
  298. // Results returns an interface slice containing the results of this
  299. // invocation.
  300. func (c AccessTokensStoreDeleteByIDFuncCall) Results() []interface{} {
  301. return []interface{}{c.Result0}
  302. }
  303. // AccessTokensStoreGetBySHA1Func describes the behavior when the GetBySHA1
  304. // method of the parent MockAccessTokensStore instance is invoked.
  305. type AccessTokensStoreGetBySHA1Func struct {
  306. defaultHook func(context.Context, string) (*AccessToken, error)
  307. hooks []func(context.Context, string) (*AccessToken, error)
  308. history []AccessTokensStoreGetBySHA1FuncCall
  309. mutex sync.Mutex
  310. }
  311. // GetBySHA1 delegates to the next hook function in the queue and stores the
  312. // parameter and result values of this invocation.
  313. func (m *MockAccessTokensStore) GetBySHA1(v0 context.Context, v1 string) (*AccessToken, error) {
  314. r0, r1 := m.GetBySHA1Func.nextHook()(v0, v1)
  315. m.GetBySHA1Func.appendCall(AccessTokensStoreGetBySHA1FuncCall{v0, v1, r0, r1})
  316. return r0, r1
  317. }
  318. // SetDefaultHook sets function that is called when the GetBySHA1 method of
  319. // the parent MockAccessTokensStore instance is invoked and the hook queue
  320. // is empty.
  321. func (f *AccessTokensStoreGetBySHA1Func) SetDefaultHook(hook func(context.Context, string) (*AccessToken, error)) {
  322. f.defaultHook = hook
  323. }
  324. // PushHook adds a function to the end of hook queue. Each invocation of the
  325. // GetBySHA1 method of the parent MockAccessTokensStore instance invokes the
  326. // hook at the front of the queue and discards it. After the queue is empty,
  327. // the default hook function is invoked for any future action.
  328. func (f *AccessTokensStoreGetBySHA1Func) PushHook(hook func(context.Context, string) (*AccessToken, error)) {
  329. f.mutex.Lock()
  330. f.hooks = append(f.hooks, hook)
  331. f.mutex.Unlock()
  332. }
  333. // SetDefaultReturn calls SetDefaultHook with a function that returns the
  334. // given values.
  335. func (f *AccessTokensStoreGetBySHA1Func) SetDefaultReturn(r0 *AccessToken, r1 error) {
  336. f.SetDefaultHook(func(context.Context, string) (*AccessToken, error) {
  337. return r0, r1
  338. })
  339. }
  340. // PushReturn calls PushHook with a function that returns the given values.
  341. func (f *AccessTokensStoreGetBySHA1Func) PushReturn(r0 *AccessToken, r1 error) {
  342. f.PushHook(func(context.Context, string) (*AccessToken, error) {
  343. return r0, r1
  344. })
  345. }
  346. func (f *AccessTokensStoreGetBySHA1Func) nextHook() func(context.Context, string) (*AccessToken, error) {
  347. f.mutex.Lock()
  348. defer f.mutex.Unlock()
  349. if len(f.hooks) == 0 {
  350. return f.defaultHook
  351. }
  352. hook := f.hooks[0]
  353. f.hooks = f.hooks[1:]
  354. return hook
  355. }
  356. func (f *AccessTokensStoreGetBySHA1Func) appendCall(r0 AccessTokensStoreGetBySHA1FuncCall) {
  357. f.mutex.Lock()
  358. f.history = append(f.history, r0)
  359. f.mutex.Unlock()
  360. }
  361. // History returns a sequence of AccessTokensStoreGetBySHA1FuncCall objects
  362. // describing the invocations of this function.
  363. func (f *AccessTokensStoreGetBySHA1Func) History() []AccessTokensStoreGetBySHA1FuncCall {
  364. f.mutex.Lock()
  365. history := make([]AccessTokensStoreGetBySHA1FuncCall, len(f.history))
  366. copy(history, f.history)
  367. f.mutex.Unlock()
  368. return history
  369. }
  370. // AccessTokensStoreGetBySHA1FuncCall is an object that describes an
  371. // invocation of method GetBySHA1 on an instance of MockAccessTokensStore.
  372. type AccessTokensStoreGetBySHA1FuncCall struct {
  373. // Arg0 is the value of the 1st argument passed to this method
  374. // invocation.
  375. Arg0 context.Context
  376. // Arg1 is the value of the 2nd argument passed to this method
  377. // invocation.
  378. Arg1 string
  379. // Result0 is the value of the 1st result returned from this method
  380. // invocation.
  381. Result0 *AccessToken
  382. // Result1 is the value of the 2nd result returned from this method
  383. // invocation.
  384. Result1 error
  385. }
  386. // Args returns an interface slice containing the arguments of this
  387. // invocation.
  388. func (c AccessTokensStoreGetBySHA1FuncCall) Args() []interface{} {
  389. return []interface{}{c.Arg0, c.Arg1}
  390. }
  391. // Results returns an interface slice containing the results of this
  392. // invocation.
  393. func (c AccessTokensStoreGetBySHA1FuncCall) Results() []interface{} {
  394. return []interface{}{c.Result0, c.Result1}
  395. }
  396. // AccessTokensStoreListFunc describes the behavior when the List method of
  397. // the parent MockAccessTokensStore instance is invoked.
  398. type AccessTokensStoreListFunc struct {
  399. defaultHook func(context.Context, int64) ([]*AccessToken, error)
  400. hooks []func(context.Context, int64) ([]*AccessToken, error)
  401. history []AccessTokensStoreListFuncCall
  402. mutex sync.Mutex
  403. }
  404. // List delegates to the next hook function in the queue and stores the
  405. // parameter and result values of this invocation.
  406. func (m *MockAccessTokensStore) List(v0 context.Context, v1 int64) ([]*AccessToken, error) {
  407. r0, r1 := m.ListFunc.nextHook()(v0, v1)
  408. m.ListFunc.appendCall(AccessTokensStoreListFuncCall{v0, v1, r0, r1})
  409. return r0, r1
  410. }
  411. // SetDefaultHook sets function that is called when the List method of the
  412. // parent MockAccessTokensStore instance is invoked and the hook queue is
  413. // empty.
  414. func (f *AccessTokensStoreListFunc) SetDefaultHook(hook func(context.Context, int64) ([]*AccessToken, error)) {
  415. f.defaultHook = hook
  416. }
  417. // PushHook adds a function to the end of hook queue. Each invocation of the
  418. // List method of the parent MockAccessTokensStore instance invokes the hook
  419. // at the front of the queue and discards it. After the queue is empty, the
  420. // default hook function is invoked for any future action.
  421. func (f *AccessTokensStoreListFunc) PushHook(hook func(context.Context, int64) ([]*AccessToken, error)) {
  422. f.mutex.Lock()
  423. f.hooks = append(f.hooks, hook)
  424. f.mutex.Unlock()
  425. }
  426. // SetDefaultReturn calls SetDefaultHook with a function that returns the
  427. // given values.
  428. func (f *AccessTokensStoreListFunc) SetDefaultReturn(r0 []*AccessToken, r1 error) {
  429. f.SetDefaultHook(func(context.Context, int64) ([]*AccessToken, error) {
  430. return r0, r1
  431. })
  432. }
  433. // PushReturn calls PushHook with a function that returns the given values.
  434. func (f *AccessTokensStoreListFunc) PushReturn(r0 []*AccessToken, r1 error) {
  435. f.PushHook(func(context.Context, int64) ([]*AccessToken, error) {
  436. return r0, r1
  437. })
  438. }
  439. func (f *AccessTokensStoreListFunc) nextHook() func(context.Context, int64) ([]*AccessToken, error) {
  440. f.mutex.Lock()
  441. defer f.mutex.Unlock()
  442. if len(f.hooks) == 0 {
  443. return f.defaultHook
  444. }
  445. hook := f.hooks[0]
  446. f.hooks = f.hooks[1:]
  447. return hook
  448. }
  449. func (f *AccessTokensStoreListFunc) appendCall(r0 AccessTokensStoreListFuncCall) {
  450. f.mutex.Lock()
  451. f.history = append(f.history, r0)
  452. f.mutex.Unlock()
  453. }
  454. // History returns a sequence of AccessTokensStoreListFuncCall objects
  455. // describing the invocations of this function.
  456. func (f *AccessTokensStoreListFunc) History() []AccessTokensStoreListFuncCall {
  457. f.mutex.Lock()
  458. history := make([]AccessTokensStoreListFuncCall, len(f.history))
  459. copy(history, f.history)
  460. f.mutex.Unlock()
  461. return history
  462. }
  463. // AccessTokensStoreListFuncCall is an object that describes an invocation
  464. // of method List on an instance of MockAccessTokensStore.
  465. type AccessTokensStoreListFuncCall struct {
  466. // Arg0 is the value of the 1st argument passed to this method
  467. // invocation.
  468. Arg0 context.Context
  469. // Arg1 is the value of the 2nd argument passed to this method
  470. // invocation.
  471. Arg1 int64
  472. // Result0 is the value of the 1st result returned from this method
  473. // invocation.
  474. Result0 []*AccessToken
  475. // Result1 is the value of the 2nd result returned from this method
  476. // invocation.
  477. Result1 error
  478. }
  479. // Args returns an interface slice containing the arguments of this
  480. // invocation.
  481. func (c AccessTokensStoreListFuncCall) Args() []interface{} {
  482. return []interface{}{c.Arg0, c.Arg1}
  483. }
  484. // Results returns an interface slice containing the results of this
  485. // invocation.
  486. func (c AccessTokensStoreListFuncCall) Results() []interface{} {
  487. return []interface{}{c.Result0, c.Result1}
  488. }
  489. // AccessTokensStoreTouchFunc describes the behavior when the Touch method
  490. // of the parent MockAccessTokensStore instance is invoked.
  491. type AccessTokensStoreTouchFunc struct {
  492. defaultHook func(context.Context, int64) error
  493. hooks []func(context.Context, int64) error
  494. history []AccessTokensStoreTouchFuncCall
  495. mutex sync.Mutex
  496. }
  497. // Touch delegates to the next hook function in the queue and stores the
  498. // parameter and result values of this invocation.
  499. func (m *MockAccessTokensStore) Touch(v0 context.Context, v1 int64) error {
  500. r0 := m.TouchFunc.nextHook()(v0, v1)
  501. m.TouchFunc.appendCall(AccessTokensStoreTouchFuncCall{v0, v1, r0})
  502. return r0
  503. }
  504. // SetDefaultHook sets function that is called when the Touch method of the
  505. // parent MockAccessTokensStore instance is invoked and the hook queue is
  506. // empty.
  507. func (f *AccessTokensStoreTouchFunc) SetDefaultHook(hook func(context.Context, int64) error) {
  508. f.defaultHook = hook
  509. }
  510. // PushHook adds a function to the end of hook queue. Each invocation of the
  511. // Touch method of the parent MockAccessTokensStore instance invokes the
  512. // hook at the front of the queue and discards it. After the queue is empty,
  513. // the default hook function is invoked for any future action.
  514. func (f *AccessTokensStoreTouchFunc) PushHook(hook func(context.Context, int64) error) {
  515. f.mutex.Lock()
  516. f.hooks = append(f.hooks, hook)
  517. f.mutex.Unlock()
  518. }
  519. // SetDefaultReturn calls SetDefaultHook with a function that returns the
  520. // given values.
  521. func (f *AccessTokensStoreTouchFunc) SetDefaultReturn(r0 error) {
  522. f.SetDefaultHook(func(context.Context, int64) error {
  523. return r0
  524. })
  525. }
  526. // PushReturn calls PushHook with a function that returns the given values.
  527. func (f *AccessTokensStoreTouchFunc) PushReturn(r0 error) {
  528. f.PushHook(func(context.Context, int64) error {
  529. return r0
  530. })
  531. }
  532. func (f *AccessTokensStoreTouchFunc) nextHook() func(context.Context, int64) error {
  533. f.mutex.Lock()
  534. defer f.mutex.Unlock()
  535. if len(f.hooks) == 0 {
  536. return f.defaultHook
  537. }
  538. hook := f.hooks[0]
  539. f.hooks = f.hooks[1:]
  540. return hook
  541. }
  542. func (f *AccessTokensStoreTouchFunc) appendCall(r0 AccessTokensStoreTouchFuncCall) {
  543. f.mutex.Lock()
  544. f.history = append(f.history, r0)
  545. f.mutex.Unlock()
  546. }
  547. // History returns a sequence of AccessTokensStoreTouchFuncCall objects
  548. // describing the invocations of this function.
  549. func (f *AccessTokensStoreTouchFunc) History() []AccessTokensStoreTouchFuncCall {
  550. f.mutex.Lock()
  551. history := make([]AccessTokensStoreTouchFuncCall, len(f.history))
  552. copy(history, f.history)
  553. f.mutex.Unlock()
  554. return history
  555. }
  556. // AccessTokensStoreTouchFuncCall is an object that describes an invocation
  557. // of method Touch on an instance of MockAccessTokensStore.
  558. type AccessTokensStoreTouchFuncCall struct {
  559. // Arg0 is the value of the 1st argument passed to this method
  560. // invocation.
  561. Arg0 context.Context
  562. // Arg1 is the value of the 2nd argument passed to this method
  563. // invocation.
  564. Arg1 int64
  565. // Result0 is the value of the 1st result returned from this method
  566. // invocation.
  567. Result0 error
  568. }
  569. // Args returns an interface slice containing the arguments of this
  570. // invocation.
  571. func (c AccessTokensStoreTouchFuncCall) Args() []interface{} {
  572. return []interface{}{c.Arg0, c.Arg1}
  573. }
  574. // Results returns an interface slice containing the results of this
  575. // invocation.
  576. func (c AccessTokensStoreTouchFuncCall) Results() []interface{} {
  577. return []interface{}{c.Result0}
  578. }
  579. // MockPermsStore is a mock implementation of the PermsStore interface (from
  580. // the package gogs.io/gogs/internal/db) used for unit testing.
  581. type MockPermsStore struct {
  582. // AccessModeFunc is an instance of a mock function object controlling
  583. // the behavior of the method AccessMode.
  584. AccessModeFunc *PermsStoreAccessModeFunc
  585. // AuthorizeFunc is an instance of a mock function object controlling
  586. // the behavior of the method Authorize.
  587. AuthorizeFunc *PermsStoreAuthorizeFunc
  588. // SetRepoPermsFunc is an instance of a mock function object controlling
  589. // the behavior of the method SetRepoPerms.
  590. SetRepoPermsFunc *PermsStoreSetRepoPermsFunc
  591. }
  592. // NewMockPermsStore creates a new mock of the PermsStore interface. All
  593. // methods return zero values for all results, unless overwritten.
  594. func NewMockPermsStore() *MockPermsStore {
  595. return &MockPermsStore{
  596. AccessModeFunc: &PermsStoreAccessModeFunc{
  597. defaultHook: func(context.Context, int64, int64, AccessModeOptions) (r0 AccessMode) {
  598. return
  599. },
  600. },
  601. AuthorizeFunc: &PermsStoreAuthorizeFunc{
  602. defaultHook: func(context.Context, int64, int64, AccessMode, AccessModeOptions) (r0 bool) {
  603. return
  604. },
  605. },
  606. SetRepoPermsFunc: &PermsStoreSetRepoPermsFunc{
  607. defaultHook: func(context.Context, int64, map[int64]AccessMode) (r0 error) {
  608. return
  609. },
  610. },
  611. }
  612. }
  613. // NewStrictMockPermsStore creates a new mock of the PermsStore interface.
  614. // All methods panic on invocation, unless overwritten.
  615. func NewStrictMockPermsStore() *MockPermsStore {
  616. return &MockPermsStore{
  617. AccessModeFunc: &PermsStoreAccessModeFunc{
  618. defaultHook: func(context.Context, int64, int64, AccessModeOptions) AccessMode {
  619. panic("unexpected invocation of MockPermsStore.AccessMode")
  620. },
  621. },
  622. AuthorizeFunc: &PermsStoreAuthorizeFunc{
  623. defaultHook: func(context.Context, int64, int64, AccessMode, AccessModeOptions) bool {
  624. panic("unexpected invocation of MockPermsStore.Authorize")
  625. },
  626. },
  627. SetRepoPermsFunc: &PermsStoreSetRepoPermsFunc{
  628. defaultHook: func(context.Context, int64, map[int64]AccessMode) error {
  629. panic("unexpected invocation of MockPermsStore.SetRepoPerms")
  630. },
  631. },
  632. }
  633. }
  634. // NewMockPermsStoreFrom creates a new mock of the MockPermsStore interface.
  635. // All methods delegate to the given implementation, unless overwritten.
  636. func NewMockPermsStoreFrom(i PermsStore) *MockPermsStore {
  637. return &MockPermsStore{
  638. AccessModeFunc: &PermsStoreAccessModeFunc{
  639. defaultHook: i.AccessMode,
  640. },
  641. AuthorizeFunc: &PermsStoreAuthorizeFunc{
  642. defaultHook: i.Authorize,
  643. },
  644. SetRepoPermsFunc: &PermsStoreSetRepoPermsFunc{
  645. defaultHook: i.SetRepoPerms,
  646. },
  647. }
  648. }
  649. // PermsStoreAccessModeFunc describes the behavior when the AccessMode
  650. // method of the parent MockPermsStore instance is invoked.
  651. type PermsStoreAccessModeFunc struct {
  652. defaultHook func(context.Context, int64, int64, AccessModeOptions) AccessMode
  653. hooks []func(context.Context, int64, int64, AccessModeOptions) AccessMode
  654. history []PermsStoreAccessModeFuncCall
  655. mutex sync.Mutex
  656. }
  657. // AccessMode delegates to the next hook function in the queue and stores
  658. // the parameter and result values of this invocation.
  659. func (m *MockPermsStore) AccessMode(v0 context.Context, v1 int64, v2 int64, v3 AccessModeOptions) AccessMode {
  660. r0 := m.AccessModeFunc.nextHook()(v0, v1, v2, v3)
  661. m.AccessModeFunc.appendCall(PermsStoreAccessModeFuncCall{v0, v1, v2, v3, r0})
  662. return r0
  663. }
  664. // SetDefaultHook sets function that is called when the AccessMode method of
  665. // the parent MockPermsStore instance is invoked and the hook queue is
  666. // empty.
  667. func (f *PermsStoreAccessModeFunc) SetDefaultHook(hook func(context.Context, int64, int64, AccessModeOptions) AccessMode) {
  668. f.defaultHook = hook
  669. }
  670. // PushHook adds a function to the end of hook queue. Each invocation of the
  671. // AccessMode method of the parent MockPermsStore instance invokes the hook
  672. // at the front of the queue and discards it. After the queue is empty, the
  673. // default hook function is invoked for any future action.
  674. func (f *PermsStoreAccessModeFunc) PushHook(hook func(context.Context, int64, int64, AccessModeOptions) AccessMode) {
  675. f.mutex.Lock()
  676. f.hooks = append(f.hooks, hook)
  677. f.mutex.Unlock()
  678. }
  679. // SetDefaultReturn calls SetDefaultHook with a function that returns the
  680. // given values.
  681. func (f *PermsStoreAccessModeFunc) SetDefaultReturn(r0 AccessMode) {
  682. f.SetDefaultHook(func(context.Context, int64, int64, AccessModeOptions) AccessMode {
  683. return r0
  684. })
  685. }
  686. // PushReturn calls PushHook with a function that returns the given values.
  687. func (f *PermsStoreAccessModeFunc) PushReturn(r0 AccessMode) {
  688. f.PushHook(func(context.Context, int64, int64, AccessModeOptions) AccessMode {
  689. return r0
  690. })
  691. }
  692. func (f *PermsStoreAccessModeFunc) nextHook() func(context.Context, int64, int64, AccessModeOptions) AccessMode {
  693. f.mutex.Lock()
  694. defer f.mutex.Unlock()
  695. if len(f.hooks) == 0 {
  696. return f.defaultHook
  697. }
  698. hook := f.hooks[0]
  699. f.hooks = f.hooks[1:]
  700. return hook
  701. }
  702. func (f *PermsStoreAccessModeFunc) appendCall(r0 PermsStoreAccessModeFuncCall) {
  703. f.mutex.Lock()
  704. f.history = append(f.history, r0)
  705. f.mutex.Unlock()
  706. }
  707. // History returns a sequence of PermsStoreAccessModeFuncCall objects
  708. // describing the invocations of this function.
  709. func (f *PermsStoreAccessModeFunc) History() []PermsStoreAccessModeFuncCall {
  710. f.mutex.Lock()
  711. history := make([]PermsStoreAccessModeFuncCall, len(f.history))
  712. copy(history, f.history)
  713. f.mutex.Unlock()
  714. return history
  715. }
  716. // PermsStoreAccessModeFuncCall is an object that describes an invocation of
  717. // method AccessMode on an instance of MockPermsStore.
  718. type PermsStoreAccessModeFuncCall struct {
  719. // Arg0 is the value of the 1st argument passed to this method
  720. // invocation.
  721. Arg0 context.Context
  722. // Arg1 is the value of the 2nd argument passed to this method
  723. // invocation.
  724. Arg1 int64
  725. // Arg2 is the value of the 3rd argument passed to this method
  726. // invocation.
  727. Arg2 int64
  728. // Arg3 is the value of the 4th argument passed to this method
  729. // invocation.
  730. Arg3 AccessModeOptions
  731. // Result0 is the value of the 1st result returned from this method
  732. // invocation.
  733. Result0 AccessMode
  734. }
  735. // Args returns an interface slice containing the arguments of this
  736. // invocation.
  737. func (c PermsStoreAccessModeFuncCall) Args() []interface{} {
  738. return []interface{}{c.Arg0, c.Arg1, c.Arg2, c.Arg3}
  739. }
  740. // Results returns an interface slice containing the results of this
  741. // invocation.
  742. func (c PermsStoreAccessModeFuncCall) Results() []interface{} {
  743. return []interface{}{c.Result0}
  744. }
  745. // PermsStoreAuthorizeFunc describes the behavior when the Authorize method
  746. // of the parent MockPermsStore instance is invoked.
  747. type PermsStoreAuthorizeFunc struct {
  748. defaultHook func(context.Context, int64, int64, AccessMode, AccessModeOptions) bool
  749. hooks []func(context.Context, int64, int64, AccessMode, AccessModeOptions) bool
  750. history []PermsStoreAuthorizeFuncCall
  751. mutex sync.Mutex
  752. }
  753. // Authorize delegates to the next hook function in the queue and stores the
  754. // parameter and result values of this invocation.
  755. func (m *MockPermsStore) Authorize(v0 context.Context, v1 int64, v2 int64, v3 AccessMode, v4 AccessModeOptions) bool {
  756. r0 := m.AuthorizeFunc.nextHook()(v0, v1, v2, v3, v4)
  757. m.AuthorizeFunc.appendCall(PermsStoreAuthorizeFuncCall{v0, v1, v2, v3, v4, r0})
  758. return r0
  759. }
  760. // SetDefaultHook sets function that is called when the Authorize method of
  761. // the parent MockPermsStore instance is invoked and the hook queue is
  762. // empty.
  763. func (f *PermsStoreAuthorizeFunc) SetDefaultHook(hook func(context.Context, int64, int64, AccessMode, AccessModeOptions) bool) {
  764. f.defaultHook = hook
  765. }
  766. // PushHook adds a function to the end of hook queue. Each invocation of the
  767. // Authorize method of the parent MockPermsStore instance invokes the hook
  768. // at the front of the queue and discards it. After the queue is empty, the
  769. // default hook function is invoked for any future action.
  770. func (f *PermsStoreAuthorizeFunc) PushHook(hook func(context.Context, int64, int64, AccessMode, AccessModeOptions) bool) {
  771. f.mutex.Lock()
  772. f.hooks = append(f.hooks, hook)
  773. f.mutex.Unlock()
  774. }
  775. // SetDefaultReturn calls SetDefaultHook with a function that returns the
  776. // given values.
  777. func (f *PermsStoreAuthorizeFunc) SetDefaultReturn(r0 bool) {
  778. f.SetDefaultHook(func(context.Context, int64, int64, AccessMode, AccessModeOptions) bool {
  779. return r0
  780. })
  781. }
  782. // PushReturn calls PushHook with a function that returns the given values.
  783. func (f *PermsStoreAuthorizeFunc) PushReturn(r0 bool) {
  784. f.PushHook(func(context.Context, int64, int64, AccessMode, AccessModeOptions) bool {
  785. return r0
  786. })
  787. }
  788. func (f *PermsStoreAuthorizeFunc) nextHook() func(context.Context, int64, int64, AccessMode, AccessModeOptions) bool {
  789. f.mutex.Lock()
  790. defer f.mutex.Unlock()
  791. if len(f.hooks) == 0 {
  792. return f.defaultHook
  793. }
  794. hook := f.hooks[0]
  795. f.hooks = f.hooks[1:]
  796. return hook
  797. }
  798. func (f *PermsStoreAuthorizeFunc) appendCall(r0 PermsStoreAuthorizeFuncCall) {
  799. f.mutex.Lock()
  800. f.history = append(f.history, r0)
  801. f.mutex.Unlock()
  802. }
  803. // History returns a sequence of PermsStoreAuthorizeFuncCall objects
  804. // describing the invocations of this function.
  805. func (f *PermsStoreAuthorizeFunc) History() []PermsStoreAuthorizeFuncCall {
  806. f.mutex.Lock()
  807. history := make([]PermsStoreAuthorizeFuncCall, len(f.history))
  808. copy(history, f.history)
  809. f.mutex.Unlock()
  810. return history
  811. }
  812. // PermsStoreAuthorizeFuncCall is an object that describes an invocation of
  813. // method Authorize on an instance of MockPermsStore.
  814. type PermsStoreAuthorizeFuncCall struct {
  815. // Arg0 is the value of the 1st argument passed to this method
  816. // invocation.
  817. Arg0 context.Context
  818. // Arg1 is the value of the 2nd argument passed to this method
  819. // invocation.
  820. Arg1 int64
  821. // Arg2 is the value of the 3rd argument passed to this method
  822. // invocation.
  823. Arg2 int64
  824. // Arg3 is the value of the 4th argument passed to this method
  825. // invocation.
  826. Arg3 AccessMode
  827. // Arg4 is the value of the 5th argument passed to this method
  828. // invocation.
  829. Arg4 AccessModeOptions
  830. // Result0 is the value of the 1st result returned from this method
  831. // invocation.
  832. Result0 bool
  833. }
  834. // Args returns an interface slice containing the arguments of this
  835. // invocation.
  836. func (c PermsStoreAuthorizeFuncCall) Args() []interface{} {
  837. return []interface{}{c.Arg0, c.Arg1, c.Arg2, c.Arg3, c.Arg4}
  838. }
  839. // Results returns an interface slice containing the results of this
  840. // invocation.
  841. func (c PermsStoreAuthorizeFuncCall) Results() []interface{} {
  842. return []interface{}{c.Result0}
  843. }
  844. // PermsStoreSetRepoPermsFunc describes the behavior when the SetRepoPerms
  845. // method of the parent MockPermsStore instance is invoked.
  846. type PermsStoreSetRepoPermsFunc struct {
  847. defaultHook func(context.Context, int64, map[int64]AccessMode) error
  848. hooks []func(context.Context, int64, map[int64]AccessMode) error
  849. history []PermsStoreSetRepoPermsFuncCall
  850. mutex sync.Mutex
  851. }
  852. // SetRepoPerms delegates to the next hook function in the queue and stores
  853. // the parameter and result values of this invocation.
  854. func (m *MockPermsStore) SetRepoPerms(v0 context.Context, v1 int64, v2 map[int64]AccessMode) error {
  855. r0 := m.SetRepoPermsFunc.nextHook()(v0, v1, v2)
  856. m.SetRepoPermsFunc.appendCall(PermsStoreSetRepoPermsFuncCall{v0, v1, v2, r0})
  857. return r0
  858. }
  859. // SetDefaultHook sets function that is called when the SetRepoPerms method
  860. // of the parent MockPermsStore instance is invoked and the hook queue is
  861. // empty.
  862. func (f *PermsStoreSetRepoPermsFunc) SetDefaultHook(hook func(context.Context, int64, map[int64]AccessMode) error) {
  863. f.defaultHook = hook
  864. }
  865. // PushHook adds a function to the end of hook queue. Each invocation of the
  866. // SetRepoPerms method of the parent MockPermsStore instance invokes the
  867. // hook at the front of the queue and discards it. After the queue is empty,
  868. // the default hook function is invoked for any future action.
  869. func (f *PermsStoreSetRepoPermsFunc) PushHook(hook func(context.Context, int64, map[int64]AccessMode) error) {
  870. f.mutex.Lock()
  871. f.hooks = append(f.hooks, hook)
  872. f.mutex.Unlock()
  873. }
  874. // SetDefaultReturn calls SetDefaultHook with a function that returns the
  875. // given values.
  876. func (f *PermsStoreSetRepoPermsFunc) SetDefaultReturn(r0 error) {
  877. f.SetDefaultHook(func(context.Context, int64, map[int64]AccessMode) error {
  878. return r0
  879. })
  880. }
  881. // PushReturn calls PushHook with a function that returns the given values.
  882. func (f *PermsStoreSetRepoPermsFunc) PushReturn(r0 error) {
  883. f.PushHook(func(context.Context, int64, map[int64]AccessMode) error {
  884. return r0
  885. })
  886. }
  887. func (f *PermsStoreSetRepoPermsFunc) nextHook() func(context.Context, int64, map[int64]AccessMode) error {
  888. f.mutex.Lock()
  889. defer f.mutex.Unlock()
  890. if len(f.hooks) == 0 {
  891. return f.defaultHook
  892. }
  893. hook := f.hooks[0]
  894. f.hooks = f.hooks[1:]
  895. return hook
  896. }
  897. func (f *PermsStoreSetRepoPermsFunc) appendCall(r0 PermsStoreSetRepoPermsFuncCall) {
  898. f.mutex.Lock()
  899. f.history = append(f.history, r0)
  900. f.mutex.Unlock()
  901. }
  902. // History returns a sequence of PermsStoreSetRepoPermsFuncCall objects
  903. // describing the invocations of this function.
  904. func (f *PermsStoreSetRepoPermsFunc) History() []PermsStoreSetRepoPermsFuncCall {
  905. f.mutex.Lock()
  906. history := make([]PermsStoreSetRepoPermsFuncCall, len(f.history))
  907. copy(history, f.history)
  908. f.mutex.Unlock()
  909. return history
  910. }
  911. // PermsStoreSetRepoPermsFuncCall is an object that describes an invocation
  912. // of method SetRepoPerms on an instance of MockPermsStore.
  913. type PermsStoreSetRepoPermsFuncCall struct {
  914. // Arg0 is the value of the 1st argument passed to this method
  915. // invocation.
  916. Arg0 context.Context
  917. // Arg1 is the value of the 2nd argument passed to this method
  918. // invocation.
  919. Arg1 int64
  920. // Arg2 is the value of the 3rd argument passed to this method
  921. // invocation.
  922. Arg2 map[int64]AccessMode
  923. // Result0 is the value of the 1st result returned from this method
  924. // invocation.
  925. Result0 error
  926. }
  927. // Args returns an interface slice containing the arguments of this
  928. // invocation.
  929. func (c PermsStoreSetRepoPermsFuncCall) Args() []interface{} {
  930. return []interface{}{c.Arg0, c.Arg1, c.Arg2}
  931. }
  932. // Results returns an interface slice containing the results of this
  933. // invocation.
  934. func (c PermsStoreSetRepoPermsFuncCall) Results() []interface{} {
  935. return []interface{}{c.Result0}
  936. }