Add postgrest-coverage to show and upload hpc reports to codecov

This commit is contained in:
Wolfgang Walther
2020-12-30 13:22:25 +01:00
committed by GitHub
parent 2015688312
commit c7f0d42323
17 changed files with 179 additions and 69 deletions
-7
View File
@@ -1,14 +1,10 @@
module Feature.InsertSpec where
import qualified Data.Aeson as JSON
import Data.List (lookup)
import Data.Maybe (fromJust)
import Network.Wai (Application)
import Network.Wai.Test (SResponse (simpleBody, simpleHeaders, simpleStatus))
import Test.Hspec hiding (pendingWith)
import Test.Hspec.Wai.Matcher (bodyEquals)
import TestTypes (CompoundPK (..), IncPK (..))
import Network.HTTP.Types
import Test.Hspec.Wai
@@ -441,9 +437,6 @@ spec actualPgVersion = do
describe "Row level permission" $
it "set user_id when inserting rows" $ do
post "/postgrest/users" [json| { "id":"jdoe", "pass": "1234", "role": "postgrest_test_author" } |]
post "/postgrest/users" [json| { "id":"jroe", "pass": "1234", "role": "postgrest_test_author" } |]
request methodPost "/authors_only"
[ authHeaderJWT "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoicG9zdGdyZXN0X3Rlc3RfYXV0aG9yIiwiaWQiOiJqZG9lIn0.B-lReuGNDwAlU1GOC476MlO0vAt9JNoHIlxg2vwMaO0", ("Prefer", "return=representation") ]
[json| { "secret": "nyancat" } |]
+1 -2
View File
@@ -1,7 +1,6 @@
module Feature.QueryLimitedSpec where
import Network.Wai (Application)
import Network.Wai.Test (SResponse (simpleHeaders, simpleStatus))
import Network.Wai (Application)
import Network.HTTP.Types
import Test.Hspec
+1 -2
View File
@@ -7,8 +7,7 @@ import Test.Hspec
import Test.Hspec.Wai
import Test.Hspec.Wai.JSON
import Protolude hiding (get)
import SpecHelper
import Protolude hiding (get)
-- two helpers functions to make sure that each test can setup and cleanup properly
+2 -7
View File
@@ -1,18 +1,13 @@
module Feature.RpcPreRequestGucsSpec where
import qualified Data.ByteString.Lazy as BL (empty)
import Network.Wai (Application)
import Network.Wai.Test (SResponse (simpleBody, simpleHeaders, simpleStatus))
import Network.Wai (Application)
import Network.HTTP.Types
import Test.Hspec hiding (pendingWith)
import Test.Hspec.Wai
import Test.Hspec.Wai.JSON
import Text.Heredoc
import Protolude hiding (get, put)
import SpecHelper
import Protolude hiding (get, put)
spec :: SpecWith ((), Application)
spec =
+1 -2
View File
@@ -7,8 +7,7 @@ import Test.Hspec
import Test.Hspec.Wai
import Test.Hspec.Wai.JSON
import Protolude hiding (get)
import SpecHelper
import Protolude hiding (get)
spec :: SpecWith ((), Application)
spec =
+2 -5
View File
@@ -1,14 +1,11 @@
module Feature.UpdateSpec where
import Data.List (lookup)
import Network.Wai (Application)
import Network.Wai.Test (SResponse (simpleBody, simpleHeaders, simpleStatus))
import Test.Hspec hiding (pendingWith)
import Network.Wai (Application)
import Test.Hspec hiding (pendingWith)
import Network.HTTP.Types
import Test.Hspec.Wai
import Test.Hspec.Wai.JSON
import Text.Heredoc
import Protolude hiding (get)
import SpecHelper
-1
View File
@@ -5,7 +5,6 @@ import qualified Data.Aeson.Lens as L
import qualified Hasql.Decoders as HD
import qualified Hasql.DynamicStatements.Snippet as H
import qualified Hasql.DynamicStatements.Statement as H
import qualified Hasql.Encoders as HE
import qualified Hasql.Pool as P
import qualified Hasql.Statement as H
import qualified Hasql.Transaction as HT
View File
+7 -2
View File
@@ -75,13 +75,16 @@ def defaultenv():
def dumpconfig(configpath=None, env=None, stdin=None):
"Dump the config as parsed by PostgREST."
env = env or {}
command = [POSTGREST_BIN, "--dump-config"]
env["HPCTIXFILE"] = os.getenv("HPCTIXFILE", "")
if configpath:
command.append(configpath)
process = subprocess.Popen(
command, env=env or {}, stdin=subprocess.PIPE, stdout=subprocess.PIPE
command, env=env, stdin=subprocess.PIPE, stdout=subprocess.PIPE
)
process.stdin.write(stdin or b"")
@@ -96,6 +99,7 @@ def dumpconfig(configpath=None, env=None, stdin=None):
@contextlib.contextmanager
def run(configpath=None, stdin=None, env=None, port=None):
"Run PostgREST and yield an endpoint that is ready for connections."
env = env or {}
with tempfile.TemporaryDirectory() as tmpdir:
if port:
@@ -108,11 +112,12 @@ def run(configpath=None, stdin=None, env=None, port=None):
baseurl = "http+unix://" + urllib.parse.quote_plus(str(socketfile))
command = [POSTGREST_BIN]
env["HPCTIXFILE"] = os.getenv("HPCTIXFILE", "")
if configpath:
command.append(configpath)
process = subprocess.Popen(command, stdin=subprocess.PIPE, env=env or {})
process = subprocess.Popen(command, stdin=subprocess.PIPE, env=env)
try:
process.stdin.write(stdin or b"")