test_helpers.go 6.6 KB

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