Merge pull request #508 from begriffs/test-plain-build
Test that binary builds, not just that suite passes
This commit is contained in:
@@ -9,7 +9,9 @@ dependencies:
|
||||
- createdb -O postgrest_test -U ubuntu postgrest_test
|
||||
override:
|
||||
- stack setup
|
||||
- rm -fr $(stack path --dist-dir) $(stack path --local-install-root)
|
||||
- stack install hlint packdeps cabal-install
|
||||
- stack build
|
||||
- stack build --test --no-run-tests
|
||||
|
||||
test:
|
||||
|
||||
+2
-2
@@ -26,7 +26,7 @@ executable postgrest
|
||||
default-extensions: OverloadedStrings, ScopedTypeVariables, QuasiQuotes
|
||||
ghc-options: -threaded -rtsopts -with-rtsopts=-N
|
||||
default-language: Haskell2010
|
||||
build-depends: aeson >= 0.8 && < 0.10
|
||||
build-depends: aeson (>= 0.8 && < 0.10) || (>= 0.11 && < 0.12)
|
||||
, base >= 4.8 && < 5
|
||||
, bytestring
|
||||
, case-insensitive
|
||||
@@ -138,6 +138,7 @@ Test-Suite spec
|
||||
, Feature.DeleteSpec
|
||||
, Feature.InsertSpec
|
||||
, Feature.QuerySpec
|
||||
, Feature.QueryLimitedSpec
|
||||
, Feature.RangeSpec
|
||||
, Feature.StructureSpec
|
||||
, Paths_postgrest
|
||||
@@ -145,7 +146,6 @@ Test-Suite spec
|
||||
, PostgREST.Auth
|
||||
, PostgREST.Config
|
||||
, PostgREST.Error
|
||||
, PostgREST.Main
|
||||
, PostgREST.Middleware
|
||||
, PostgREST.Parsers
|
||||
, PostgREST.DbStructure
|
||||
|
||||
+27
-8
@@ -3,7 +3,7 @@
|
||||
{-# LANGUAGE TupleSections #-}
|
||||
--module PostgREST.App where
|
||||
module PostgREST.App (
|
||||
app
|
||||
postgrest
|
||||
) where
|
||||
|
||||
import Control.Applicative
|
||||
@@ -18,6 +18,9 @@ import Data.String.Conversions (cs)
|
||||
import Data.Text (Text, replace, strip)
|
||||
import Data.Tree
|
||||
|
||||
import qualified Hasql.Pool as P
|
||||
import qualified Hasql.Transaction as HT
|
||||
|
||||
import Text.Parsec.Error
|
||||
import Text.ParserCombinators.Parsec (parse)
|
||||
|
||||
@@ -26,25 +29,26 @@ import Network.HTTP.Types.Header
|
||||
import Network.HTTP.Types.Status
|
||||
import Network.HTTP.Types.URI (parseSimpleQuery)
|
||||
import Network.Wai
|
||||
import Network.Wai.Middleware.RequestLogger (logStdout)
|
||||
|
||||
import Data.Aeson
|
||||
import Data.Aeson.Types (emptyArray)
|
||||
import Data.Monoid
|
||||
import Data.Time.Clock.POSIX (getPOSIXTime)
|
||||
import qualified Data.Vector as V
|
||||
import qualified Hasql.Transaction as H
|
||||
|
||||
import PostgREST.Config (AppConfig (..))
|
||||
import PostgREST.Parsers
|
||||
import PostgREST.DbStructure
|
||||
import PostgREST.RangeQuery
|
||||
import PostgREST.ApiRequest (ApiRequest(..), ContentType(..)
|
||||
, Action(..), Target(..)
|
||||
, PreferRepresentation (..)
|
||||
, userApiRequest)
|
||||
import PostgREST.Types
|
||||
import PostgREST.Auth (tokenJWT)
|
||||
import PostgREST.Error (errResponse)
|
||||
|
||||
import PostgREST.Config (AppConfig (..))
|
||||
import PostgREST.DbStructure
|
||||
import PostgREST.Error (errResponse, pgErrResponse)
|
||||
import PostgREST.Parsers
|
||||
import PostgREST.RangeQuery
|
||||
import PostgREST.Middleware
|
||||
import PostgREST.QueryBuilder ( callProc
|
||||
, addJoinConditions
|
||||
, sourceCTEName
|
||||
@@ -55,9 +59,24 @@ import PostgREST.QueryBuilder ( callProc
|
||||
, createWriteStatement
|
||||
, ResultsWithCount
|
||||
)
|
||||
import PostgREST.Types
|
||||
|
||||
import Prelude
|
||||
|
||||
|
||||
postgrest :: AppConfig -> DbStructure -> P.Pool -> Application
|
||||
postgrest conf dbStructure pool =
|
||||
let middle = (if configQuiet conf then id else logStdout) . defaultMiddle in
|
||||
|
||||
middle $ \ req respond -> do
|
||||
time <- getPOSIXTime
|
||||
body <- strictRequestBody req
|
||||
|
||||
let handleReq = runWithClaims conf time (app dbStructure conf body) req
|
||||
resp <- either pgErrResponse id <$> P.use pool
|
||||
(HT.run handleReq HT.ReadCommitted HT.Write)
|
||||
respond resp
|
||||
|
||||
app :: DbStructure -> AppConfig -> RequestBody -> Request -> H.Transaction Response
|
||||
app dbStructure conf reqBody req =
|
||||
let
|
||||
|
||||
+1
-21
@@ -1,6 +1,6 @@
|
||||
{-# LANGUAGE CPP #-}
|
||||
|
||||
module PostgREST.Main where
|
||||
module Main where
|
||||
|
||||
|
||||
import PostgREST.App
|
||||
@@ -9,23 +9,16 @@ import PostgREST.Config (AppConfig (..),
|
||||
prettyVersion,
|
||||
readOptions)
|
||||
import PostgREST.DbStructure
|
||||
import PostgREST.Error (pgErrResponse)
|
||||
import PostgREST.Middleware
|
||||
import PostgREST.Types (DbStructure)
|
||||
|
||||
import Control.Monad
|
||||
import Data.Monoid ((<>))
|
||||
import Data.String.Conversions (cs)
|
||||
import Data.Time.Clock.POSIX (getPOSIXTime)
|
||||
import qualified Hasql.Query as H
|
||||
import qualified Hasql.Session as H
|
||||
import qualified Hasql.Transaction as HT
|
||||
import qualified Hasql.Decoders as HD
|
||||
import qualified Hasql.Encoders as HE
|
||||
import qualified Hasql.Pool as P
|
||||
import Network.Wai
|
||||
import Network.Wai.Handler.Warp
|
||||
import Network.Wai.Middleware.RequestLogger (logStdout)
|
||||
import System.IO (BufferMode (..),
|
||||
hSetBuffering, stderr,
|
||||
stdin, stdout)
|
||||
@@ -82,16 +75,3 @@ main = do
|
||||
|
||||
let dbStructure = either (error.show) id result
|
||||
runSettings appSettings $ postgrest conf dbStructure pool
|
||||
|
||||
postgrest :: AppConfig -> DbStructure -> P.Pool -> Application
|
||||
postgrest conf dbStructure pool =
|
||||
let middle = (if configQuiet conf then id else logStdout) . defaultMiddle in
|
||||
|
||||
middle $ \ req respond -> do
|
||||
time <- getPOSIXTime
|
||||
body <- strictRequestBody req
|
||||
|
||||
let handleReq = runWithClaims conf time (app dbStructure conf body) req
|
||||
resp <- either pgErrResponse id <$> P.use pool
|
||||
(HT.run handleReq HT.ReadCommitted HT.Write)
|
||||
respond resp
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
resolver: lts-5.0
|
||||
resolver: lts-5.5
|
||||
extra-deps:
|
||||
- Ranged-sets-0.3.0
|
||||
- bytestring-tree-builder-0.2.5
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ import SpecHelper
|
||||
import qualified Hasql.Pool as P
|
||||
|
||||
import PostgREST.DbStructure (getDbStructure)
|
||||
import PostgREST.Main (postgrest)
|
||||
import PostgREST.App (postgrest)
|
||||
import Data.String.Conversions (cs)
|
||||
|
||||
import qualified Feature.AuthSpec
|
||||
|
||||
Reference in New Issue
Block a user