queue.go 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. // Code generated by moq; DO NOT EDIT.
  2. // github.com/matryer/moq
  3. package mock
  4. import (
  5. "context"
  6. "github.com/qor5/admin/worker"
  7. "sync"
  8. )
  9. // Ensure, that QueueMock does implement worker.Queue.
  10. // If this is not the case, regenerate this file with moq.
  11. var _ worker.Queue = &QueueMock{}
  12. // QueueMock is a mock implementation of worker.Queue.
  13. //
  14. // func TestSomethingThatUsesQueue(t *testing.T) {
  15. //
  16. // // make and configure a mocked worker.Queue
  17. // mockedQueue := &QueueMock{
  18. // AddFunc: func(ctx context.Context, job worker.QueJobInterface) error {
  19. // panic("mock out the Add method")
  20. // },
  21. // KillFunc: func(ctx context.Context, job worker.QueJobInterface) error {
  22. // panic("mock out the Kill method")
  23. // },
  24. // ListenFunc: func(jobDefs []*worker.QorJobDefinition, getJob func(qorJobID uint) (worker.QueJobInterface, error)) error {
  25. // panic("mock out the Listen method")
  26. // },
  27. // RemoveFunc: func(ctx context.Context, job worker.QueJobInterface) error {
  28. // panic("mock out the Remove method")
  29. // },
  30. // ShutdownFunc: func(ctx context.Context) error {
  31. // panic("mock out the Shutdown method")
  32. // },
  33. // }
  34. //
  35. // // use mockedQueue in code that requires worker.Queue
  36. // // and then make assertions.
  37. //
  38. // }
  39. type QueueMock struct {
  40. // AddFunc mocks the Add method.
  41. AddFunc func(ctx context.Context, job worker.QueJobInterface) error
  42. // KillFunc mocks the Kill method.
  43. KillFunc func(ctx context.Context, job worker.QueJobInterface) error
  44. // ListenFunc mocks the Listen method.
  45. ListenFunc func(jobDefs []*worker.QorJobDefinition, getJob func(qorJobID uint) (worker.QueJobInterface, error)) error
  46. // RemoveFunc mocks the Remove method.
  47. RemoveFunc func(ctx context.Context, job worker.QueJobInterface) error
  48. // ShutdownFunc mocks the Shutdown method.
  49. ShutdownFunc func(ctx context.Context) error
  50. // calls tracks calls to the methods.
  51. calls struct {
  52. // Add holds details about calls to the Add method.
  53. Add []struct {
  54. // Ctx is the ctx argument value.
  55. Ctx context.Context
  56. // Job is the job argument value.
  57. Job worker.QueJobInterface
  58. }
  59. // Kill holds details about calls to the Kill method.
  60. Kill []struct {
  61. // Ctx is the ctx argument value.
  62. Ctx context.Context
  63. // Job is the job argument value.
  64. Job worker.QueJobInterface
  65. }
  66. // Listen holds details about calls to the Listen method.
  67. Listen []struct {
  68. // JobDefs is the jobDefs argument value.
  69. JobDefs []*worker.QorJobDefinition
  70. // GetJob is the getJob argument value.
  71. GetJob func(qorJobID uint) (worker.QueJobInterface, error)
  72. }
  73. // Remove holds details about calls to the Remove method.
  74. Remove []struct {
  75. // Ctx is the ctx argument value.
  76. Ctx context.Context
  77. // Job is the job argument value.
  78. Job worker.QueJobInterface
  79. }
  80. // Shutdown holds details about calls to the Shutdown method.
  81. Shutdown []struct {
  82. // Ctx is the ctx argument value.
  83. Ctx context.Context
  84. }
  85. }
  86. lockAdd sync.RWMutex
  87. lockKill sync.RWMutex
  88. lockListen sync.RWMutex
  89. lockRemove sync.RWMutex
  90. lockShutdown sync.RWMutex
  91. }
  92. // Add calls AddFunc.
  93. func (mock *QueueMock) Add(ctx context.Context, job worker.QueJobInterface) error {
  94. if mock.AddFunc == nil {
  95. panic("QueueMock.AddFunc: method is nil but Queue.Add was just called")
  96. }
  97. callInfo := struct {
  98. Ctx context.Context
  99. Job worker.QueJobInterface
  100. }{
  101. Ctx: ctx,
  102. Job: job,
  103. }
  104. mock.lockAdd.Lock()
  105. mock.calls.Add = append(mock.calls.Add, callInfo)
  106. mock.lockAdd.Unlock()
  107. return mock.AddFunc(ctx, job)
  108. }
  109. // AddCalls gets all the calls that were made to Add.
  110. // Check the length with:
  111. //
  112. // len(mockedQueue.AddCalls())
  113. func (mock *QueueMock) AddCalls() []struct {
  114. Ctx context.Context
  115. Job worker.QueJobInterface
  116. } {
  117. var calls []struct {
  118. Ctx context.Context
  119. Job worker.QueJobInterface
  120. }
  121. mock.lockAdd.RLock()
  122. calls = mock.calls.Add
  123. mock.lockAdd.RUnlock()
  124. return calls
  125. }
  126. // Kill calls KillFunc.
  127. func (mock *QueueMock) Kill(ctx context.Context, job worker.QueJobInterface) error {
  128. if mock.KillFunc == nil {
  129. panic("QueueMock.KillFunc: method is nil but Queue.Kill was just called")
  130. }
  131. callInfo := struct {
  132. Ctx context.Context
  133. Job worker.QueJobInterface
  134. }{
  135. Ctx: ctx,
  136. Job: job,
  137. }
  138. mock.lockKill.Lock()
  139. mock.calls.Kill = append(mock.calls.Kill, callInfo)
  140. mock.lockKill.Unlock()
  141. return mock.KillFunc(ctx, job)
  142. }
  143. // KillCalls gets all the calls that were made to Kill.
  144. // Check the length with:
  145. //
  146. // len(mockedQueue.KillCalls())
  147. func (mock *QueueMock) KillCalls() []struct {
  148. Ctx context.Context
  149. Job worker.QueJobInterface
  150. } {
  151. var calls []struct {
  152. Ctx context.Context
  153. Job worker.QueJobInterface
  154. }
  155. mock.lockKill.RLock()
  156. calls = mock.calls.Kill
  157. mock.lockKill.RUnlock()
  158. return calls
  159. }
  160. // Listen calls ListenFunc.
  161. func (mock *QueueMock) Listen(jobDefs []*worker.QorJobDefinition, getJob func(qorJobID uint) (worker.QueJobInterface, error)) error {
  162. if mock.ListenFunc == nil {
  163. panic("QueueMock.ListenFunc: method is nil but Queue.Listen was just called")
  164. }
  165. callInfo := struct {
  166. JobDefs []*worker.QorJobDefinition
  167. GetJob func(qorJobID uint) (worker.QueJobInterface, error)
  168. }{
  169. JobDefs: jobDefs,
  170. GetJob: getJob,
  171. }
  172. mock.lockListen.Lock()
  173. mock.calls.Listen = append(mock.calls.Listen, callInfo)
  174. mock.lockListen.Unlock()
  175. return mock.ListenFunc(jobDefs, getJob)
  176. }
  177. // ListenCalls gets all the calls that were made to Listen.
  178. // Check the length with:
  179. //
  180. // len(mockedQueue.ListenCalls())
  181. func (mock *QueueMock) ListenCalls() []struct {
  182. JobDefs []*worker.QorJobDefinition
  183. GetJob func(qorJobID uint) (worker.QueJobInterface, error)
  184. } {
  185. var calls []struct {
  186. JobDefs []*worker.QorJobDefinition
  187. GetJob func(qorJobID uint) (worker.QueJobInterface, error)
  188. }
  189. mock.lockListen.RLock()
  190. calls = mock.calls.Listen
  191. mock.lockListen.RUnlock()
  192. return calls
  193. }
  194. // Remove calls RemoveFunc.
  195. func (mock *QueueMock) Remove(ctx context.Context, job worker.QueJobInterface) error {
  196. if mock.RemoveFunc == nil {
  197. panic("QueueMock.RemoveFunc: method is nil but Queue.Remove was just called")
  198. }
  199. callInfo := struct {
  200. Ctx context.Context
  201. Job worker.QueJobInterface
  202. }{
  203. Ctx: ctx,
  204. Job: job,
  205. }
  206. mock.lockRemove.Lock()
  207. mock.calls.Remove = append(mock.calls.Remove, callInfo)
  208. mock.lockRemove.Unlock()
  209. return mock.RemoveFunc(ctx, job)
  210. }
  211. // RemoveCalls gets all the calls that were made to Remove.
  212. // Check the length with:
  213. //
  214. // len(mockedQueue.RemoveCalls())
  215. func (mock *QueueMock) RemoveCalls() []struct {
  216. Ctx context.Context
  217. Job worker.QueJobInterface
  218. } {
  219. var calls []struct {
  220. Ctx context.Context
  221. Job worker.QueJobInterface
  222. }
  223. mock.lockRemove.RLock()
  224. calls = mock.calls.Remove
  225. mock.lockRemove.RUnlock()
  226. return calls
  227. }
  228. // Shutdown calls ShutdownFunc.
  229. func (mock *QueueMock) Shutdown(ctx context.Context) error {
  230. if mock.ShutdownFunc == nil {
  231. panic("QueueMock.ShutdownFunc: method is nil but Queue.Shutdown was just called")
  232. }
  233. callInfo := struct {
  234. Ctx context.Context
  235. }{
  236. Ctx: ctx,
  237. }
  238. mock.lockShutdown.Lock()
  239. mock.calls.Shutdown = append(mock.calls.Shutdown, callInfo)
  240. mock.lockShutdown.Unlock()
  241. return mock.ShutdownFunc(ctx)
  242. }
  243. // ShutdownCalls gets all the calls that were made to Shutdown.
  244. // Check the length with:
  245. //
  246. // len(mockedQueue.ShutdownCalls())
  247. func (mock *QueueMock) ShutdownCalls() []struct {
  248. Ctx context.Context
  249. } {
  250. var calls []struct {
  251. Ctx context.Context
  252. }
  253. mock.lockShutdown.RLock()
  254. calls = mock.calls.Shutdown
  255. mock.lockShutdown.RUnlock()
  256. return calls
  257. }