Skip to content

Commit

Permalink
(pgtap/trsp) not testing deprecated signatures
Browse files Browse the repository at this point in the history
  • Loading branch information
cvvergara committed Oct 31, 2024
1 parent 1c32892 commit cc056af
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 48 deletions.
22 changes: 12 additions & 10 deletions pgtap/trsp/trsp/edge_cases/compare_dijkstraVia.pg
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,20 @@ BEGIN;
SET extra_float_digits=-3;
UPDATE edges SET cost = sign(cost) + 0.001 * id * id, reverse_cost = sign(reverse_cost) + 0.001 * id * id;

SELECT plan(6);
SELECT CASE WHEN min_version('3.4.0') THEN plan(6) ELSE plan(1) END;

PREPARE related_restriction AS SELECT 100.2 AS cost, ARRAY[4,8] AS path;
PREPARE unrelated_restriction AS SELECT 100 AS cost, ARRAY[33, 32, 25] AS path;

CREATE OR REPLACE FUNCTION edge_cases()
RETURNS SETOF TEXT AS
$BODY$
BEGIN

PREPARE related_restriction AS SELECT 100.2 AS cost, ARRAY[4,8] AS path;
PREPARE unrelated_restriction AS SELECT 100 AS cost, ARRAY[33, 32, 25] AS path;
IF NOT min_version('3.4.0') THEN
RETURN QUERY SELECT skip(1, 'pgr_signature added on 3.4.0');
RETURN;
END IF;

/* Directed */
PREPARE q1 AS
Expand Down Expand Up @@ -91,14 +96,14 @@ BEGIN
RETURN QUERY SELECT set_eq('q51','q51_expected','6: Undirected: without retrictions returns the same as pgr_dijkstra');

