Get rid of unneeded Maybe in NormalRequestResult (#34)

This commit is contained in:
Connor Clark 2016-06-23 14:34:36 -07:00 committed by Joel Stanley
parent 51891bb026
commit 9f170be5b0
2 changed files with 5 additions and 12 deletions

View file

@ -113,7 +113,7 @@ withClientCall client regmethod timeout f = do
data NormalRequestResult = NormalRequestResult data NormalRequestResult = NormalRequestResult
{ rspBody :: ByteString { rspBody :: ByteString
, initMD :: Maybe MetadataMap -- initial metadata , initMD :: MetadataMap -- initial metadata
, trailMD :: MetadataMap -- trailing metadata , trailMD :: MetadataMap -- trailing metadata
, rspCode :: C.StatusCode , rspCode :: C.StatusCode
, details :: StatusDetails , details :: StatusDetails
@ -127,14 +127,7 @@ compileNormalRequestResults
[OpRecvInitialMetadataResult m, [OpRecvInitialMetadataResult m,
OpRecvMessageResult (Just body), OpRecvMessageResult (Just body),
OpRecvStatusOnClientResult m2 status details] OpRecvStatusOnClientResult m2 status details]
= Right $ NormalRequestResult body (Just m) m2 status = Right $ NormalRequestResult body m m2 status (StatusDetails details)
(StatusDetails details)
-- TODO: it seems registered request responses on the server
-- don't send initial metadata. Hence the 'Maybe'. Investigate.
compileNormalRequestResults
[OpRecvMessageResult (Just body),
OpRecvStatusOnClientResult m2 status details]
= Right $ NormalRequestResult body Nothing m2 status (StatusDetails details)
compileNormalRequestResults x = compileNormalRequestResults x =
case extractStatusInfo x of case extractStatusInfo x of
Nothing -> Left GRPCIOUnknownError Nothing -> Left GRPCIOUnknownError

View file

@ -87,7 +87,7 @@ testMixRegisteredUnregistered =
clientRequest c rm1 1 "Hello" mempty >>= do clientRequest c rm1 1 "Hello" mempty >>= do
checkReqRslt $ \NormalRequestResult{..} -> do checkReqRslt $ \NormalRequestResult{..} -> do
rspBody @?= "reply test" rspBody @?= "reply test"
initMD @?= Just dummyMeta initMD @?= dummyMeta
trailMD @?= dummyMeta trailMD @?= dummyMeta
clientRequest c rm2 1 "bad endpoint" mempty >>= do clientRequest c rm2 1 "bad endpoint" mempty >>= do
checkReqRslt $ \NormalRequestResult{..} -> do checkReqRslt $ \NormalRequestResult{..} -> do
@ -127,7 +127,7 @@ testPayload =
rspCode @?= StatusOk rspCode @?= StatusOk
rspBody @?= "reply test" rspBody @?= "reply test"
details @?= "details string" details @?= "details string"
initMD @?= Just dummyMeta initMD @?= dummyMeta
trailMD @?= dummyMeta trailMD @?= dummyMeta
server s = do server s = do
length (registeredMethods s) @?= 1 length (registeredMethods s) @?= 1
@ -286,7 +286,7 @@ testClientServerCompression =
rspCode @?= StatusOk rspCode @?= StatusOk
rspBody @?= "hello" rspBody @?= "hello"
details @?= "" details @?= ""
initMD @?= Just dummyMeta initMD @?= dummyMeta
trailMD @?= dummyMeta trailMD @?= dummyMeta
return () return ()
sconf = ServerConfig "localhost" sconf = ServerConfig "localhost"