Test for no results case
This commit is contained in:
+3
-1
@@ -111,7 +111,9 @@ respondWithRangedResult rr =
|
|||||||
from = rrFrom rr
|
from = rrFrom rr
|
||||||
to = rrTo rr
|
to = rrTo rr
|
||||||
total = rrTotal rr
|
total = rrTotal rr
|
||||||
status = if (1 + to - from) < total then status206 else status200
|
status = if total == 0 then status204
|
||||||
|
else if (1 + to - from) < total then status206
|
||||||
|
else status200
|
||||||
|
|
||||||
requestedVersion :: RequestHeaders -> Maybe Int
|
requestedVersion :: RequestHeaders -> Maybe Int
|
||||||
requestedVersion hdrs =
|
requestedVersion hdrs =
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ spec = around appWithFixture $
|
|||||||
(rangeHdrs $ ByteRangeFromTo 0 1) ""
|
(rangeHdrs $ ByteRangeFromTo 0 1) ""
|
||||||
liftIO $ do
|
liftIO $ do
|
||||||
simpleHeaders r `shouldSatisfy`
|
simpleHeaders r `shouldSatisfy`
|
||||||
matchHeader "Content-Range" "0-1/[0-9]+"
|
matchHeader "Content-Range" "0-1/15"
|
||||||
simpleStatus r `shouldBe` partialContent206
|
simpleStatus r `shouldBe` partialContent206
|
||||||
|
|
||||||
it "understands open-ended ranges" $
|
it "understands open-ended ranges" $
|
||||||
@@ -33,6 +33,15 @@ spec = around appWithFixture $
|
|||||||
(rangeHdrs $ ByteRangeFrom 0) ""
|
(rangeHdrs $ ByteRangeFrom 0) ""
|
||||||
`shouldRespondWith` 200
|
`shouldRespondWith` 200
|
||||||
|
|
||||||
|
it "returns an empty body when there are no results" $
|
||||||
|
request methodGet "/menagerie"
|
||||||
|
(rangeHdrs $ ByteRangeFromTo 0 1) ""
|
||||||
|
`shouldRespondWith` ResponseMatcher {
|
||||||
|
matchBody = Nothing
|
||||||
|
, matchStatus = 204
|
||||||
|
, matchHeaders = []
|
||||||
|
}
|
||||||
|
|
||||||
context "of invalid range" $
|
context "of invalid range" $
|
||||||
it "fails with 416 for offside range" $
|
it "fails with 416 for offside range" $
|
||||||
request methodGet "/items"
|
request methodGet "/items"
|
||||||
|
|||||||
Reference in New Issue
Block a user