From 59a644bb9981e0999e84dc9b300fe6619ed1797d Mon Sep 17 00:00:00 2001 From: steve-chavez Date: Thu, 30 Jul 2026 22:18:27 -0500 Subject: [PATCH] test: prefer timezone offsets --- .../Feature/Query/Preferences/TimezoneSpec.hs | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/test/spec/Feature/Query/Preferences/TimezoneSpec.hs b/test/spec/Feature/Query/Preferences/TimezoneSpec.hs index fae2431dd..dd13a45e0 100644 --- a/test/spec/Feature/Query/Preferences/TimezoneSpec.hs +++ b/test/spec/Feature/Query/Preferences/TimezoneSpec.hs @@ -55,3 +55,32 @@ spec withConfig = withConfig baseCfg $ do `shouldRespondWith` [json|{"code":"22023","details":null,"hint":null,"message":"invalid value for parameter \"TimeZone\": \"Invalid/Timezone\""}|] { matchStatus = 400 } + + context "test Prefer: timezone offsets" $ do + it "should change with positive offset" $ + request methodGet "/timestamps" + [("Prefer", "timezone=+05:30")] + "" + `shouldRespondWith` + [json|[{"t":"2023-10-18T07:07:59.611-05:30"}, {"t":"2023-10-18T09:07:59.611-05:30"}, {"t":"2023-10-18T11:07:59.611-05:30"}]|] + { matchStatus = 200 + , matchHeaders = [matchContentTypeJson + , "Preference-Applied" <:> "timezone=+05:30"] } + + it "should change with negative offset" $ + request methodGet "/timestamps" + [("Prefer", "timezone=-4")] + "" + `shouldRespondWith` + [json|[{"t":"2023-10-18T08:37:59.611-04:00"}, {"t":"2023-10-18T10:37:59.611-04:00"}, {"t":"2023-10-18T12:37:59.611-04:00"}]|] + { matchStatus = 200 + , matchHeaders = [matchContentTypeJson + , "Preference-Applied" <:> "timezone=-4"] } + + it "fails on leap seconds" $ + request methodGet "/timestamps" + [("Prefer", "timezone=05:30:15")] + "" + `shouldRespondWith` + [json|{"code":"22023","details":"PostgreSQL does not support leap seconds.","hint":null,"message":"time zone \"05:30:15\" appears to use leap seconds"}|] + { matchStatus = 400 }