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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
module Database.Persist.TH.DiscoverEntitiesSpec where
import TemplateTestImports
import Data.Aeson
import Data.Text (Text)
import Language.Haskell.TH.Syntax
import Database.Persist.ImplicitIdDef
import Database.Persist.ImplicitIdDef.Internal (fieldTypeFromTypeable)
mkPersist sqlSettings [persistLowerCase|
User
name String
age Int
Dog
user UserId
name String
Cat
enemy DogId
name String
|]
pass :: IO ()
pass = pure ()
asIO :: IO a -> IO a
asIO = id
$(pure [])
spec :: Spec
spec = describe "DiscoverEntitiesSpec" $ do
let entities = $(discoverEntities)
it "should have all three entities" $ do
entities `shouldMatchList`
[ entityDef $ Proxy @User
, entityDef $ Proxy @Dog
, entityDef $ Proxy @Cat
]
|