Skip to content

Commit 8bd0f7a

Browse files
committed
test: move db-pre-config with pg reserved word func to spec tests
Signed-off-by: Taimoor Zaeem <taimoorzaeem@gmail.com>
1 parent baabd17 commit 8bd0f7a

5 files changed

Lines changed: 15 additions & 37 deletions

File tree

test/io/__snapshots__/test_cli/test_schema_cache_snapshot[dbRoutines].yaml

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -478,23 +478,6 @@
478478
pdSchema: public
479479
pdVolatility: Volatile
480480

481-
- - qiName: 'true'
482-
qiSchema: public
483-
- - pdDescription: null
484-
pdFuncSettings: []
485-
pdHasVariadic: false
486-
pdName: 'true'
487-
pdParams: []
488-
pdReturnType:
489-
contents:
490-
contents:
491-
qiName: bool
492-
qiSchema: pg_catalog
493-
tag: Scalar
494-
tag: Single
495-
pdSchema: public
496-
pdVolatility: Volatile
497-
498481
- - qiName: create_function
499482
qiSchema: public
500483
- - pdDescription: null

test/io/fixtures/schema.sql

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,10 +251,6 @@ select * from projects;
251251
create or replace view infinite_recursion as
252252
select * from infinite_recursion;
253253

254-
create or replace function "true"() returns boolean as $_$
255-
select true;
256-
$_$ language sql;
257-
258254
create or replace function notify_pgrst() returns void as $$
259255
notify pgrst;
260256
$$ language sql;

test/io/test_io.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2037,19 +2037,6 @@ def test_connection_error_message_does_not_claim_retry(defaultenv):
20372037
assert any('"message":"Database connection error."' in line for line in output)
20382038

20392039

2040-
def test_db_pre_config_with_pg_reserved_words(defaultenv):
2041-
"The db-pre-config should not fail unexpectedly when function name is a postgres reserved word"
2042-
2043-
env = {
2044-
**defaultenv,
2045-
"PGRST_DB_PRE_CONFIG": "true", # call true function
2046-
}
2047-
2048-
with run(env=env) as postgrest:
2049-
response = postgrest.session.post("/rpc/true")
2050-
assert response.status_code == 200
2051-
2052-
20532040
def test_db_pre_config_with_non_existent_function(defaultenv):
20542041
"Log error when db-pre-config is set to non-existent function"
20552042

test/spec/Feature/Query/RpcSpec.hs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,16 @@ import Test.Hspec.Wai
1010
import Test.Hspec.Wai.JSON
1111
import Text.Heredoc
1212

13-
import PostgREST.Config.PgVersion (PgVersion, pgVersion180)
13+
import PostgREST.Config (AppConfig (..))
14+
import PostgREST.Config.PgVersion (PgVersion, pgVersion180)
15+
import PostgREST.SchemaCache.Identifiers (QualifiedIdentifier (..))
1416

1517
import Protolude hiding (get)
1618
import SpecHelper
1719

1820
spec :: PgVersion -> SpecWithConfig
19-
spec actualPgVersion withConfig = withConfig baseCfg $
20-
describe "remote procedure call" $ do
21+
spec actualPgVersion withConfig = do
22+
withConfig baseCfg $ describe "remote procedure call" $ do
2123
context "a proc that returns a set" $ do
2224
context "returns paginated results" $ do
2325
it "using the Range header" $
@@ -1490,3 +1492,9 @@ spec actualPgVersion withConfig = withConfig baseCfg $
14901492
`shouldRespondWith`
14911493
[json| 1 |]
14921494
{ matchStatus = 200 }
1495+
1496+
withConfig baseCfg { configDbPreConfig = Just $ QualifiedIdentifier "test" "true" } $
1497+
it "should not fail when function name is a pg reserved word" $
1498+
request methodGet "/rpc/true"
1499+
[] ""
1500+
`shouldRespondWith` 200

test/spec/fixtures/schema.sql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3877,3 +3877,7 @@ create or replace function custom_vary_hdr() returns void as $$
38773877
perform set_config('response.headers', '[{"Vary": "X-Test-Accept"}]', false);
38783878
end
38793879
$$ language plpgsql;
3880+
3881+
create or replace function "true"() returns boolean as $_$
3882+
select true;
3883+
$_$ language sql;

0 commit comments

Comments
 (0)