Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
{-# 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
You can’t perform that action at this time.