1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
{-# LANGUAGE CPP #-}
{-# LANGUAGE TemplateHaskell #-}
module Database.Persist.TH.EntityHaddockSpec (spec) where
import TemplateTestImports
#if MIN_VERSION_template_haskell(2,18,0)
import Database.Persist.TH.CommentSpec (CommentModel (..))
import Language.Haskell.TH (DocLoc (DeclDoc), getDoc)
import Language.Haskell.TH.Syntax (lift)
[d|
commentModelDoc :: Maybe String
commentModelDoc = $(lift =<< getDoc (DeclDoc ''CommentModel))
commentFieldDoc :: Maybe String
commentFieldDoc = $(lift =<< getDoc (DeclDoc 'commentModelName))
|]
spec :: Spec
spec = describe "EntityHaddockSpec" $ do
it "generates entity Haddock" $ do
let expected = unlines [ "Doc comments work."
, "Has multiple lines."
]
commentModelDoc `shouldBe` Just expected
it "generates field Haddock" $ do
let expected = unlines [ "First line of comment on column."
, "Second line of comment on column."
]
commentFieldDoc `shouldBe` Just expected
#else
spec :: Spec
spec = pure ()
#endif
|