File: RequireOnlyPersistImportSpec.hs

package info (click to toggle)
haskell-persistent 2.14.6.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,120 kB
  • sloc: haskell: 12,767; makefile: 3
file content (47 lines) | stat: -rw-r--r-- 1,274 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
37
38
39
40
41
42
43
44
45
46
47
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}

module Database.Persist.TH.RequireOnlyPersistImportSpec where

-- This test asserts this is the only import required to define entities
-- See: https://github.com/yesodweb/persistent/pull/1369
import Database.Persist.TH

-- always explicitly import qualified Hspec in the context of this spec
import qualified Test.Hspec as HS

mkPersist sqlSettings [persistLowerCase|
Plain
    name String
    age  Int
    deriving Show Eq

JsonEncoded json
    name String
    age  Int
    deriving Show Eq
|]

spec :: HS.Spec
spec =
    HS.describe "RequireOnlyPersistImport" $ do
        HS.it "Plain" $ do
            let typeSigPlain :: String -> Int -> Plain
                typeSigPlain = Plain
            compiles

        HS.it "JsonEncoded" $ do
            let typeSigJsonEncoded :: String -> Int -> JsonEncoded
                typeSigJsonEncoded = JsonEncoded
            compiles

compiles :: HS.Expectation
compiles = True `HS.shouldBe` True