diff --git a/src/Middleware.hs b/src/Middleware.hs index 9db7b1209..47658ef8d 100644 --- a/src/Middleware.hs +++ b/src/Middleware.hs @@ -26,18 +26,18 @@ import Network.URI (URI(..), parseURI) import PgQuery(LoginAttempt(..), signInRole, setRole, resetRole) import Codec.Binary.Base64.String (decode) -inTransaction :: (Connection -> Application) -> (Connection -> Application) +inTransaction :: (Connection -> Application) -> Connection -> Application inTransaction app conn req respond = finally (runRaw conn "begin" >> app conn req respond) (runRaw conn "commit") -withSavepoint :: (Connection -> Application) -> (Connection -> Application) +withSavepoint :: (Connection -> Application) -> Connection -> Application withSavepoint app conn req respond = do runRaw conn "savepoint req_sp" catch (app conn req respond) (\e -> let _ = (e::SomeException) in runRaw conn "rollback to savepoint req_sp" >> throw e) authenticated :: BS.ByteString -> (Connection -> Application) -> - (Connection -> Application) + Connection -> Application authenticated anon app conn req respond = do attempt <- httpRequesterRole (requestHeaders req) case attempt of diff --git a/test/Feature/AuthSpec.hs b/test/Feature/AuthSpec.hs index cd657a4ac..0a7d80550 100644 --- a/test/Feature/AuthSpec.hs +++ b/test/Feature/AuthSpec.hs @@ -12,7 +12,7 @@ import SpecHelper spec :: Spec spec = around appWithFixture $ describe "authorization" $ do - it "hides tables that anonymous does not own" $ do + it "hides tables that anonymous does not own" $ get "/authors_only" `shouldRespondWith` 400 -- TODO: should be 404 it "indicates login failure" $ do let auth = authHeader "dbapi_test_author_a" "fakefake" diff --git a/test/Feature/InsertSpec.hs b/test/Feature/InsertSpec.hs index bbc06c29f..607b834b3 100644 --- a/test/Feature/InsertSpec.hs +++ b/test/Feature/InsertSpec.hs @@ -47,7 +47,7 @@ spec = around appWithFixture $ do incNullableStr record `shouldBe` Nothing context "into a table with simple pk" $ - it "fails with 400 and error" $ do + it "fails with 400 and error" $ post "/simple_pk" [json| { "extra":"foo"} |] `shouldRespondWith` 400 diff --git a/test/Unit/ErrorsSpec.hs b/test/Unit/ErrorsSpec.hs index c6f8f84d3..8d052d667 100644 --- a/test/Unit/ErrorsSpec.hs +++ b/test/Unit/ErrorsSpec.hs @@ -21,9 +21,9 @@ spec = let runRaw conn "select 1/0" _ <- insert "1" "items" (SqlRow []) conn res $ responseLBS ok200 [("Content-Type", "application/json")] "{}" - in around dbWithSchema $ do + in around dbWithSchema $ - describe "withSavepoint" $ do + describe "withSavepoint" $ it "allows partial rollback of request" $ \c -> do let app = withSavepoint dbErrApp c [[beforeCount]] <- quickQuery c "select count(*) from \"1\".items" []