From c73c676849450ddce60b63853a1a5c67113d931e Mon Sep 17 00:00:00 2001 From: Taimoor Zaeem Date: Sat, 4 Jul 2026 15:51:26 +0500 Subject: [PATCH] test: move error verbosity test from io tests to spec tests Signed-off-by: Taimoor Zaeem --- test/io/test_io.py | 32 ---------------------------- test/spec/Feature/Query/ErrorSpec.hs | 14 +++++++++++- 2 files changed, 13 insertions(+), 33 deletions(-) diff --git a/test/io/test_io.py b/test/io/test_io.py index 19cdaaa14..181e5e86e 100644 --- a/test/io/test_io.py +++ b/test/io/test_io.py @@ -2087,38 +2087,6 @@ def test_server_timing_transaction_duration_with_role_statement_timeout( assert 2000 <= response_dur < 3000 -def test_client_error_verbosity_config(defaultenv): - "Test PostgREST errors with different error verbosity settings" - - env = { - **defaultenv, - "PGRST_CLIENT_ERROR_VERBOSITY": "minimal", # hide details and hint - } - - with run(env=env) as postgrest: - response = postgrest.session.get("/itemsx") - assert response.status_code == 404 - assert response.json() == { - "code": "PGRST205", - "message": "Could not find the table 'public.itemsx' in the schema cache", - } - - env = { - **defaultenv, - "PGRST_CLIENT_ERROR_VERBOSITY": "verbose", - } - - with run(env=env) as postgrest: - response = postgrest.session.get("/itemsx") - assert response.status_code == 404 - assert response.json() == { - "code": "PGRST205", - "message": "Could not find the table 'public.itemsx' in the schema cache", - "details": None, - "hint": "Perhaps you meant the table 'public.items'", - } - - def test_positive_pool_metric(defaultenv): "When a network failure is caused on the pg connection, pgrst_db_pool_available stays positive" diff --git a/test/spec/Feature/Query/ErrorSpec.hs b/test/spec/Feature/Query/ErrorSpec.hs index b0f8a8b8b..38259c309 100644 --- a/test/spec/Feature/Query/ErrorSpec.hs +++ b/test/spec/Feature/Query/ErrorSpec.hs @@ -5,7 +5,7 @@ import Test.Hspec import Test.Hspec.Wai import Test.Hspec.Wai.JSON -import PostgREST.Config (AppConfig (..)) +import PostgREST.Config (AppConfig (..), Verbosity (..)) import Protolude hiding (get) import SpecHelper @@ -223,3 +223,15 @@ spec withConfig = do "message":"Wrong or unsupported encoding algorithm" }|] { matchStatus = 401 } + + -- By default, error verbosity is set to 'verbose', which returns all error + -- fields. No need to test that explicitly. + withConfig baseCfg { configClientErrorVerbosity = Minimal } $ describe "Test client-error-verbosity config" $ + it "hides details and hint when set to 'minimal'" $ + request methodGet "/itemsx" [] "" + `shouldRespondWith` + [json|{ + "code":"PGRST205", + "message":"Could not find the table 'test.itemsx' in the schema cache" + }|] + { matchStatus = 404 }