mirror of
https://github.com/unclechu/gRPC-haskell.git
synced 2024-12-25 19:29:45 +01:00
Make test descriptions more structured and consistent
This commit is contained in:
parent
93e9a92328
commit
2262860af1
2 changed files with 29 additions and 26 deletions
|
@ -38,23 +38,23 @@ dummyMeta :: M.Map ByteString ByteString
|
|||
dummyMeta = M.fromList [("foo","bar")]
|
||||
|
||||
testGRPCBracket :: TestTree
|
||||
testGRPCBracket = testCase "No errors starting and stopping GRPC" $
|
||||
withGRPC $ const $ return ()
|
||||
testGRPCBracket = testCase "Start/stop GRPC" $
|
||||
withGRPC $ const $ return ()
|
||||
|
||||
testCompletionQueueCreateDestroy :: TestTree
|
||||
testCompletionQueueCreateDestroy =
|
||||
testCase "No errors creating and destroying a CQ" $ withGRPC $ \grpc ->
|
||||
testCase "Create/destroy completion queue" $ withGRPC $ \grpc ->
|
||||
withCompletionQueue grpc $ const (return ())
|
||||
|
||||
testServerCreateDestroy :: TestTree
|
||||
testServerCreateDestroy =
|
||||
testCase "No errors when starting and stopping a server" $
|
||||
testCase "Server - start/stop" $
|
||||
withGRPC $ \grpc -> withServer grpc (ServerConfig "localhost" 50051 [])
|
||||
(const $ return ())
|
||||
|
||||
testClientCreateDestroy :: TestTree
|
||||
testClientCreateDestroy =
|
||||
testCase "No errors when starting and stopping a client" $
|
||||
testCase "Client - start/stop" $
|
||||
withGRPC $ \grpc -> withClient grpc (ClientConfig "localhost" 50051)
|
||||
(const $ return ())
|
||||
|
||||
|
@ -107,7 +107,8 @@ testPayloadLowLevelServerUnregistered grpc = do
|
|||
Right _ -> return ()
|
||||
|
||||
testClientRequestNoServer :: TestTree
|
||||
testClientRequestNoServer = testCase "request times out when no server " $ do
|
||||
testClientRequestNoServer =
|
||||
testCase "Client - request timeout when server DNE" $
|
||||
withGRPC $ \grpc -> do
|
||||
withClient grpc (ClientConfig "localhost" 50051) $ \client -> do
|
||||
method <- clientRegisterMethod client "/foo" "localhost" Normal
|
||||
|
@ -115,7 +116,8 @@ testClientRequestNoServer = testCase "request times out when no server " $ do
|
|||
reqResult @?= (Left GRPCIOTimeout)
|
||||
|
||||
testServerAwaitNoClient :: TestTree
|
||||
testServerAwaitNoClient = testCase "server wait times out when no client " $ do
|
||||
testServerAwaitNoClient =
|
||||
testCase "Server - registered call handler timeout" $
|
||||
withGRPC $ \grpc -> do
|
||||
let conf = (ServerConfig "localhost" 50051 [("/foo", "localhost", Normal)])
|
||||
withServer grpc conf $ \server -> do
|
||||
|
@ -126,7 +128,7 @@ testServerAwaitNoClient = testCase "server wait times out when no client " $ do
|
|||
|
||||
testServerUnregisteredAwaitNoClient :: TestTree
|
||||
testServerUnregisteredAwaitNoClient =
|
||||
testCase "server wait times out when no client -- unregistered method " $ do
|
||||
testCase "Server - unregistered call handler timeout" $
|
||||
withGRPC $ \grpc -> do
|
||||
let conf = ServerConfig "localhost" 50051 []
|
||||
withServer grpc conf $ \server -> do
|
||||
|
@ -137,16 +139,17 @@ testServerUnregisteredAwaitNoClient =
|
|||
Right _ -> return ()
|
||||
|
||||
testPayloadLowLevel :: TestTree
|
||||
testPayloadLowLevel = testCase "LowLevel Haskell library request/response " $ do
|
||||
withGRPC $ \grpc -> do
|
||||
withAsync (testPayloadLowLevelServer grpc) $ \a1 -> do
|
||||
withAsync (testPayloadLowLevelClient grpc) $ \a2 -> do
|
||||
wait a1
|
||||
wait a2
|
||||
testPayloadLowLevel =
|
||||
testCase "Client/Server - low-level (registered) request/response" $
|
||||
withGRPC $ \grpc -> do
|
||||
withAsync (testPayloadLowLevelServer grpc) $ \a1 -> do
|
||||
withAsync (testPayloadLowLevelClient grpc) $ \a2 -> do
|
||||
wait a1
|
||||
wait a2
|
||||
|
||||
testPayloadLowLevelUnregistered :: TestTree
|
||||
testPayloadLowLevelUnregistered =
|
||||
testCase "LowLevel Haskell library unregistered request/response " $ do
|
||||
testCase "Client/Server - low-level unregistered request/response" $ do
|
||||
withGRPC $ \grpc -> do
|
||||
withAsync (testPayloadLowLevelServerUnregistered grpc) $ \a1 ->
|
||||
withAsync (testPayloadLowLevelClientUnregistered grpc) $ \a2 -> do
|
||||
|
@ -155,7 +158,7 @@ testPayloadLowLevelUnregistered =
|
|||
|
||||
testWithServerCall :: TestTree
|
||||
testWithServerCall =
|
||||
testCase "Creating and destroying a call: no errors. " $
|
||||
testCase "Server - Create/destroy call" $
|
||||
withGRPC $ \grpc -> do
|
||||
let conf = ServerConfig "localhost" 50051 []
|
||||
withServer grpc conf $ \server -> do
|
||||
|
@ -164,7 +167,7 @@ testWithServerCall =
|
|||
|
||||
testWithClientCall :: TestTree
|
||||
testWithClientCall =
|
||||
testCase "Creating and destroying a client call: no errors. " $
|
||||
testCase "Client - Create/destroy call" $
|
||||
withGRPC $ \grpc -> do
|
||||
let conf = ClientConfig "localhost" 50051
|
||||
withClient grpc conf $ \client -> do
|
||||
|
@ -299,7 +302,7 @@ testPayloadServer = do
|
|||
-- This is intended to test the low-level C bindings, so we use only a few
|
||||
-- minimal abstractions on top of it.
|
||||
testPayload :: TestTree
|
||||
testPayload = testCase "low-level C bindings request/response " $ do
|
||||
testPayload = testCase "Client/Server - End-to-end request/response" $ do
|
||||
grpcInit
|
||||
withAsync testPayloadServer $ \a1 -> do
|
||||
withAsync testPayloadClient $ \a2 -> do
|
||||
|
|
|
@ -12,7 +12,7 @@ import Test.Tasty
|
|||
import Test.Tasty.HUnit as HU (testCase, (@?=))
|
||||
|
||||
unsafeTests :: TestTree
|
||||
unsafeTests = testGroup "Unit tests for unsafe C bindings."
|
||||
unsafeTests = testGroup "Unit tests for unsafe C bindings"
|
||||
[ roundtripSlice "Hello, world!"
|
||||
, roundtripByteBuffer "Hwaet! We gardena in geardagum..."
|
||||
, testMetadata
|
||||
|
@ -23,14 +23,14 @@ unsafeTests = testGroup "Unit tests for unsafe C bindings."
|
|||
]
|
||||
|
||||
roundtripSlice :: B.ByteString -> TestTree
|
||||
roundtripSlice bs = testCase "Slice C bindings roundtrip" $ do
|
||||
roundtripSlice bs = testCase "ByteString slice roundtrip" $ do
|
||||
slice <- byteStringToSlice bs
|
||||
unslice <- sliceToByteString slice
|
||||
bs HU.@?= unslice
|
||||
freeSlice slice
|
||||
|
||||
roundtripByteBuffer :: B.ByteString -> TestTree
|
||||
roundtripByteBuffer bs = testCase "ByteBuffer C bindings roundtrip" $ do
|
||||
roundtripByteBuffer bs = testCase "ByteBuffer roundtrip" $ do
|
||||
slice <- byteStringToSlice bs
|
||||
buffer <- grpcRawByteBufferCreate slice 1
|
||||
reader <- byteBufferReaderCreate buffer
|
||||
|
@ -44,7 +44,7 @@ roundtripByteBuffer bs = testCase "ByteBuffer C bindings roundtrip" $ do
|
|||
freeSlice readSlice
|
||||
|
||||
testMetadata :: TestTree
|
||||
testMetadata = testCase "metadata setter/getter C bindings roundtrip" $ do
|
||||
testMetadata = testCase "Metadata setter/getter roundtrip" $ do
|
||||
m <- metadataAlloc 3
|
||||
setMetadataKeyVal "hello" "world" m 0
|
||||
setMetadataKeyVal "foo" "bar" m 1
|
||||
|
@ -71,26 +71,26 @@ currTimeMillis t = do
|
|||
return tMillis
|
||||
|
||||
testNow :: TestTree
|
||||
testNow = testCase "create and destroy various clock types" $ do
|
||||
testNow = testCase "Create/destroy various clock types" $ do
|
||||
_ <- currTimeMillis GprClockMonotonic
|
||||
_ <- currTimeMillis GprClockRealtime
|
||||
_ <- currTimeMillis GprClockPrecise
|
||||
return ()
|
||||
|
||||
testCreateDestroyMetadata :: TestTree
|
||||
testCreateDestroyMetadata = testCase "create/destroy metadataArrayPtr " $ do
|
||||
testCreateDestroyMetadata = testCase "Create/destroy metadataArrayPtr" $ do
|
||||
grpcInit
|
||||
withMetadataArrayPtr $ const $ return ()
|
||||
grpcShutdown
|
||||
|
||||
testCreateDestroyMetadataKeyVals :: TestTree
|
||||
testCreateDestroyMetadataKeyVals = testCase "create/destroy metadata k/vs " $ do
|
||||
testCreateDestroyMetadataKeyVals = testCase "Create/destroy metadata key/values" $ do
|
||||
grpcInit
|
||||
withMetadataKeyValPtr 10 $ const $ return ()
|
||||
grpcShutdown
|
||||
|
||||
testCreateDestroyDeadline :: TestTree
|
||||
testCreateDestroyDeadline = testCase "create/destroy deadline " $ do
|
||||
testCreateDestroyDeadline = testCase "Create/destroy deadline" $ do
|
||||
grpcInit
|
||||
withDeadlineSeconds 10 $ const $ return ()
|
||||
grpcShutdown
|
||||
|
|
Loading…
Reference in a new issue