test_helpers.go 5.8 KB

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