PREPARE q61 AS
SELECT seq-1::INTEGER, node::INTEGER, edge::INTEGER, cost::TEXT from pgr_trsp(
SELECT seq-1, node, edge, cost::TEXT from pgr_trsp(
'SELECT id, source, target, cost, reverse_cost from edges',
'related_restriction',
5, 10, false);

PREPARE q61_expected AS
SELECT (row_number() over() -1)::INTEGER, node::INTEGER,
(CASE WHEN edge = -2 THEN -1 ELSE edge END)::INTEGER, cost::text
SELECT (row_number() over() -1), node,
(CASE WHEN edge = -2 THEN -1 ELSE edge END), cost::text
FROM pgr_dijkstraVia(
'select id, source, target, cost, reverse_cost from edges',
ARRAY[5, 6, 10],
Expand All @@ -109,10 +114,7 @@ END;
$BODY$
LANGUAGE plpgsql;

SELECT CASE WHEN min_version('3.4.0')
THEN test
ELSE skip('pgr_trsp new signatures were created on 3.4.0', 1) END
FROM edge_cases() AS test;
SELECT edge_cases();

SELECT finish();
ROLLBACK;
15 changes: 9 additions & 6 deletions pgtap/trsp/trsp/edge_cases/directed_compare_dijkstraVia.pg
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,19 @@ BEGIN;
SET extra_float_digits = -3;
UPDATE edges SET cost = sign(cost) + 0.001 * id * id, reverse_cost = sign(reverse_cost) + 0.001 * id * id;

SELECT plan(3);
SELECT CASE WHEN min_version('3.4.0') THEN plan(3) ELSE plan(1) END;

PREPARE related_restriction AS SELECT 100.2 AS cost, ARRAY[5,9] AS path;
PREPARE unrelated_restriction AS SELECT 100 AS cost, ARRAY[33, 32, 25] AS path;

CREATE OR REPLACE FUNCTION edge_cases() RETURNS SETOF TEXT AS
$BODY$
BEGIN

PREPARE related_restriction AS SELECT 100.2 AS cost, ARRAY[5,9] AS path;
PREPARE unrelated_restriction AS SELECT 100 AS cost, ARRAY[33, 32, 25] AS path;
IF NOT min_version('3.4.0') THEN
RETURN QUERY SELECT skip(1, 'pgr_signature added on 3.4.0');
RETURN;
END IF;

PREPARE q1 AS
SELECT * from pgr_trsp(
Expand Down Expand Up @@ -71,9 +76,7 @@ END;
$BODY$
LANGUAGE plpgsql;

SELECT CASE WHEN min_version('3.4.0')
THEN test ELSE skip('pgr_trsp new signatures were created on 3.4.0', 1) END
FROM edge_cases() AS test;
SELECT edge_cases();

SELECT finish();
ROLLBACK;
10 changes: 6 additions & 4 deletions pgtap/trsp/trsp/edge_cases/edge_cases.pg
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ $BODY$
DECLARE
BEGIN

IF NOT min_version('3.4.0') THEN
RETURN QUERY SELECT skip(1, 'pgr_signature added on 3.4.0');
RETURN;
END IF;

RETURN QUERY SELECT lives_ok($q$
SELECT * FROM pgr_trsp(
$$SELECT * FROM edges order by id$$,
Expand Down Expand Up @@ -63,10 +68,7 @@ END;
$BODY$
LANGUAGE plpgsql;

SELECT CASE WHEN min_version('3.4.0')
THEN test
ELSE skip('pgr_trsp new signatures were created on 3.4.0', 1) END
FROM edge_cases() AS test;
SELECT edge_cases();

SELECT finish();
ROLLBACK;
21 changes: 8 additions & 13 deletions pgtap/trsp/trsp/edge_cases/emptyset_from_i_to_i.pg
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
BEGIN;

UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost);
SELECT plan(76);
SELECT CASE WHEN min_version('3.4.0') THEN plan(76) ELSE plan(2) END;

PREPARE restriction AS SELECT * FROM restrictions;
PREPARE with_reverse AS SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id;
Expand All @@ -38,6 +38,11 @@ DECLARE
msg TEXT;
parameters TEXT;
BEGIN
IF NOT min_version('3.4.0') THEN
RETURN QUERY SELECT skip(1, 'pgr_signature added on 3.4.0');
RETURN;
END IF;

directed = 'Undirected';
IF flag THEN directed = 'Directed'; END IF;

Expand Down Expand Up @@ -68,18 +73,8 @@ END
$BODY$
language plpgsql;

SELECT CASE WHEN min_version('3.4.0')
THEN test
ELSE skip('pgr_trsp new signatures were created on 3.4.0', 1) END
FROM edge_cases(19, true) AS test;

SELECT CASE WHEN min_version('3.4.0')
THEN test
ELSE skip('pgr_trsp new signatures were created on 3.4.0', 1) END
FROM edge_cases(19, false) AS test;
SELECT edge_cases(19, true);
SELECT edge_cases(19, false);


-- Finish the tests and clean up.
SELECT * FROM finish();
ROLLBACK;

11 changes: 7 additions & 4 deletions pgtap/trsp/trsp/edge_cases/issue_244.pg
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ CREATE OR REPLACE FUNCTION edge_cases()
RETURNS SETOF TEXT AS
$BODY$
BEGIN

IF NOT min_version('3.4.0') THEN
RETURN QUERY SELECT skip(1, 'pgr_signature added on 3.4.0');
RETURN;
END IF;

PREPARE q1 AS
SELECT seq, node, edge, cost::text FROM pgr_trsp(
$$SELECT id, source, target, cost FROM edges$$,
Expand All @@ -43,10 +49,7 @@ $BODY$
LANGUAGE plpgsql;


SELECT CASE WHEN min_version('3.4.0')
THEN test
ELSE skip('pgr_trsp new signatures were created on 3.4.0', 1) END
FROM edge_cases() AS test;
SELECT edge_cases();

SELECT finish();
ROLLBACK;
15 changes: 9 additions & 6 deletions pgtap/trsp/trsp/inner_query.pg
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
********************************************************************PGR-GNU*/
BEGIN;

UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost);
SELECT plan(216) END;
UPDATE edges SET cost = sign(cost) + 0.001 * id * id, reverse_cost = sign(reverse_cost) + 0.001 * id * id;
SELECT CASE WHEN min_version('3.4.0') THEN plan(6) ELSE plan(1) END;


CREATE OR REPLACE FUNCTION inner_query()
RETURNS SETOF TEXT AS
Expand All @@ -31,6 +32,11 @@ DECLARE
empty_restriction TEXT;
BEGIN

IF NOT min_version('3.4.0') THEN
RETURN QUERY SELECT skip(1, 'pgr_signature added on 3.4.0');
RETURN;
END IF;

unrelated_restriction := '$$SELECT 1 AS id, 100 AS cost, ARRAY[33, 32, 25] AS path$$';
empty_restriction := '$$SELECT * FROM restrictions WHERE id > 7$$';

Expand All @@ -44,10 +50,7 @@ END;
$BODY$
LANGUAGE plpgsql;

SELECT CASE WHEN min_version('3.4.0')
THEN test
ELSE skip('pgr_trsp new signatures were created on 3.4.0', 1) END
FROM inner_query() AS test;
SELECT inner_query();


SELECT finish();
Expand Down
7 changes: 2 additions & 5 deletions pgtap/trsp/trsp/types_check.pg
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

BEGIN;

SELECT plan(14);
SELECT CASE WHEN min_version('3.4.0') THEN plan(14) ELSE plan(2) END;

SELECT has_function('pgr_trsp');

SELECT CASE WHEN min_version('3.4.0')
THEN test
ELSE skip('pgr_trsp new signatures were created on 3.4.0', 1) END
FROM types_check_general('pgr_trsp') AS test;
SELECT types_check_general('pgr_trsp') AS test;

SELECT finish();
ROLLBACK;

0 comments on commit cc056af

Please sign in to comment.