Rollback test connection on errors
This commit is contained in:
+5
-2
@@ -47,8 +47,11 @@ withApp config dbStructure c perform = do
|
|||||||
let handleReq = H.run $ inTransaction ReadCommitted
|
let handleReq = H.run $ inTransaction ReadCommitted
|
||||||
(runWithClaims config time (app dbStructure config body) req)
|
(runWithClaims config time (app dbStructure config body) req)
|
||||||
|
|
||||||
resOrError <- handleReq c
|
handleReq c >>= \case
|
||||||
either (resp . pgErrResponse) resp resOrError
|
Left err -> do
|
||||||
|
void $ H.run (H.sql "rollback;") c
|
||||||
|
resp $ pgErrResponse err
|
||||||
|
Right res -> resp res
|
||||||
|
|
||||||
setupDb :: IO ()
|
setupDb :: IO ()
|
||||||
setupDb = do
|
setupDb = do
|
||||||
|
|||||||
Reference in New Issue
Block a user