Add test for multi_row case #314

This commit is contained in:
Rafa de la Torre 2016-12-14 12:53:51 +01:00
parent 5c8dbe91eb
commit 4523b2e04d
2 changed files with 28 additions and 4 deletions

View File

@ -1,5 +1,6 @@
SET client_min_messages TO warning;
SET search_path TO public,cartodb,cdb_dataservices_client; SET search_path TO public,cartodb,cdb_dataservices_client;
-- Mock the server function to fail -- Mock the server functions to raise exceptions
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) 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 $$ RETURNS Geometry AS $$
BEGIN BEGIN
@ -7,9 +8,15 @@ BEGIN
RETURN NULL; RETURN NULL;
END; END;
$$ LANGUAGE 'plpgsql'; $$ LANGUAGE 'plpgsql';
CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_isodistance(username text, orgname text, source geometry, mode text, range integer[], options text[] DEFAULT ARRAY[]::text[])
RETURNS SETOF isoline AS $$
BEGIN
RAISE EXCEPTION 'Not enough quota or any other exception whatsoever.';
END;
$$ LANGUAGE 'plpgsql';
-- Use regular user role -- Use regular user role
SET ROLE test_regular_user; SET ROLE test_regular_user;
-- Exercise the public and the proxied function -- Exercise the exception safe and the proxied functions
SELECT _cdb_geocode_street_point_exception_safe('One street, 1'); 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. 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)" DETAIL: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_street_point(username, orgname, searchtext, city, state_province, country)"
@ -19,3 +26,10 @@ PL/pgSQL function _cdb_geocode_street_point_exception_safe(text,text,text,text)
(1 row) (1 row)
SELECT the_geom FROM _cdb_isodistance_exception_safe('POINT(-3.70568 40.42028)'::geometry, 'walk', ARRAY[300]::integer[]);
WARNING: cdb_dataservices_client._cdb_isodistance(6): [contrib_regression] REMOTE ERROR: Not enough quota or any other exception whatsoever.
DETAIL: PL/pgSQL function _cdb_isodistance_exception_safe(geometry,text,integer[],text[]) line 21 at RETURN QUERY
the_geom
----------
(0 rows)

View File

@ -1,6 +1,7 @@
SET client_min_messages TO warning;
SET search_path TO public,cartodb,cdb_dataservices_client; SET search_path TO public,cartodb,cdb_dataservices_client;
-- Mock the server function to fail -- Mock the server functions to raise exceptions
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) 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 $$ RETURNS Geometry AS $$
BEGIN BEGIN
@ -9,8 +10,17 @@ BEGIN
END; END;
$$ LANGUAGE 'plpgsql'; $$ LANGUAGE 'plpgsql';
CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_isodistance(username text, orgname text, source geometry, mode text, range integer[], options text[] DEFAULT ARRAY[]::text[])
RETURNS SETOF isoline AS $$
BEGIN
RAISE EXCEPTION 'Not enough quota or any other exception whatsoever.';
END;
$$ LANGUAGE 'plpgsql';
-- Use regular user role -- Use regular user role
SET ROLE test_regular_user; SET ROLE test_regular_user;
-- Exercise the public and the proxied function -- Exercise the exception safe and the proxied functions
SELECT _cdb_geocode_street_point_exception_safe('One street, 1'); SELECT _cdb_geocode_street_point_exception_safe('One street, 1');
SELECT the_geom FROM _cdb_isodistance_exception_safe('POINT(-3.70568 40.42028)'::geometry, 'walk', ARRAY[300]::integer[]);