Skip to content

Instantly share code, notes, and snippets.

@jfischoff
Created June 18, 2017 04:43
Show Gist options
  • Save jfischoff/15af9f2460e5a15d23e2eb1361535bb9 to your computer and use it in GitHub Desktop.
Save jfischoff/15af9f2460e5a15d23e2eb1361535bb9 to your computer and use it in GitHub Desktop.
{-# 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