test: Make PgSafeUpdateSpec parallel-ready
This commit is contained in:
@@ -10,7 +10,6 @@ import Test.Hspec.Wai
|
||||
import Test.Hspec.Wai.JSON
|
||||
|
||||
import Protolude hiding (get, put)
|
||||
import SpecHelper
|
||||
|
||||
tblDataBefore = [aesonQQ|[
|
||||
{ "id": 1, "name": "item-1", "observation": null }
|
||||
@@ -36,15 +35,9 @@ spec =
|
||||
{ matchStatus = 400 }
|
||||
|
||||
it "allows full table update if a filter is present" $
|
||||
baseTable "safe_update_items" "id" tblDataBefore
|
||||
`mutatesWith`
|
||||
requestMutation methodPatch "/safe_update_items?id=gt.0" mempty [json| {"name": "updated-item"} |]
|
||||
`shouldMutateInto`
|
||||
[json|[
|
||||
{ "id": 1, "name": "updated-item", "observation": null }
|
||||
, { "id": 2, "name": "updated-item", "observation": null }
|
||||
, { "id": 3, "name": "updated-item", "observation": null }
|
||||
]|]
|
||||
request methodPatch "/safe_update_items?id=gt.0" mempty [json| {"name": "updated-item"} |]
|
||||
`shouldRespondWith`
|
||||
204
|
||||
|
||||
context "Full table delete" $ do
|
||||
it "does not delete and throws error if no condition is present" $
|
||||
@@ -59,31 +52,21 @@ spec =
|
||||
{ matchStatus = 400 }
|
||||
|
||||
it "allows full table delete if a filter is present" $
|
||||
baseTable "safe_delete_items" "id" tblDataBefore
|
||||
`mutatesWith`
|
||||
requestMutation methodDelete "/safe_delete_items?id=gt.0" mempty mempty
|
||||
`shouldMutateInto`
|
||||
[json|[]|]
|
||||
request methodDelete "/safe_delete_items?id=gt.0" mempty mempty
|
||||
`shouldRespondWith`
|
||||
204
|
||||
|
||||
disabledSpec :: SpecWith ((), Application)
|
||||
disabledSpec =
|
||||
describe "Disabling pg-safeupdate" $ do
|
||||
context "Full table update" $ do
|
||||
it "works if no condition is present" $
|
||||
baseTable "unsafe_update_items" "id" tblDataBefore
|
||||
`mutatesWith`
|
||||
requestMutation methodPatch "/unsafe_update_items" mempty [json| {"name": "updated-item"} |]
|
||||
`shouldMutateInto`
|
||||
[json|[
|
||||
{ "id": 1, "name": "updated-item", "observation": null }
|
||||
, { "id": 2, "name": "updated-item", "observation": null }
|
||||
, { "id": 3, "name": "updated-item", "observation": null }
|
||||
]|]
|
||||
request methodPatch "/unsafe_update_items" mempty [json| {"name": "updated-item"} |]
|
||||
`shouldRespondWith`
|
||||
204
|
||||
|
||||
context "Full table delete" $ do
|
||||
it "works if no condition is present" $
|
||||
baseTable "unsafe_delete_items" "id" tblDataBefore
|
||||
`mutatesWith`
|
||||
requestMutation methodDelete "/unsafe_delete_items" mempty mempty
|
||||
`shouldMutateInto`
|
||||
[json|[]|]
|
||||
request methodDelete "/unsafe_delete_items" mempty mempty
|
||||
`shouldRespondWith`
|
||||
204
|
||||
|
||||
Reference in New Issue
Block a user