test_helpers.go 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. package http
  2. import (
  3. "context"
  4. "net/mail"
  5. "github.com/mk6i/retro-aim-server/state"
  6. "github.com/mk6i/retro-aim-server/wire"
  7. )
  8. type mockParams struct {
  9. accountRetrieverParams
  10. bartRetrieverParams
  11. chatRoomCreatorParams
  12. chatRoomRetrieverParams
  13. chatSessionRetrieverParams
  14. directoryManagerParams
  15. feedBagRetrieverParams
  16. messageRelayerParams
  17. profileRetrieverParams
  18. sessionRetrieverParams
  19. userManagerParams
  20. }
  21. // accountRetrieverParams is a helper struct that contains mock parameters for
  22. // accountRetriever methods
  23. type accountRetrieverParams struct {
  24. emailAddressByNameParams
  25. regStatusByNameParams
  26. confirmStatusByNameParams
  27. }
  28. // emailAddressByNameParams is the list of parameters passed at the mock
  29. // accountRetriever.EmailAddressByName call site
  30. type emailAddressByNameParams []struct {
  31. screenName state.IdentScreenName
  32. result *mail.Address
  33. err error
  34. }
  35. // regStatusByNameParams is the list of parameters passed at the mock
  36. // accountRetriever.RegStatusByName call site
  37. type regStatusByNameParams []struct {
  38. screenName state.IdentScreenName
  39. result uint16
  40. err error
  41. }
  42. // confirmStatusByNameParams is the list of parameters passed at the mock
  43. // accountRetriever.ConfirmStatusByName call site
  44. type confirmStatusByNameParams []struct {
  45. screenName state.IdentScreenName
  46. result bool
  47. err error
  48. }
  49. // bartRetrieverParams is a helper struct that contains mock parameters for
  50. // BARTRetriever methods
  51. type bartRetrieverParams struct {
  52. bartRetrieveParams
  53. }
  54. // bartRetrieveParams is the list of parameters passed at the mock
  55. // BARTRetriever.BARTRetrieveParams call site
  56. type bartRetrieveParams []struct {
  57. itemHash []byte
  58. result []byte
  59. err error
  60. }
  61. // chatRoomCreatorParams is a helper struct that contains mock parameters for
  62. // ChatRoomCreator methods
  63. type chatRoomCreatorParams struct {
  64. createChatRoomParams
  65. }
  66. // createChatRoomParams is the list of parameters passed at the mock
  67. // ChatRoomCreator.CreateChatRoom call site
  68. type createChatRoomParams []struct {
  69. chatRoom *state.ChatRoom
  70. err error
  71. }
  72. // chatRoomRetrieverParams is a helper struct that contains mock parameters for
  73. // ChatRoomRetriever methods
  74. type chatRoomRetrieverParams struct {
  75. allChatRoomsParams
  76. }
  77. // allChatRoomsParams is the list of parameters passed at the mock
  78. // ChatRoomRetriever.AllChatRooms call site
  79. type allChatRoomsParams []struct {
  80. exchange uint16
  81. result []state.ChatRoom
  82. err error
  83. }
  84. // chatRoomRetrieverParams is a helper struct that contains mock parameters for
  85. // ChatRoomRetriever methods
  86. type chatSessionRetrieverParams struct {
  87. chatSessionRetrieverAllSessionsParams
  88. }
  89. // chatSessionRetrieverAllSessionsParams is the list of parameters passed at the mock
  90. // ChatSessionRetriever.AllSessions call site
  91. type chatSessionRetrieverAllSessionsParams []struct {
  92. cookie string
  93. result []*state.Session
  94. }
  95. type directoryManagerParams struct {
  96. categoriesParams
  97. createCategoryParams
  98. createKeywordParams
  99. deleteCategoryParams
  100. deleteKeywordParams
  101. keywordsByCategoryParams
  102. }
  103. // categoriesParams is the list of parameters passed at the mock
  104. // DirectoryManager.Categories call site
  105. type categoriesParams []struct {
  106. result []state.Category
  107. err error
  108. }
  109. // createCategoryParams is the list of parameters passed at the mock
  110. // DirectoryManager.CreateCategory call site
  111. type createCategoryParams []struct {
  112. name string
  113. result state.Category
  114. err error
  115. }
  116. // createKeywordParams is the list of parameters passed at the mock
  117. // DirectoryManager.CreateKeyword call site
  118. type createKeywordParams []struct {
  119. name string
  120. categoryID uint8
  121. result state.Keyword
  122. err error
  123. }
  124. // deleteCategoryParams is the list of parameters passed at the mock
  125. // DirectoryManager.DeleteCategory call site
  126. type deleteCategoryParams []struct {
  127. categoryID uint8
  128. err error
  129. }
  130. // deleteKeywordParams is the list of parameters passed at the mock
  131. // DirectoryManager.DeleteKeyword call site
  132. type deleteKeywordParams []struct {
  133. id uint8
  134. err error
  135. }
  136. // keywordsByCategoryParams is the list of parameters passed at the mock
  137. // DirectoryManager.KeywordsByCategory call site
  138. type keywordsByCategoryParams []struct {
  139. categoryID uint8
  140. result []state.Keyword
  141. err error
  142. }
  143. // feedBagRetrieverParams is a helper struct that contains mock parameters for
  144. // FeedBagRetriever methods
  145. type feedBagRetrieverParams struct {
  146. buddyIconRefByNameParams
  147. }
  148. // buddyIconRefByNameParams is the list of parameters passed at the mock
  149. // FeedBagRetriever.BuddyIconRefByNameParams call site
  150. type buddyIconRefByNameParams []struct {
  151. screenName state.IdentScreenName
  152. result *wire.BARTID
  153. err error
  154. }
  155. // messageRelayerParams is a helper struct that contains mock parameters for
  156. // MessageRelayer methods
  157. type messageRelayerParams struct {
  158. relayToScreenNameParams
  159. }
  160. // relayToScreenNameParams is the list of parameters passed at the mock
  161. // MessageRelayer.RelayToScreenNameParams call site
  162. type relayToScreenNameParams []struct {
  163. ctx context.Context
  164. screenName state.IdentScreenName
  165. msg wire.SNACMessage
  166. }
  167. // profileRetrieverParams is a helper struct that contains mock parameters for
  168. // ProfileRetriever methods
  169. type profileRetrieverParams struct {
  170. retrieveProfileParams
  171. }
  172. // retrieveProfileParams is the list of parameters passed at the mock
  173. // ProfileRetriever.Profile call site
  174. type retrieveProfileParams []struct {
  175. screenName state.IdentScreenName
  176. result string
  177. err error
  178. }
  179. // sessionRetrieverParams is a helper struct that contains mock parameters for
  180. // SessionRetriever methods
  181. type sessionRetrieverParams struct {
  182. sessionRetrieverAllSessionsParams
  183. retrieveSessionByNameParams
  184. }
  185. // sessionRetrieverAllSessionsParams is the list of parameters passed at the mock
  186. // SessionRetriever.AllSessions call site
  187. type sessionRetrieverAllSessionsParams []struct {
  188. result []*state.Session
  189. }
  190. // retrieveSessionParams is the list of parameters passed at the mock
  191. // SessionRetriever.RetrieveSessionByName call site
  192. type retrieveSessionByNameParams []struct {
  193. screenName state.IdentScreenName
  194. result *state.Session
  195. }
  196. // userManagerParams is a helper struct that contains mock parameters for
  197. // UserManager methods
  198. type userManagerParams struct {
  199. allUsersParams
  200. deleteUserParams
  201. getUserParams
  202. insertUserParams
  203. setUserPasswordParams
  204. }
  205. // allUsersParams is the list of parameters passed at the mock
  206. // UserManager.AllUsers call site
  207. type allUsersParams []struct {
  208. result []state.User
  209. err error
  210. }
  211. // deleteUserParams is the list of parameters passed at the mock
  212. // UserManager.DeleteUser call site
  213. type deleteUserParams []struct {
  214. screenName state.IdentScreenName
  215. err error
  216. }
  217. // getUserParams is the list of parameters passed at the mock
  218. // UserManager.User call site
  219. type getUserParams []struct {
  220. screenName state.IdentScreenName
  221. result *state.User
  222. err error
  223. }
  224. // insertUserParams is the list of parameters passed at the mock
  225. // UserManager.InsertUser call site
  226. type insertUserParams []struct {
  227. u state.User
  228. err error
  229. }
  230. // setUserPasswordParams is the list of parameters passed at the mock
  231. // UserManager.SetUserPassword call site
  232. type setUserPasswordParams []struct {
  233. screenName state.IdentScreenName
  234. newPassword string
  235. err error
  236. }