Respond with 200 or 206 in ranged responses
This commit is contained in:
@@ -1,15 +1,22 @@
|
||||
{-# LANGUAGE OverloadedStrings, QuasiQuotes #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
module Feature.RangeSpec where
|
||||
|
||||
import Test.Hspec
|
||||
import Test.Hspec.Wai
|
||||
import Network.HTTP.Types
|
||||
|
||||
import SpecHelper
|
||||
|
||||
spec :: Spec
|
||||
spec = around appWithFixture $ do
|
||||
describe "GET /view" $
|
||||
spec = around appWithFixture $
|
||||
describe "GET /items" $ do
|
||||
context "without range headers" $
|
||||
context "with response under server size limit" $
|
||||
it "returns whole range with status 200" $
|
||||
get "/auto_incrementing_pk" `shouldRespondWith` 206
|
||||
get "/items" `shouldRespondWith` 200
|
||||
context "with range headers" $
|
||||
context "of acceptable range" $
|
||||
it "succeeds with partial content" $
|
||||
request methodGet "/items"
|
||||
(rangeHdrs $ ByteRangeFromTo 0 1) ""
|
||||
`shouldRespondWith` 206
|
||||
|
||||
@@ -17,6 +17,7 @@ spec = around appWithFixture $ do
|
||||
[json| [
|
||||
{"schema":"1","name":"auto_incrementing_pk","insertable":true}
|
||||
, {"schema":"1","name":"compound_pk","insertable":true}
|
||||
, {"schema":"1","name":"items","insertable":true}
|
||||
, {"schema":"1","name":"menagerie","insertable":true}
|
||||
, {"schema":"1","name":"no_pk","insertable":true}
|
||||
, {"schema":"1","name":"simple_pk","insertable":true}
|
||||
@@ -26,7 +27,7 @@ spec = around appWithFixture $ do
|
||||
describe "Table info" $
|
||||
it "is available with OPTIONS verb" $
|
||||
-- {{{ big json object
|
||||
request methodOptions "/auto_incrementing_pk" "" `shouldRespondWith` [json|
|
||||
request methodOptions "/auto_incrementing_pk" [] "" `shouldRespondWith` [json|
|
||||
{
|
||||
"pkey":["id"],
|
||||
"columns":{
|
||||
|
||||
Reference in New Issue
Block a user