on master help sign in
patch up test warnings
commitecab2f09da68b60e2b0e954c99eba27895b76343 authorAgentM <agentm@themactionfaction.com> dateSun 4 Oct 2020, 13:39 (6 years ago) parent711dee1
1 file changed+8−2
test/Curryer/Test/Basic.hs+8−2
test/Curryer/Test/Basic.hs+8−2
@@ -7,6 +7,7 @@ import GHC.Generics
77import Control.Concurrent.MVar
88import Network.Socket (SockAddr(..))
99import Control.Concurrent.Async
10+import Control.Monad
1011
1112import Network.RPC.Curryer.Server
1213import Network.RPC.Curryer.Client
@@ -43,6 +44,7 @@ testServerMessageHandler mAsyncMVar msg = do
4344 Nothing -> pure ()
4445 Just mvar -> putMVar mvar s
4546 pure NoResponse
47+ TestAsyncReq _ -> pure NoResponse
4648
4749-- test a simple client-to-server round-trip function execution
4850testSimpleCall :: Assertion
@@ -59,9 +61,11 @@ testSimpleCall = do
5961 conn <- mkConn
6062 let c :: IO (Either ConnectionError TestResponse)
6163 c = call conn (AddTwoNumbersReq 1 1)
62− x <- c
63− assertEqual "server request+response" (Right (AddTwoNumbersResp 2)) x
64+ replicateM_ 5 $ do --make five AddTwo calls to shake out parallelism bugs
65+ x <- c
66+ assertEqual "server request+response" (Right (AddTwoNumbersResp 2)) x
6467 close conn
68+ cancel server
6569
6670--test that the client can proces a server-initiated asynchronous callback from the server
6771testAsyncServerCall :: Assertion
@@ -84,6 +88,7 @@ testAsyncServerCall = do
8488 asyncMessage <- takeMVar receivedAsyncMessageVar
8589 assertEqual "async message" "welcome" asyncMessage
8690 close conn
91+ cancel server
8792
8893--test that the client can make a non-blocking call
8994testAsyncClientCall :: Assertion
@@ -100,3 +105,4 @@ testAsyncClientCall = do
100105 asyncMessage <- takeMVar receivedAsyncMessageVar
101106 assertEqual "async message" "hi server" asyncMessage
102107 close conn
108+ cancel server