-
Notifications
You must be signed in to change notification settings - Fork 35
/
SocketChannelTest.hs
46 lines (36 loc) · 1.16 KB
/
SocketChannelTest.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
{-
Copyright (c) Meta Platforms, Inc. and affiliates.
All rights reserved.
This source code is licensed under the BSD-style license found in the
LICENSE file in the root directory of this source tree.
-}
module SocketChannelTest where
import Network.Socket (maxListenQueue)
import TestRunner
import Test.HUnit hiding (State)
import Thrift.Api
import Thrift.Channel
import Thrift.Channel.SocketChannel.Server
import Thrift.Protocol.Id
import Math.Calculator.Client
import TestCommon
main :: IO ()
main = testRunner . TestList $
runChannelTests mkClientTestSockWith
[ addTest, divTest, putGetTest, putPutGetTest
, exceptionTest, unimplementedTest, multiTest ]
-- Client utilities ------------------------------------------------------------
mkClientTestSock
:: String
-> Thrift Calculator ()
-> Test
mkClientTestSock lbl = mkClientTestSockWith lbl defaultRpcOptions
mkClientTestSockWith
:: String
-> RpcOptions
-> Thrift Calculator ()
-> Test
mkClientTestSockWith lbl _opts action = TestLabel lbl $ TestCase $ do
state <- initServerState
withServer binaryProtocolId Nothing maxListenQueue (processCommand state)
(\_ _ -> []) action