test_helpers.go 6.3 KB

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