mocks.go 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659
  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. // SaveFunc is an instance of a mock function object controlling the
  24. // behavior of the method Save.
  25. SaveFunc *AccessTokensStoreSaveFunc
  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. SaveFunc: &AccessTokensStoreSaveFunc{
  53. defaultHook: func(context.Context, *AccessToken) (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. SaveFunc: &AccessTokensStoreSaveFunc{
  85. defaultHook: func(context.Context, *AccessToken) error {
  86. panic("unexpected invocation of MockAccessTokensStore.Save")
  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. SaveFunc: &AccessTokensStoreSaveFunc{
  109. defaultHook: i.Save,
  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. // AccessTokensStoreSaveFunc describes the behavior when the Save method of
  490. // the parent MockAccessTokensStore instance is invoked.
  491. type AccessTokensStoreSaveFunc struct {
  492. defaultHook func(context.Context, *AccessToken) error
  493. hooks []func(context.Context, *AccessToken) error
  494. history []AccessTokensStoreSaveFuncCall
  495. mutex sync.Mutex
  496. }
  497. // Save delegates to the next hook function in the queue and stores the
  498. // parameter and result values of this invocation.
  499. func (m *MockAccessTokensStore) Save(v0 context.Context, v1 *AccessToken) error {
  500. r0 := m.SaveFunc.nextHook()(v0, v1)
  501. m.SaveFunc.appendCall(AccessTokensStoreSaveFuncCall{v0, v1, r0})
  502. return r0
  503. }
  504. // SetDefaultHook sets function that is called when the Save method of the
  505. // parent MockAccessTokensStore instance is invoked and the hook queue is
  506. // empty.
  507. func (f *AccessTokensStoreSaveFunc) SetDefaultHook(hook func(context.Context, *AccessToken) error) {
  508. f.defaultHook = hook
  509. }
  510. // PushHook adds a function to the end of hook queue. Each invocation of the
  511. // Save method of the parent MockAccessTokensStore instance invokes the hook
  512. // at the front of the queue and discards it. After the queue is empty, the
  513. // default hook function is invoked for any future action.
  514. func (f *AccessTokensStoreSaveFunc) PushHook(hook func(context.Context, *AccessToken) 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 *AccessTokensStoreSaveFunc) SetDefaultReturn(r0 error) {
  522. f.SetDefaultHook(func(context.Context, *AccessToken) error {
  523. return r0
  524. })
  525. }
  526. // PushReturn calls PushHook with a function that returns the given values.
  527. func (f *AccessTokensStoreSaveFunc) PushReturn(r0 error) {
  528. f.PushHook(func(context.Context, *AccessToken) error {
  529. return r0
  530. })
  531. }
  532. func (f *AccessTokensStoreSaveFunc) nextHook() func(context.Context, *AccessToken) 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 *AccessTokensStoreSaveFunc) appendCall(r0 AccessTokensStoreSaveFuncCall) {
  543. f.mutex.Lock()
  544. f.history = append(f.history, r0)
  545. f.mutex.Unlock()
  546. }
  547. // History returns a sequence of AccessTokensStoreSaveFuncCall objects
  548. // describing the invocations of this function.
  549. func (f *AccessTokensStoreSaveFunc) History() []AccessTokensStoreSaveFuncCall {
  550. f.mutex.Lock()
  551. history := make([]AccessTokensStoreSaveFuncCall, len(f.history))
  552. copy(history, f.history)
  553. f.mutex.Unlock()
  554. return history
  555. }
  556. // AccessTokensStoreSaveFuncCall is an object that describes an invocation
  557. // of method Save on an instance of MockAccessTokensStore.
  558. type AccessTokensStoreSaveFuncCall 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 *AccessToken
  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 AccessTokensStoreSaveFuncCall) 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 AccessTokensStoreSaveFuncCall) Results() []interface{} {
  577. return []interface{}{c.Result0}
  578. }