run spec tests in parallel
reduces time to run postgrest-test-spec-all by 20-25%
This commit is contained in:
committed by
Wolfgang Walther
parent
a52c114ff4
commit
dbe3c163bd
+12
-11
@@ -293,29 +293,30 @@ spec actualPgVersion = do
|
||||
-- reset pk sequence first to make test repeatable
|
||||
request methodPost "/rpc/reset_sequence"
|
||||
[("Prefer", "tx=commit")]
|
||||
[json|{"name": "items_id_seq", "value": 20}|]
|
||||
[json|{"name": "items2_id_seq", "value": 20}|]
|
||||
`shouldRespondWith`
|
||||
[json|""|]
|
||||
|
||||
request methodPost "/items" [("Prefer", "return=representation")] "{}"
|
||||
`shouldRespondWith` [json|[{ id: 20 }]|]
|
||||
{ matchStatus = 201,
|
||||
matchHeaders = []
|
||||
}
|
||||
request methodPost "/items2"
|
||||
[("Prefer", "return=representation")]
|
||||
[json|{}|]
|
||||
`shouldRespondWith`
|
||||
[json|[{ id: 20 }]|]
|
||||
{ matchStatus = 201 }
|
||||
|
||||
it "successfully inserts a row with all-default columns with prefer=rep and &select=" $ do
|
||||
-- reset pk sequence first to make test repeatable
|
||||
request methodPost "/rpc/reset_sequence"
|
||||
[("Prefer", "tx=commit")]
|
||||
[json|{"name": "items_id_seq", "value": 20}|]
|
||||
[json|{"name": "items3_id_seq", "value": 20}|]
|
||||
`shouldRespondWith`
|
||||
[json|""|]
|
||||
|
||||
request methodPost "/items?select=id" [("Prefer", "return=representation")] "{}"
|
||||
request methodPost "/items3?select=id"
|
||||
[("Prefer", "return=representation")]
|
||||
[json|{}|]
|
||||
`shouldRespondWith` [json|[{ id: 20 }]|]
|
||||
{ matchStatus = 201,
|
||||
matchHeaders = []
|
||||
}
|
||||
{ matchStatus = 201 }
|
||||
|
||||
context "POST with ?columns parameter" $ do
|
||||
it "ignores json keys not included in ?columns" $ do
|
||||
|
||||
@@ -80,7 +80,7 @@ shouldPersistMutations reqHeaders respHeaders = do
|
||||
[json|[{"id":0}]|]
|
||||
{ matchStatus = 201
|
||||
, matchHeaders = respHeaders }
|
||||
get "items?id=eq.0"
|
||||
get "/items?id=eq.0"
|
||||
`shouldRespondWith`
|
||||
[json|[{"id":0}]|]
|
||||
deleteItems
|
||||
@@ -92,7 +92,7 @@ shouldPersistMutations reqHeaders respHeaders = do
|
||||
`shouldRespondWith`
|
||||
[json|[{"id":0}]|]
|
||||
{ matchHeaders = respHeaders }
|
||||
get "items?id=eq.0"
|
||||
get "/items?id=eq.0"
|
||||
`shouldRespondWith`
|
||||
[json|[{"id":0}]|]
|
||||
deleteItems
|
||||
@@ -105,10 +105,10 @@ shouldPersistMutations reqHeaders respHeaders = do
|
||||
`shouldRespondWith`
|
||||
[json|[{"id":-1}]|]
|
||||
{ matchHeaders = respHeaders }
|
||||
get "items?id=eq.0"
|
||||
get "/items?id=eq.0"
|
||||
`shouldRespondWith`
|
||||
[json|[]|]
|
||||
get "items?id=eq.-1"
|
||||
get "/items?id=eq.-1"
|
||||
`shouldRespondWith`
|
||||
[json|[{"id":-1}]|]
|
||||
deleteItems
|
||||
@@ -121,7 +121,7 @@ shouldPersistMutations reqHeaders respHeaders = do
|
||||
`shouldRespondWith`
|
||||
[json|[{"id":0}]|]
|
||||
{ matchHeaders = respHeaders }
|
||||
get "items?id=eq.0"
|
||||
get "/items?id=eq.0"
|
||||
`shouldRespondWith`
|
||||
[json|[]|]
|
||||
|
||||
@@ -134,7 +134,7 @@ shouldNotPersistMutations reqHeaders respHeaders = do
|
||||
[json|[{"id":0}]|]
|
||||
{ matchStatus = 201
|
||||
, matchHeaders = respHeaders }
|
||||
get "items?id=eq.0"
|
||||
get "/items?id=eq.0"
|
||||
`shouldRespondWith`
|
||||
[json|[]|]
|
||||
|
||||
@@ -145,7 +145,7 @@ shouldNotPersistMutations reqHeaders respHeaders = do
|
||||
`shouldRespondWith`
|
||||
[json|[{"id":0}]|]
|
||||
{ matchHeaders = respHeaders }
|
||||
get "items?id=eq.0"
|
||||
get "/items?id=eq.0"
|
||||
`shouldRespondWith`
|
||||
[json|[]|]
|
||||
|
||||
@@ -156,7 +156,7 @@ shouldNotPersistMutations reqHeaders respHeaders = do
|
||||
`shouldRespondWith`
|
||||
[json|[{"id":0}]|]
|
||||
{ matchHeaders = respHeaders }
|
||||
get "items?id=eq.0"
|
||||
get "/items?id=eq.0"
|
||||
`shouldRespondWith`
|
||||
[json|[]|]
|
||||
get "items?id=eq.1"
|
||||
@@ -170,7 +170,7 @@ shouldNotPersistMutations reqHeaders respHeaders = do
|
||||
`shouldRespondWith`
|
||||
[json|[{"id":1}]|]
|
||||
{ matchHeaders = respHeaders }
|
||||
get "items?id=eq.1"
|
||||
get "/items?id=eq.1"
|
||||
`shouldRespondWith`
|
||||
[json|[{"id":1}]|]
|
||||
|
||||
|
||||
@@ -51,32 +51,14 @@ spec = do
|
||||
|
||||
context "in a nonempty table" $ do
|
||||
it "can update a single item" $ do
|
||||
get "/items?id=eq.42"
|
||||
`shouldRespondWith`
|
||||
[json|[]|]
|
||||
|
||||
request methodPatch "/items?id=eq.2"
|
||||
[("Prefer", "tx=commit")]
|
||||
patch "/items?id=eq.2"
|
||||
[json| { "id":42 } |]
|
||||
`shouldRespondWith`
|
||||
""
|
||||
{ matchStatus = 204
|
||||
, matchHeaders = ["Content-Range" <:> "0-0/*"
|
||||
, "Preference-Applied" <:> "tx=commit" ]
|
||||
, matchHeaders = ["Content-Range" <:> "0-0/*"]
|
||||
}
|
||||
|
||||
-- check it really got updated
|
||||
get "/items?id=eq.42"
|
||||
`shouldRespondWith`
|
||||
[json|[ { "id": 42 } ]|]
|
||||
|
||||
-- put value back for other tests
|
||||
request methodPatch "/items?id=eq.42"
|
||||
[("Prefer", "tx=commit")]
|
||||
[json| { "id":2 } |]
|
||||
`shouldRespondWith`
|
||||
204
|
||||
|
||||
it "returns empty array when no rows updated and return=rep" $
|
||||
request methodPatch "/items?id=eq.999999"
|
||||
[("Prefer", "return=representation")] [json| { "id":999999 } |]
|
||||
|
||||
Reference in New Issue
Block a user