@@ -3,7 +3,7 @@ module WaiExtraTest (specs) where
33
44import Test.Hspec
55import Test.HUnit hiding (Test)
6−import Data.Monoid (mappend, mempty)
6+import Data.Monoid (mappend, mempty, (<>))
77
88import Network.Wai
99import Network.Wai.Test
@@ -545,21 +545,26 @@ caseDebugRequestBody = do
545545 where
546546 params = [("foo", "bar"), ("baz", "bin")]
547547 -- FIXME change back once we include post parameter output in logging postOutput = T.pack $ "POST \nAccept: \nPOST " ++ (show params)
548− postOutput = T.pack $ "POST / :: \nStatus: 200 OK. /\n"
549− getOutput params' = T.pack $ "GET /location :: \nGET " ++ show params' ++ "\nStatus: 200 OK. /location\n"
548+ -- the time cannot be known, so match around it
549+ postOutput = ("POST / :: \nStatus: 200 OK. 0", "s. /\n")
550+ getOutput params' = ("GET /location :: \nGET " <> T.pack (show params') <> "\nStatus: 200 OK. 0", "s. /location\n")
550551
551− debugApp output' req = do
552+ debugApp (beginning, ending) req = do
552553 iactual <- liftIO $ I.newIORef mempty
553554 middleware <- liftIO $ mkRequestLogger def
554555 { destination = Callback $ \strs -> I.modifyIORef iactual $ (`mappend` strs)
555556 , outputFormat = Detailed False
556557 }
557558 res <- middleware (\_req -> return $ responseLBS status200 [ ] "") req
558− actual <- liftIO $ I.readIORef iactual
559− liftIO $ assertEqual "debug" output $ logToBs actual
559+ actual <- logToBs <$> liftIO (I.readIORef iactual)
560+ liftIO $ do
561+ actual `shouldSatisfy` S.isPrefixOf begin
562+ actual `shouldSatisfy` S.isSuffixOf end
563+
560564 return res
561565 where
562− output = TE.encodeUtf8 $ T.toStrict output'
566+ begin = TE.encodeUtf8 $ T.toStrict beginning
567+ end = TE.encodeUtf8 $ T.toStrict ending
563568
564569 logToBs = fromLogStr
565570