Created
June 18, 2017 04:43
-
-
Save jfischoff/15af9f2460e5a15d23e2eb1361535bb9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE QuasiQuotes #-} | |
module SimpleDBSpec (spec, main) where | |
import Database.PostgreSQL.Simple.SqlQQ | |
import qualified Database.PostgreSQL.Simple as Simple | |
import Database.PostgreSQL.Transact | |
import Test.Hspec (Spec, hspec) | |
import Test.Hspec.Expectations.Lifted | |
import Test.Hspec.DB | |
import Control.Monad | |
main :: IO () | |
main = hspec spec | |
migrate :: Simple.Connection -> IO () | |
migrate conn = void $ Simple.execute_ conn | |
[sql| CREATE TABLE things (name text) |] | |
spec :: Spec | |
spec = describeDB migrate "Queries" $ do | |
itDB "can insert" $ do | |
execute_ [sql| INSERT INTO things VALUES ('bob') |] | |
query_ [sql| SELECT name FROM things |] `shouldReturn` [Simple.Only "bob"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment