feat: add timezone in Prefer header (#3024)
* increase reloading timeout in io-tests * increase memory test by 1M
This commit is contained in:
@@ -12,7 +12,7 @@ import SpecHelper
|
||||
|
||||
spec :: SpecWith ((), Application)
|
||||
spec =
|
||||
describe "check prefer: handling=strict and handling=lenient" $ do
|
||||
describe "test prefer headers and preference-applied headers" $ do
|
||||
|
||||
context "check behaviour of Prefer: handling=strict" $ do
|
||||
it "throws error when handling=strict and invalid prefs are given" $
|
||||
@@ -71,3 +71,51 @@ spec =
|
||||
{ matchStatus = 200
|
||||
, matchHeaders = [matchContentTypeJson]
|
||||
}
|
||||
|
||||
context "test Prefer: timezone=America/Los_Angeles" $ do
|
||||
it "should change timezone with handling=strict" $
|
||||
request methodGet "/timestamps"
|
||||
[("Prefer", "handling=strict, timezone=America/Los_Angeles")]
|
||||
""
|
||||
`shouldRespondWith`
|
||||
[json|[{"t":"2023-10-18T05:37:59.611-07:00"}, {"t":"2023-10-18T07:37:59.611-07:00"}, {"t":"2023-10-18T09:37:59.611-07:00"}]|]
|
||||
{ matchStatus = 200
|
||||
, matchHeaders = [matchContentTypeJson
|
||||
, "Preference-Applied" <:> "handling=strict, timezone=America/Los_Angeles"]}
|
||||
|
||||
it "should change timezone without handling=strict" $
|
||||
request methodGet "/timestamps"
|
||||
[("Prefer", "timezone=America/Los_Angeles")]
|
||||
""
|
||||
`shouldRespondWith`
|
||||
[json|[{"t":"2023-10-18T05:37:59.611-07:00"}, {"t":"2023-10-18T07:37:59.611-07:00"}, {"t":"2023-10-18T09:37:59.611-07:00"}]|]
|
||||
{ matchStatus = 200
|
||||
, matchHeaders = [matchContentTypeJson
|
||||
, "Preference-Applied" <:> "timezone=America/Los_Angeles"] }
|
||||
|
||||
context "test Prefer: timezone=Invalid/Timezone" $ do
|
||||
it "should throw error with handling=strict" $
|
||||
request methodGet "/timestamps"
|
||||
[("Prefer", "handling=strict, timezone=Invalid/Timezone")]
|
||||
""
|
||||
`shouldRespondWith`
|
||||
[json|{"code":"PGRST122","details":"Invalid preferences: timezone=Invalid/Timezone","hint":null,"message":"Invalid preferences given with handling=strict"}|]
|
||||
{ matchStatus = 400 }
|
||||
|
||||
it "should return with default timezone without handling or with handling=lenient" $ do
|
||||
request methodGet "/timestamps"
|
||||
[("Prefer", "timezone=Invalid/Timezone")]
|
||||
""
|
||||
`shouldRespondWith`
|
||||
[json|[{"t":"2023-10-18T12:37:59.611+00:00"}, {"t":"2023-10-18T14:37:59.611+00:00"}, {"t":"2023-10-18T16:37:59.611+00:00"}]|]
|
||||
{ matchStatus = 200
|
||||
, matchHeaders = [matchContentTypeJson]}
|
||||
|
||||
request methodGet "/timestamps"
|
||||
[("Prefer", "handling=lenient, timezone=Invalid/Timezone")]
|
||||
""
|
||||
`shouldRespondWith`
|
||||
[json|[{"t":"2023-10-18T12:37:59.611+00:00"}, {"t":"2023-10-18T14:37:59.611+00:00"}, {"t":"2023-10-18T16:37:59.611+00:00"}]|]
|
||||
{ matchStatus = 200
|
||||
, matchHeaders = [matchContentTypeJson
|
||||
, "Preference-Applied" <:> "handling=lenient"]}
|
||||
|
||||
Vendored
+5
@@ -861,3 +861,8 @@ INSERT INTO table_b(table_a_id, name) VALUES (1, 'Test 1'), (2, 'Test 2'), (null
|
||||
|
||||
TRUNCATE TABLE lines CASCADE;
|
||||
insert into lines values (1, 'line-1', 'LINESTRING(1 1,5 5)'::extensions.geometry), (2, 'line-2', 'LINESTRING(2 2,6 6)'::extensions.geometry);
|
||||
|
||||
TRUNCATE TABLE timestamps CASCADE;
|
||||
INSERT INTO timestamps VALUES ('2023-10-18 12:37:59.611000+0000');
|
||||
INSERT INTO timestamps VALUES ('2023-10-18 14:37:59.611000+0000');
|
||||
INSERT INTO timestamps VALUES ('2023-10-18 16:37:59.611000+0000');
|
||||
|
||||
Vendored
+4
@@ -3627,3 +3627,7 @@ create aggregate test.bom_csv_agg (test.lines) (
|
||||
);
|
||||
|
||||
create table empty_string as select 1 as id, ''::text as string;
|
||||
|
||||
create table timestamps (
|
||||
t timestamp with time zone
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user