Fix tests

This commit is contained in:
Gabriel Gonzalez 2019-06-03 12:30:07 -07:00
parent 68ce43f183
commit dffd2d19f2
3 changed files with 6 additions and 5 deletions

View file

@ -13,6 +13,7 @@ mkDerivation {
transformers vector transformers vector
]; ];
librarySystemDepends = [ grpc ]; librarySystemDepends = [ grpc ];
buildDepends = [ grpc ];
libraryToolDepends = [ c2hs ]; libraryToolDepends = [ c2hs ];
testHaskellDepends = [ testHaskellDepends = [
async base bytestring clock containers managed pipes proto3-suite async base bytestring clock containers managed pipes proto3-suite

View file

@ -34,7 +34,7 @@ import Test.Tasty
import Test.Tasty.HUnit ((@?=), assertString, testCase) import Test.Tasty.HUnit ((@?=), assertString, testCase)
testNormalCall client = testCase "Normal call" $ testNormalCall client = testCase "Normal call" $
do randoms <- fromList <$> replicateM 1000 (Fixed <$> randomRIO (1, 1000)) do randoms <- fromList <$> replicateM 1000 (randomRIO (1, 1000))
let req = SimpleServiceRequest "NormalRequest" randoms let req = SimpleServiceRequest "NormalRequest" randoms
res <- simpleServiceNormalCall client res <- simpleServiceNormalCall client
(ClientNormalRequest req 10 mempty) (ClientNormalRequest req 10 mempty)
@ -52,7 +52,7 @@ testClientStreamingCall client = testCase "Client-streaming call" $
do (finalName, totalSum) <- do (finalName, totalSum) <-
fmap ((mconcat *** (sum . mconcat)) . unzip) . fmap ((mconcat *** (sum . mconcat)) . unzip) .
replicateM iterationCount $ replicateM iterationCount $
do randoms <- fromList <$> replicateM 1000 (Fixed <$> randomRIO (1, 1000)) do randoms <- fromList <$> replicateM 1000 (randomRIO (1, 1000))
name <- fromString <$> replicateM 10 (randomRIO ('a', 'z')) name <- fromString <$> replicateM 10 (randomRIO ('a', 'z'))
send (SimpleServiceRequest name randoms) send (SimpleServiceRequest name randoms)
pure (name, randoms) pure (name, randoms)
@ -69,7 +69,7 @@ testClientStreamingCall client = testCase "Client-streaming call" $
testServerStreamingCall client = testCase "Server-streaming call" $ testServerStreamingCall client = testCase "Server-streaming call" $
do numCount <- randomRIO (50, 500) do numCount <- randomRIO (50, 500)
nums <- replicateM numCount (Fixed <$> randomIO) nums <- replicateM numCount (randomIO)
let checkResults [] recv = let checkResults [] recv =
do res <- recv do res <- recv
@ -98,7 +98,7 @@ testBiDiStreamingCall client = testCase "Bidi-streaming call" $
do let handleRequests (0 :: Int) _ _ done = done >> pure () do let handleRequests (0 :: Int) _ _ done = done >> pure ()
handleRequests n recv send done = handleRequests n recv send done =
do numCount <- randomRIO (10, 1000) do numCount <- randomRIO (10, 1000)
nums <- fromList <$> replicateM numCount (Fixed <$> randomRIO (1, 1000)) nums <- fromList <$> replicateM numCount (randomRIO (1, 1000))
testName <- fromString <$> replicateM 10 (randomRIO ('a', 'z')) testName <- fromString <$> replicateM 10 (randomRIO ('a', 'z'))
send (SimpleServiceRequest testName nums) send (SimpleServiceRequest testName nums)

View file

@ -38,4 +38,4 @@ server = beta_create_SimpleService_server(SimpleServiceServer())
server.add_insecure_port('[::]:50051') server.add_insecure_port('[::]:50051')
server.start() server.start()
done_queue.get() done_queue.get(True, 10)