Skip to content

Commit

Permalink
[pgtap] standarizing type_check.pg (#2227)
Browse files Browse the repository at this point in the history
* [format] 2 space indent on .pg files
* [dijkstra] moving old tests around
* [dijkstra][pgtap] standarizing type_check.pg
* [dijkstra][pgtap] keep other tests
* [allpairs][pgtap] moving old tests to edge_cases.pg
* [allpairs][pgtap] standarizing type_check.pg
* [alphaShape][pgtap] standarizing type_check.pg
* [astar][pgtap] moving old test around
* [astar][pgtap] standarizing type_check.pg
* [bdastar][pgtap] moving old tests to remaining_tests.pg
* [bdastar][pgtap] standarizing type_check.pg
* [bdastar][pgtap] keep other tests
* [bddijkstra][pgtap] moving old tests to remaining_tests.pg
* [bddijkstra][pgtap] standarizing type_check.pg
* [bddijkstra][pgtap] standarizing type_check.pg
* [bellmanford][pgtap] standarizing type_check.pg
* [breadthFirstSearch][pgtap] standarizing type_check.pg
* [chinese][pgtap] standarizing type_check.pg
* [coloring][pgtap] standarizing type_check.pg
* [components][pgtap] standarizing type_check.pg
* [contraction][pgtap] moving old tests to remaining_tests.pg
* [chinese][pgtap] standarizing type_check.pg
* [contraction][pgtap] standarizing type_check.pg
* [costMatrix][pgtap] standarizing type_check.pg
* [costMatrix][pgtap] moving to family and removing duplicate tests
* [dag][pgtap] standarizing type_check.pg
* [dominator][pgtap] standarizing type_check.pg
* [driving_distance][pgtap] standarizing type_check.pg
* [DD][pgtap] moving tests to appropiate directory
* [ksp][pgtap] standarizing type_check.pg
* [linegraph][pgtap] standarizing type_check.pg
* [max_flow][pgtap] moving old tests to edge_cases.pg
* [max_flow][pgtap] standarizing type_check.pg
* [max_flow][pgtap] standarizing type_check.pg
* [max_flow][pgtap] standarizing type_check.pg
* [max_flow][pgtap] keeping remaining tests as edge_cases.pg
* [withPoints][pgtap] standarizing type_check.pg
* [mincut][pgtap] standarizing type_check.pg
* [spanningtree][pgtap] standarizing type_check.pg
* [planar][pgtap] standarizing type_check.pg
* [topologicalsort][pgtap] standarizing type_check.pg
* [transitiveclosure][pgtap] standarizing type_check.pg
* [pickDeliver][pgtap] standarizing type_check.pg
* [topology][pgtap] standarizing type_check.pg
* [traversal][pgtap] standarizing type_check.pg
* [version][pgtap] standarizing type_check.pg
* [vrp-basic][pgtap] standarizing type_check.pg
* [trsp][pgtap] standarizing type_check.pg
* [astar] reducing duplicated code on similar functions
* [dijkstra] reducing duplicated code on similar tests
* [BFS][pgtap] moving to traversal
* [dijkstra] fixing error
  • Loading branch information
cvvergara authored Dec 28, 2021
1 parent f1f3598 commit aa5d301
Show file tree
Hide file tree
Showing 131 changed files with 3,921 additions and 3,355 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ indent_size = 8


# SQL files want space indentation
[*.sql]
[*.{sql,pg}]
indent_style = space
indent_size = 2

Expand Down
53 changes: 53 additions & 0 deletions pgtap/allpairs/floydWarshall/edge_cases.pg
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@

BEGIN;


UPDATE edge_table SET cost = sign(cost), reverse_cost = sign(reverse_cost);
SELECT plan(4);

PREPARE q1 AS
SELECT * FROM pgr_floydWarshall(
'SELECT id, source, target, cost, reverse_cost FROM edge_table'
);

PREPARE q2 AS
SELECT * FROM pgr_floydWarshall(
'SELECT source, target, cost, reverse_cost FROM edge_table'
);


PREPARE q3 AS
SELECT * FROM pgr_floydWarshall(
'SELECT source, target, cost FROM edge_table',
true
);


SELECT lives_ok('q1', 'SHOULD WORK: without flag & with id');
SELECT lives_ok('q2', 'SHOULD WORK: without flag');
SELECT lives_ok('q3', 'SHOULD WORK: with flag');


-- CHECKING THE RETURN TYPES
PREPARE v21q00 AS
SELECT pg_typeof(start_vid)::text AS t1,
pg_typeof(end_vid)::text AS t2,
pg_typeof(agg_cost)::TEXT AS t3
FROM (
SELECT * FROM pgr_floydWarshall(
'SELECT id, source, target, cost, reverse_cost FROM edge_table'
)) AS a
LIMIT 1
;

PREPARE v21q01 AS
SELECT 'bigint'::text AS t1,
'bigint'::text AS t2,
'double precision'::text AS t3;

SELECT set_eq('v21q00', 'v21q01','Expected columns names & types');



SELECT finish();
ROLLBACK;
59 changes: 14 additions & 45 deletions pgtap/allpairs/floydWarshall/types_check.pg
Original file line number Diff line number Diff line change
@@ -1,53 +1,22 @@

BEGIN;

SELECT plan(5);

UPDATE edge_table SET cost = sign(cost), reverse_cost = sign(reverse_cost);
SELECT plan(4);

PREPARE q1 AS
SELECT * FROM pgr_floydWarshall(
'SELECT id, source, target, cost, reverse_cost FROM edge_table'
);

PREPARE q2 AS
SELECT * FROM pgr_floydWarshall(
'SELECT source, target, cost, reverse_cost FROM edge_table'
);


PREPARE q3 AS
SELECT * FROM pgr_floydWarshall(
'SELECT source, target, cost FROM edge_table',
true
);


SELECT lives_ok('q1', 'SHOULD WORK: without flag & with id');
SELECT lives_ok('q2', 'SHOULD WORK: without flag');
SELECT lives_ok('q3', 'SHOULD WORK: with flag');


-- CHECKING THE RETURN TYPES
PREPARE v21q00 AS
SELECT pg_typeof(start_vid)::text AS t1,
pg_typeof(end_vid)::text AS t2,
pg_typeof(agg_cost)::TEXT AS t3
FROM (
SELECT * FROM pgr_floydWarshall(
'SELECT id, source, target, cost, reverse_cost FROM edge_table'
)) AS a
LIMIT 1
;

PREPARE v21q01 AS
SELECT 'bigint'::text AS t1,
'bigint'::text AS t2,
'double precision'::text AS t3;

SELECT set_eq('v21q00', 'v21q01','Expected columns names & types');
SELECT has_function('pgr_floydwarshall');
SELECT has_function('pgr_floydwarshall', ARRAY['text','boolean']);
SELECT function_returns('pgr_floydwarshall', ARRAY['text','boolean'],'setof record');

SELECT set_eq(
$$SELECT proargnames from pg_proc where proname = 'pgr_floydwarshall'$$,
$$VALUES
('{"","directed","start_vid","end_vid","agg_cost"}'::TEXT[])
$$);

SELECT set_eq(
$$SELECT proallargtypes from pg_proc where proname = 'pgr_floydwarshall'$$,
$$VALUES
('{25,16,20,20,701}'::OID[])
$$);

SELECT finish();
ROLLBACK;
53 changes: 53 additions & 0 deletions pgtap/allpairs/johnson/edge_cases.pg
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@

BEGIN;


UPDATE edge_table SET cost = sign(cost), reverse_cost = sign(reverse_cost);
SELECT plan(4);

PREPARE q1 AS
SELECT * FROM pgr_johnson(
'SELECT id, source, target, cost, reverse_cost FROM edge_table'
);

PREPARE q2 AS
SELECT * FROM pgr_johnson(
'SELECT source, target, cost, reverse_cost FROM edge_table'
);


PREPARE q3 AS
SELECT * FROM pgr_johnson(
'SELECT source, target, cost FROM edge_table',
true
);


SELECT lives_ok('q1', 'SHOULD WORK: without flag & with id');
SELECT lives_ok('q2', 'SHOULD WORK: without flag');
SELECT lives_ok('q3', 'SHOULD WORK: with flag');


-- CHECKING THE RETURN TYPES
PREPARE v21q00 AS
SELECT pg_typeof(start_vid)::text AS t1,
pg_typeof(end_vid)::text AS t2,
pg_typeof(agg_cost)::TEXT AS t3
FROM (
SELECT * FROM pgr_johnson(
'SELECT id, source, target, cost, reverse_cost FROM edge_table'
)) AS a
LIMIT 1
;

PREPARE v21q01 AS
SELECT 'bigint'::text AS t1,
'bigint'::text AS t2,
'double precision'::text AS t3;

SELECT set_eq('v21q00', 'v21q01','Expected columns names & types');



SELECT finish();
ROLLBACK;
59 changes: 14 additions & 45 deletions pgtap/allpairs/johnson/types_check.pg
Original file line number Diff line number Diff line change
@@ -1,53 +1,22 @@

BEGIN;

SELECT plan(5);

UPDATE edge_table SET cost = sign(cost), reverse_cost = sign(reverse_cost);
SELECT plan(4);

PREPARE q1 AS
SELECT * FROM pgr_johnson(
'SELECT id, source, target, cost, reverse_cost FROM edge_table'
);

PREPARE q2 AS
SELECT * FROM pgr_johnson(
'SELECT source, target, cost, reverse_cost FROM edge_table'
);


PREPARE q3 AS
SELECT * FROM pgr_johnson(
'SELECT source, target, cost FROM edge_table',
true
);


SELECT lives_ok('q1', 'SHOULD WORK: without flag & with id');
SELECT lives_ok('q2', 'SHOULD WORK: without flag');
SELECT lives_ok('q3', 'SHOULD WORK: with flag');


-- CHECKING THE RETURN TYPES
PREPARE v21q00 AS
SELECT pg_typeof(start_vid)::text AS t1,
pg_typeof(end_vid)::text AS t2,
pg_typeof(agg_cost)::TEXT AS t3
FROM (
SELECT * FROM pgr_johnson(
'SELECT id, source, target, cost, reverse_cost FROM edge_table'
)) AS a
LIMIT 1
;

PREPARE v21q01 AS
SELECT 'bigint'::text AS t1,
'bigint'::text AS t2,
'double precision'::text AS t3;

SELECT set_eq('v21q00', 'v21q01','Expected columns names & types');
SELECT has_function('pgr_johnson');
SELECT has_function('pgr_johnson', ARRAY['text','boolean']);
SELECT function_returns('pgr_johnson', ARRAY['text','boolean'],'setof record');

SELECT set_eq(
$$SELECT proargnames from pg_proc where proname = 'pgr_johnson'$$,
$$VALUES
('{"","directed","start_vid","end_vid","agg_cost"}'::TEXT[])
$$);

SELECT set_eq(
$$SELECT proallargtypes from pg_proc where proname = 'pgr_johnson'$$,
$$VALUES
('{25,16,20,20,701}'::OID[])
$$);

SELECT finish();
ROLLBACK;
30 changes: 30 additions & 0 deletions pgtap/alpha_shape/types_check.pg
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
BEGIN;

SELECT plan(4);

SELECT has_function('pgr_alphashape');

/* pgtap does not like geometry type, this is a workaround */
SELECT set_eq(
$$WITH a AS (SELECT unnest(proargtypes) from pg_proc where proname = 'pgr_alphashape')
SELECT typname from a JOIN pg_type ON(oid = unnest)$$,
$$VALUES
('float8'),
('geometry')
$$);
SELECT set_eq(
$$WITH a AS (SELECT prorettype from pg_proc where proname = 'pgr_alphashape')
SELECT typname from a JOIN pg_type ON(oid = prorettype)$$,
$$VALUES
('geometry')
$$);

SELECT set_eq(
$$SELECT proargnames from pg_proc where proname = 'pgr_alphashape'$$,
$$VALUES
('{"","alpha"}'::TEXT[])
$$);


SELECT finish();
ROLLBACK;
File renamed without changes.
8 changes: 8 additions & 0 deletions pgtap/astar/aStarCostMatrix/types_check.pg
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
BEGIN;

SELECT plan(5);

SELECT astarcostmatrix_types_check('pgr_astarcostmatrix');

SELECT finish();
ROLLBACK;
Loading

0 comments on commit aa5d301

Please sign in to comment.