From 5c8dbe91eb62356ee50fcf230f1cd9e549b735a7 Mon Sep 17 00:00:00 2001 From: Rafa de la Torre Date: Wed, 14 Dec 2016 12:39:56 +0100 Subject: [PATCH] Add test for simple interface case #314 --- ..._exception_safe_private_functions_test.out | 21 +++++++++++++++++++ ..._exception_safe_private_functions_test.sql | 16 ++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 client/test/expected/25_exception_safe_private_functions_test.out create mode 100644 client/test/sql/25_exception_safe_private_functions_test.sql diff --git a/client/test/expected/25_exception_safe_private_functions_test.out b/client/test/expected/25_exception_safe_private_functions_test.out new file mode 100644 index 0000000..01b79ed --- /dev/null +++ b/client/test/expected/25_exception_safe_private_functions_test.out @@ -0,0 +1,21 @@ +SET search_path TO public,cartodb,cdb_dataservices_client; +-- Mock the server function to fail +CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_street_point (username text, orgname text, searchtext text, city text DEFAULT NULL, state_province text DEFAULT NULL, country text DEFAULT NULL) +RETURNS Geometry AS $$ +BEGIN + RAISE EXCEPTION 'Not enough quota or any other exception whatsoever.'; + RETURN NULL; +END; +$$ LANGUAGE 'plpgsql'; +-- Use regular user role +SET ROLE test_regular_user; +-- Exercise the public and the proxied function +SELECT _cdb_geocode_street_point_exception_safe('One street, 1'); +WARNING: cdb_dataservices_client._cdb_geocode_street_point(6): [contrib_regression] REMOTE ERROR: Not enough quota or any other exception whatsoever. +DETAIL: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_street_point(username, orgname, searchtext, city, state_province, country)" +PL/pgSQL function _cdb_geocode_street_point_exception_safe(text,text,text,text) line 21 at SQL statement + _cdb_geocode_street_point_exception_safe +------------------------------------------ + +(1 row) + diff --git a/client/test/sql/25_exception_safe_private_functions_test.sql b/client/test/sql/25_exception_safe_private_functions_test.sql new file mode 100644 index 0000000..c5a1831 --- /dev/null +++ b/client/test/sql/25_exception_safe_private_functions_test.sql @@ -0,0 +1,16 @@ +SET search_path TO public,cartodb,cdb_dataservices_client; + +-- Mock the server function to fail +CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_street_point (username text, orgname text, searchtext text, city text DEFAULT NULL, state_province text DEFAULT NULL, country text DEFAULT NULL) +RETURNS Geometry AS $$ +BEGIN + RAISE EXCEPTION 'Not enough quota or any other exception whatsoever.'; + RETURN NULL; +END; +$$ LANGUAGE 'plpgsql'; + +-- Use regular user role +SET ROLE test_regular_user; + +-- Exercise the public and the proxied function +SELECT _cdb_geocode_street_point_exception_safe('One street, 1');