Test for --max-rows behavior

This commit is contained in:
Joe Nelson
2015-12-05 19:31:53 -08:00
parent cbbb1871bb
commit f4c73c7666
9 changed files with 50 additions and 13 deletions
+1 -1
View File
@@ -12,7 +12,7 @@ import SpecHelper
spec :: Spec
spec = beforeAll
(clearTable "postgrest.auth") . afterAll_ (clearTable "postgrest.auth")
$ around withApp
$ around (withApp cfgDefault)
$ describe "authorization" $ do
it "hides tables that anonymous does not own" $
+1 -1
View File
@@ -12,7 +12,7 @@ import Network.HTTP.Types
-- }}}
spec :: Spec
spec = around withApp $ describe "CORS" $ do
spec = around (withApp cfgDefault) $ describe "CORS" $ do
let preflightHeaders = [
("Accept", "*/*"),
("Origin", "http://example.com"),
+1 -1
View File
@@ -8,7 +8,7 @@ import Network.HTTP.Types
spec :: Spec
spec = beforeAll (clearTable "items" >> createItems 15) . afterAll_ (clearTable "items")
. around withApp $
. around (withApp cfgDefault) $
describe "Deleting" $ do
context "existing record" $ do
it "succeeds with 204 and deletion count" $
+1 -1
View File
@@ -17,7 +17,7 @@ import Control.Monad (replicateM_)
import TestTypes(IncPK(..), CompoundPK(..))
spec :: Spec
spec = afterAll_ resetDb $ around withApp $ do
spec = afterAll_ resetDb $ around (withApp cfgDefault) $ do
describe "Posting new record" $ do
after_ (clearTable "menagerie") . context "disparate csv types" $ do
it "accepts disparate json types" $ do
+32
View File
@@ -0,0 +1,32 @@
module Feature.QueryLimitedSpec where
import Test.Hspec hiding (pendingWith)
import Test.Hspec.Wai
import Test.Hspec.Wai.JSON
import Network.HTTP.Types
import Network.Wai.Test (SResponse(simpleHeaders, simpleStatus))
import SpecHelper
spec :: Spec
spec =
beforeAll (clearTable "items" >> createItems 15)
. afterAll_ (clearTable "items")
. around (withApp $ cfgLimitRows 3) $ do
describe "Requesting many items with server limits enabled" $ do
it "restricts results" $
get "/items"
`shouldRespondWith` ResponseMatcher {
matchBody = Just [json| [{"id":1},{"id":2},{"id":3}] |]
, matchStatus = 206
, matchHeaders = ["Content-Range" <:> "0-2/15"]
}
it "respects additional client limiting" $ do
r <- request methodGet "/items"
(rangeHdrs $ ByteRangeFromTo 0 1) ""
liftIO $ do
simpleHeaders r `shouldSatisfy`
matchHeader "Content-Range" "0-1/15"
simpleStatus r `shouldBe` partialContent206
+1 -1
View File
@@ -22,7 +22,7 @@ spec =
createLikableStrings >>
createJsonData)
. afterAll_ (clearTable "items" >> clearTable "complex_items" >> clearTable "no_pk" >> clearTable "simple_pk")
. around withApp $ do
. around (withApp cfgDefault) $ do
describe "Querying a table with a column called count" $
it "should not confuse count column with pg_catalog.count aggregate" $
+1 -1
View File
@@ -10,7 +10,7 @@ import SpecHelper
spec :: Spec
spec = beforeAll (clearTable "items" >> createItems 15) . afterAll_ (clearTable "items")
. around withApp $
. around (withApp cfgDefault) $
describe "GET /items" $ do
context "without range headers" $ do
+1 -1
View File
@@ -9,7 +9,7 @@ import SpecHelper
import Network.HTTP.Types
spec :: Spec
spec = around withApp $ do
spec = around (withApp cfgDefault) $ do
describe "GET /" $ do
it "lists views in schema" $
request methodGet "/" [] ""