roboservant/test/Spec.hs

47 lines
1.6 KiB
Haskell
Raw Normal View History

2020-09-13 20:42:23 +03:00
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeApplications #-}
import qualified Foo
2020-09-14 19:07:17 +03:00
import qualified Headers
import Hedgehog (Group (..), checkSequential, withTests)
2020-09-13 20:42:23 +03:00
import qualified Roboservant as RS
import qualified UnsafeIO
2020-09-21 23:10:50 +03:00
import Control.Monad(when)
2020-09-24 05:48:59 +03:00
import Test.Hspec.Hedgehog
import Test.Hspec
import Test.Hspec.Core.Spec(shouldFail)
import Control.Monad.Trans (MonadIO(liftIO))
2020-09-13 20:42:23 +03:00
2020-09-24 05:48:59 +03:00
-- -- | this is pretty bad. hopefully Jacob knows a better way of doing this.
-- -- https://twitter.com/mwotton/status/1305189249646460933
-- assert :: String -> Bool -> IO ()
-- assert _ True = pure ()
-- assert err False = ioError $ userError err
2020-06-06 17:24:56 +03:00
2020-09-24 05:48:59 +03:00
main = hspec spec
2020-09-14 19:07:17 +03:00
2020-09-24 05:48:59 +03:00
spec :: Spec
spec = do
describe "Foo" $ do
--
shouldFail $ it "finds an error" $
(hedgehog $ RS.prop_sequential @Foo.FooApi Foo.fooServer [])
describe "Headers" $ do
shouldFail $ it "should find a failure that's dependent on using header info" $ do
liftIO $ pendingWith "doesn't yet work"
(hedgehog $ RS.prop_sequential @Headers.Api Headers.server [])
-- -- The UnsafeIO checker does not actually really use the contextually aware stuff, though it
-- -- could: it's mostly here to show how to test for concurrency problems.
before UnsafeIO.makeServer $ do
describe "sequential checking" $ do
it "safe use" $ \unsafeServer -> do
hedgehog $ RS.prop_sequential @UnsafeIO.UnsafeApi unsafeServer []
modifyMaxSuccess (const 10000) $
shouldFail $
describe "concurrent" $ do
it "concurrent, dangerous use" $ \unsafeServer -> do
RS.prop_concurrent @UnsafeIO.UnsafeApi unsafeServer