hspec-pg-transact: Helpers for creating database tests with hspec and pg-transact

[ bsd3, library, web ] [ Propose Tags ]

Helpers for creating database tests with hspec and pg-transact

hspec-pg-transact utilizes tmp-postgres to automatically and connect to a temporary instance of postgres on a random port.

describeDB migrate "Query” $
  itDB "work" $ do
    execute_ [sql|
      INSERT INTO things
      VALUES (‘me’) |]
    query_ [sql|
      SELECT name
       FROM things |]
      `shouldReturn` [Only "me"]

In the example above describeDB wraps describe with a beforeAll hook for creating a db and a afterAll hook for stopping a db.

Tests can be written with itDB which is wrapper around it that uses the passed in Connection to run a db transaction automatically for the test.

The libary also provides a few other functions for more fine grained control over running transactions in tests.

[Skip to Readme]
Versions [RSS] [faq],,
Dependencies base (>=4.7 && <5), bytestring, hspec, pg-transact, postgresql-simple, resource-pool, text, tmp-postgres [details]
License BSD-3-Clause
Copyright 2017 Jonathan Fischoff
Author Jonathan Fischoff
Maintainer jonathangfischoff@gmail.com
Category Web
Home page https://github.com/jfischoff/pg-transact-hspec#readme
Source repo head: git clone https://github.com/jfischoff/pg-transact-hspec
Uploaded by JonathanFischoff at 2017-06-19T18:24:52Z
Distributions NixOS:
Downloads 1921 total (9 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs available [build log]
Last success reported on 2017-06-19 [all 1 reports]




Maintainer's Corner

For package maintainers and hackage trustees


Readme for hspec-pg-transact-

[back to package description]