From 7ed8b10776809307d2e5314846a6503b4c410248 Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Wed, 24 Nov 2021 15:31:31 +0100 Subject: [PATCH] test: Remove conditional for pgVersion95 in JsonOperatorSpec pgVersion95 is the minimum already. --- test/Feature/JsonOperatorSpec.hs | 83 ++++++++++++++++---------------- 1 file changed, 41 insertions(+), 42 deletions(-) diff --git a/test/Feature/JsonOperatorSpec.hs b/test/Feature/JsonOperatorSpec.hs index 3ad0e6d7d..4c43be833 100644 --- a/test/Feature/JsonOperatorSpec.hs +++ b/test/Feature/JsonOperatorSpec.hs @@ -8,7 +8,7 @@ import Test.Hspec.Wai import Test.Hspec.Wai.JSON import PostgREST.Config.PgVersion (PgVersion, pgVersion112, - pgVersion121, pgVersion95) + pgVersion121) import Protolude hiding (get) import SpecHelper @@ -209,46 +209,45 @@ spec actualPgVersion = describe "json and jsonb operators" $ do `shouldRespondWith` [json| [{ "data": { "id":" \"escaped" } }] |] - when (actualPgVersion >= pgVersion95) $ - context "json array negative index" $ do - it "can select with negative indexes" $ do - get "/json_arr?select=data->>-1::int&id=in.(1,2)" `shouldRespondWith` - [json| [{"data":3}, {"data":6}] |] - { matchHeaders = [matchContentTypeJson] } - get "/json_arr?select=data->0->>-2::int&id=in.(3,4)" `shouldRespondWith` - [json| [{"data":8}, {"data":7}] |] - { matchHeaders = [matchContentTypeJson] } - get "/json_arr?select=data->-2->>a&id=in.(5,6)" `shouldRespondWith` - [json| [{"a":"A"}, {"a":"[1,2,3]"}] |] - { matchHeaders = [matchContentTypeJson] } + context "json array negative index" $ do + it "can select with negative indexes" $ do + get "/json_arr?select=data->>-1::int&id=in.(1,2)" `shouldRespondWith` + [json| [{"data":3}, {"data":6}] |] + { matchHeaders = [matchContentTypeJson] } + get "/json_arr?select=data->0->>-2::int&id=in.(3,4)" `shouldRespondWith` + [json| [{"data":8}, {"data":7}] |] + { matchHeaders = [matchContentTypeJson] } + get "/json_arr?select=data->-2->>a&id=in.(5,6)" `shouldRespondWith` + [json| [{"a":"A"}, {"a":"[1,2,3]"}] |] + { matchHeaders = [matchContentTypeJson] } - it "can filter with negative indexes" $ do - get "/json_arr?select=data&data->>-3=eq.1" `shouldRespondWith` - [json| [{"data":[1, 2, 3]}] |] - { matchHeaders = [matchContentTypeJson] } - get "/json_arr?select=data&data->-1->>-3=eq.11" `shouldRespondWith` - [json| [{"data":[[9, 8, 7], [11, 12, 13]]}] |] - { matchHeaders = [matchContentTypeJson] } - get "/json_arr?select=data&data->-1->>b=eq.B" `shouldRespondWith` - [json| [{"data":[{"a": "A"}, {"b": "B"}]}] |] - { matchHeaders = [matchContentTypeJson] } - get "/json_arr?select=data&data->-1->b->>-1=eq.5" `shouldRespondWith` - [json| [{"data":[{"a": [1,2,3]}, {"b": [4,5]}]}] |] - { matchHeaders = [matchContentTypeJson] } + it "can filter with negative indexes" $ do + get "/json_arr?select=data&data->>-3=eq.1" `shouldRespondWith` + [json| [{"data":[1, 2, 3]}] |] + { matchHeaders = [matchContentTypeJson] } + get "/json_arr?select=data&data->-1->>-3=eq.11" `shouldRespondWith` + [json| [{"data":[[9, 8, 7], [11, 12, 13]]}] |] + { matchHeaders = [matchContentTypeJson] } + get "/json_arr?select=data&data->-1->>b=eq.B" `shouldRespondWith` + [json| [{"data":[{"a": "A"}, {"b": "B"}]}] |] + { matchHeaders = [matchContentTypeJson] } + get "/json_arr?select=data&data->-1->b->>-1=eq.5" `shouldRespondWith` + [json| [{"data":[{"a": [1,2,3]}, {"b": [4,5]}]}] |] + { matchHeaders = [matchContentTypeJson] } - it "should fail on badly formed negatives" $ do - get "/json_arr?select=data->>-78xy" `shouldRespondWith` - [json| - {"details": "unexpected 'x' expecting digit, \"->\", \"::\" or end of input", - "message": "\"failed to parse select parameter (data->>-78xy)\" (line 1, column 11)"} |] - { matchStatus = 400, matchHeaders = [matchContentTypeJson] } - get "/json_arr?select=data->>--34" `shouldRespondWith` - [json| - {"details": "unexpected \"-\" expecting digit", - "message": "\"failed to parse select parameter (data->>--34)\" (line 1, column 9)"} |] - { matchStatus = 400, matchHeaders = [matchContentTypeJson] } - get "/json_arr?select=data->>-xy-4" `shouldRespondWith` - [json| - {"details":"unexpected \"x\" expecting digit", - "message":"\"failed to parse select parameter (data->>-xy-4)\" (line 1, column 9)"} |] - { matchStatus = 400, matchHeaders = [matchContentTypeJson] } + it "should fail on badly formed negatives" $ do + get "/json_arr?select=data->>-78xy" `shouldRespondWith` + [json| + {"details": "unexpected 'x' expecting digit, \"->\", \"::\" or end of input", + "message": "\"failed to parse select parameter (data->>-78xy)\" (line 1, column 11)"} |] + { matchStatus = 400, matchHeaders = [matchContentTypeJson] } + get "/json_arr?select=data->>--34" `shouldRespondWith` + [json| + {"details": "unexpected \"-\" expecting digit", + "message": "\"failed to parse select parameter (data->>--34)\" (line 1, column 9)"} |] + { matchStatus = 400, matchHeaders = [matchContentTypeJson] } + get "/json_arr?select=data->>-xy-4" `shouldRespondWith` + [json| + {"details":"unexpected \"x\" expecting digit", + "message":"\"failed to parse select parameter (data->>-xy-4)\" (line 1, column 9)"} |] + { matchStatus = 400, matchHeaders = [matchContentTypeJson] }