|
1 | 1 | {-# LANGUAGE OverloadedStrings #-}
|
2 | 2 | {-# LANGUAGE ScopedTypeVariables #-}
|
3 |
| -{-# OPTIONS_GHC -Wno-redundant-constraints #-} |
4 | 3 |
|
5 | 4 | -- This file is part of the Wire Server implementation.
|
6 | 5 | --
|
|
19 | 18 | -- You should have received a copy of the GNU Affero General Public License along
|
20 | 19 | -- with this program. If not, see <https://www.gnu.org/licenses/>.
|
21 | 20 |
|
22 |
| -module TestLib.Cannon where |
| 21 | +module TestLib.Cannon |
| 22 | + ( WebSocket (..), |
| 23 | + WSConnect (..), |
| 24 | + ToWSConnect (..), |
| 25 | + withWebSocket, |
| 26 | + withWebSockets, |
| 27 | + awaitNMatchesResult, |
| 28 | + awaitNMatches, |
| 29 | + awaitMatch, |
| 30 | + nPayload, |
| 31 | + printAwaitResult, |
| 32 | + ) |
| 33 | +where |
23 | 34 |
|
24 | 35 | import Control.Concurrent.Async
|
25 | 36 | import Control.Exception (throwIO)
|
26 | 37 | import Control.Monad.Catch hiding (bracket)
|
27 | 38 | import qualified Control.Monad.Catch as Catch
|
28 | 39 | import Data.Aeson (Value (..), decodeStrict')
|
29 |
| -import Data.ByteString.Conversion (fromByteString, toByteString') |
| 40 | +import Data.ByteString.Conversion (fromByteString) |
| 41 | +import Data.ByteString.Conversion.To |
30 | 42 | import Imports
|
31 | 43 | import qualified Network.HTTP.Client as Http
|
32 | 44 | import qualified Network.WebSockets as WS
|
@@ -112,7 +124,6 @@ run wsConnect app = do
|
112 | 124 | Nothing -> ""
|
113 | 125 | Just client -> fromJust . fromByteString $ Http.queryString (Http.setQueryString [("client", Just (toByteString' client))] Http.defaultRequest)
|
114 | 126 | )
|
115 |
| - |
116 | 127 | caHdrs =
|
117 | 128 | [ ("Z-User", toByteString' (wsConnect.user)),
|
118 | 129 | ("Z-Connection", toByteString' connId)
|
@@ -272,7 +283,7 @@ awaitMatch ::
|
272 | 283 | App Value
|
273 | 284 | awaitMatch tSecs checkMatch ws = head <$> awaitNMatches 1 tSecs checkMatch ws
|
274 | 285 |
|
275 |
| -payload :: ProducesJSON a => a -> App Value |
276 |
| -payload event = do |
| 286 | +nPayload :: ProducesJSON a => a -> App Value |
| 287 | +nPayload event = do |
277 | 288 | payloads <- event %. "payload" & asList
|
278 | 289 | assertOne payloads
|
0 commit comments