File: EntityHaddockSpec.hs

package info (click to toggle)
haskell-persistent 2.17.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,196 kB
  • sloc: haskell: 14,076; makefile: 3
file content (36 lines) | stat: -rw-r--r-- 1,140 bytes parent folder | download | duplicates (2)
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