queue.go 6.0 KB

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