Skip to content

Commit

Permalink
test: notify do nothing
Browse files Browse the repository at this point in the history
  • Loading branch information
steve-chavez committed Mar 19, 2024
1 parent ee8b3ef commit 941ea0f
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- #3237, Dump media handlers and timezones with --dump-schema - @wolfgangwalther
- #3323, #3324, Don't hide error on LISTEN channel failure - @steve-chavez
- #3330, Incorrect admin server `/ready` response on slow schema cache loads - @steve-chavez
- #3327, Fix slow responses on schema cache reloads - @steve-chavez
- #3340, Log when the LISTEN channel gets a notification - @steve-chavez

### Deprecated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,23 @@
pdSchema: public
pdVolatility: Volatile

- - qiName: notify_do_nothing
qiSchema: public
- - pdDescription: null
pdFuncSettings: []
pdHasVariadic: false
pdName: notify_do_nothing
pdParams: []
pdReturnType:
contents:
contents:
qiName: void
qiSchema: pg_catalog
tag: Scalar
tag: Single
pdSchema: public
pdVolatility: Volatile

- - qiName: sleep
qiSchema: public
- - pdDescription: null
Expand Down
4 changes: 4 additions & 0 deletions test/io/fixtures.sql
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ begin
perform pg_notify('pgrst', 'reload config');
end $_$ volatile security definer language plpgsql ;

create function notify_do_nothing() returns void as $_$
notify pgrst, 'nothing';
$_$ language sql;

create function reset_invalid_role_claim_key() returns void as $_$
begin
alter role postgrest_test_authenticator reset pgrst.jwt_role_claim_key;
Expand Down
2 changes: 1 addition & 1 deletion test/io/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def test_invalid_openapi_mode(invalidopenapimodes, defaultenv):
print(line)


# If this test is failing, run pytest with --snapshot-update.
# If this test is failing, run postgrest-test-io --snapshot-update -k test_schema_cache_snapshot
@pytest.mark.parametrize(
"key",
[
Expand Down
18 changes: 18 additions & 0 deletions test/io/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,24 @@ def test_invalid_role_claim_key_notify_reload(defaultenv):
assert response.status_code == 204


def test_notify_do_nothing(defaultenv):
"NOTIFY with unknown message should do nothing"

env = {
**defaultenv,
"PGRST_DB_CONFIG": "true",
"PGRST_DB_CHANNEL_ENABLED": "true",
"PGRST_LOG_LEVEL": "crit",
}

with run(env=env) as postgrest:
response = postgrest.session.post("/rpc/notify_do_nothing")
assert response.status_code == 204

output = postgrest.read_stdout()
assert output == []


def test_db_prepared_statements_enable(defaultenv):
"Should use prepared statements when the setting is enabled."

Expand Down

0 comments on commit 941ea0f

Please sign in to comment.