Refactors tests to use new fixtures and remove some haskell functions that wont be necessary anymore
This commit is contained in:
@@ -10,9 +10,7 @@ import SpecHelper
|
||||
-- }}}
|
||||
|
||||
spec :: Spec
|
||||
spec = beforeAll
|
||||
(clearTable "postgrest.auth") . afterAll_ (clearTable "postgrest.auth")
|
||||
$ around (withApp cfgDefault)
|
||||
spec = around (withApp cfgDefault)
|
||||
$ describe "authorization" $ do
|
||||
|
||||
it "hides tables that anonymous does not own" $
|
||||
|
||||
@@ -7,7 +7,7 @@ import SpecHelper
|
||||
import Network.HTTP.Types
|
||||
|
||||
spec :: Spec
|
||||
spec = beforeAll (clearTable "items" >> createItems 15) . afterAll_ (clearTable "items")
|
||||
spec = beforeAll resetDb
|
||||
. around (withApp cfgDefault) $
|
||||
describe "Deleting" $ do
|
||||
context "existing record" $ do
|
||||
|
||||
@@ -17,7 +17,7 @@ import Control.Monad (replicateM_)
|
||||
import TestTypes(IncPK(..), CompoundPK(..))
|
||||
|
||||
spec :: Spec
|
||||
spec = afterAll_ resetDb $ around (withApp cfgDefault) $ do
|
||||
spec = beforeAll_ resetDb $ around (withApp cfgDefault) $ do
|
||||
describe "Posting new record" $ do
|
||||
after_ (clearTable "menagerie") . context "disparate csv types" $ do
|
||||
it "accepts disparate json types" $ do
|
||||
@@ -301,17 +301,16 @@ spec = afterAll_ resetDb $ around (withApp cfgDefault) $ do
|
||||
|
||||
context "on an empty table" $
|
||||
it "indicates no records found to update" $
|
||||
request methodPatch "/simple_pk" []
|
||||
request methodPatch "/empty_table" []
|
||||
[json| { "extra":20 } |]
|
||||
`shouldRespondWith` 404
|
||||
|
||||
context "in a nonempty table" . before_ (clearTable "items" >> createItems 15) .
|
||||
after_ (clearTable "items") $ do
|
||||
context "in a nonempty table" $ do
|
||||
it "can update a single item" $ do
|
||||
g <- get "/items?id=eq.42"
|
||||
liftIO $ simpleHeaders g
|
||||
`shouldSatisfy` matchHeader "Content-Range" "\\*/0"
|
||||
request methodPatch "/items?id=eq.1" []
|
||||
request methodPatch "/items?id=eq.2" []
|
||||
[json| { "id":42 } |]
|
||||
`shouldRespondWith` ResponseMatcher {
|
||||
matchBody = Nothing,
|
||||
|
||||
@@ -10,8 +10,7 @@ import SpecHelper
|
||||
|
||||
spec :: Spec
|
||||
spec =
|
||||
beforeAll (clearTable "items" >> createItems 15)
|
||||
. afterAll_ (clearTable "items")
|
||||
beforeAll resetDb
|
||||
. around (withApp $ cfgLimitRows 3) $
|
||||
describe "Requesting many items with server limits enabled" $ do
|
||||
it "restricts results" $
|
||||
|
||||
@@ -11,18 +11,7 @@ import Text.Heredoc
|
||||
|
||||
|
||||
spec :: Spec
|
||||
spec =
|
||||
beforeAll (clearTable "items" >> createItems 15)
|
||||
. beforeAll clearProjectsTable
|
||||
. beforeAll (clearTable "complex_items" >> createComplexItems)
|
||||
. beforeAll (clearTable "nullable_integer" >> createNullInteger)
|
||||
. beforeAll (
|
||||
clearTable "no_pk" >>
|
||||
createNulls 2 >>
|
||||
createLikableStrings >>
|
||||
createJsonData)
|
||||
. afterAll_ (clearTable "items" >> clearTable "complex_items" >> clearTable "no_pk" >> clearTable "simple_pk")
|
||||
. around (withApp cfgDefault) $ do
|
||||
spec = around (withApp cfgDefault) $ do
|
||||
|
||||
describe "Querying a table with a column called count" $
|
||||
it "should not confuse count column with pg_catalog.count aggregate" $
|
||||
@@ -355,8 +344,7 @@ spec =
|
||||
[json| [{"data": {"id": 1, "foo": {"bar": "baz"}}}] |]
|
||||
|
||||
describe "remote procedure call" $ do
|
||||
context "a proc that returns a set" . before_ (clearTable "items" >> createItems 10) .
|
||||
after_ (clearTable "items") $
|
||||
context "a proc that returns a set" $
|
||||
it "returns proper json" $
|
||||
post "/rpc/getitemrange" [json| { "min": 2, "max": 4 } |] `shouldRespondWith`
|
||||
[json| [ {"id": 3}, {"id":4} ] |]
|
||||
|
||||
@@ -9,7 +9,7 @@ import Network.Wai.Test (SResponse(simpleHeaders,simpleStatus))
|
||||
import SpecHelper
|
||||
|
||||
spec :: Spec
|
||||
spec = beforeAll (clearTable "items" >> createItems 15) . afterAll_ (clearTable "items")
|
||||
spec = beforeAll resetDb
|
||||
. around (withApp cfgDefault) $
|
||||
describe "GET /items" $ do
|
||||
|
||||
|
||||
Reference in New Issue
Block a user