Skip to content

Commit db06e15

Browse files
Adds doctest
This change enables running doctest as part of the test-suite. Change-Id: Ic78759fbf5b105e3c9c74b764b10b97b7c7a3a6d
1 parent 4b806ab commit db06e15

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

matrix-client/matrix-client.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,4 @@ test-suite unit
8686
, hspec >= 2
8787
, matrix-client
8888
, text
89+
, doctest

matrix-client/test/Spec.hs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
-- | The matrix client specification tests
55
module Main (main) where
66

7+
import Control.Monad.Except
78
import qualified Data.Aeson.Encode.Pretty as Aeson
89
import qualified Data.ByteString.Lazy as BS
910
import Data.Either (isLeft)
@@ -12,8 +13,8 @@ import Data.Time.Clock.System (SystemTime (..), getSystemTime)
1213
import Network.Matrix.Client
1314
import Network.Matrix.Internal
1415
import System.Environment (lookupEnv)
16+
import Test.DocTest (doctest)
1517
import Test.Hspec
16-
import Control.Monad.Except
1718

1819
main :: IO ()
1920
main = do
@@ -26,7 +27,13 @@ main = do
2627
_ -> do
2728
putStrLn "Skipping integration test"
2829
pure $ pure mempty
29-
hspec (parallel $ spec >> runIntegration)
30+
hspec (parallel $ spec >> runIntegration >> docTest)
31+
32+
docTest :: Spec
33+
docTest = do
34+
describe "doctest" $ do
35+
it "works" $ do
36+
doctest ["-XOverloadedStrings", "src/"]
3037

3138
integration :: ClientSession -> ClientSession -> Spec
3239
integration sess1 sess2 = do
@@ -44,7 +51,7 @@ integration sess1 sess2 = do
4451
case resp of
4552
Left err -> meError err `shouldBe` "Alias already exists"
4653
Right (RoomID roomID') -> roomID' `shouldSatisfy` (/= mempty)
47-
it "join room" $ do
54+
it "join room" $ do
4855
resp <- runMatrixM sess1 $joinRoom "#test:localhost"
4956
case resp of
5057
Left err -> error (show err)
@@ -57,7 +64,7 @@ integration sess1 sess2 = do
5764
result <- runMatrixM sess2 $ do
5865
-- Flush previous events
5966
sr <- sync Nothing Nothing Nothing Nothing
60-
[room] <- getJoinedRooms
67+
[room] <- getJoinedRooms
6168
let msg body = RoomMessageText $ MessageText body TextType Nothing Nothing
6269
let since = srNextBatch sr
6370
eventID <- sendMessage room (EventRoomMessage $ msg "Hello") (TxnID since)

0 commit comments

Comments
 (0)