Skip to content

Commit 50ca5a9

Browse files
committed
Updating pgtap functions based on executions
1 parent 3f39906 commit 50ca5a9

3 files changed

Lines changed: 50 additions & 19 deletions

File tree

pgtap/dijkstra/dijkstraVia/edge_cases/issue-3110.pg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ CREATE OR REPLACE FUNCTION test_function()
1212
RETURNS SETOF TEXT AS
1313
$BODY$
1414
BEGIN
15-
IF NOT min_version('4.0.1') THEN
15+
IF NOT min_lib_version('4.0.2') THEN
1616
RETURN query
17-
SELECT skip(1, 'bad alloc error Fixed on 4.0.1');
17+
SELECT skip(1, 'bad alloc error Fixed on 4.0.2');
1818
RETURN;
1919
END IF;
2020

pgtap/standards/negative_distance_throws.pg

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,24 +44,52 @@ DECLARE
4444
stmt TEXT = 'SELECT * FROM pgr_drivingDistance';
4545
BEGIN
4646

47-
RAISE NOTICE '%', stmt;
4847
IF min_lib_version('4.0.2') THEN
4948
RETURN QUERY
5049
SELECT throws_ok(stmt || $$('edges', 1, -3.5)$$);
5150

5251
RETURN QUERY
5352
SELECT throws_ok(stmt || $$('edges', 1, -3.5)$$,
5453
'XX000', $$Negative value found on 'distance'$$, fn || ': Negative distance throws');
55-
ELSE
54+
55+
RETURN QUERY
56+
SELECT lives_ok(stmt || $$('edges', 1, 0)$$, fn || ': 0 is ok');
57+
58+
ELSEIF min_version('4.0.0') THEN
59+
5660
RETURN QUERY
5761
SELECT lives_ok(stmt || $$('edges', 1, -3.5)$$, 'Silently ignores negative values');
5862

5963
RETURN QUERY
6064
SELECT lives_ok(stmt || $$('edges', 1, -3.5)$$, 'Silently ignores negative values');
65+
66+
RETURN QUERY
67+
SELECT lives_ok(stmt || $$('edges', 1, 0)$$, fn || ': 0 is ok');
68+
69+
ELSEIF min_version('3.7.0') THEN
70+
71+
RETURN QUERY
72+
SELECT lives_ok(stmt || $$('edges', 1, -3.5)$$, 'Silently ignores negative values');
73+
74+
RETURN QUERY
75+
SELECT lives_ok(stmt || $$('edges', 1, -3.5)$$, 'Silently ignores negative values');
76+
77+
RETURN QUERY
78+
SELECT lives_ok(stmt || $$('edges', 1, 0)$$, fn || ': 0 is ok');
79+
80+
ELSE
81+
82+
RETURN QUERY
83+
SELECT lives_ok(stmt || $$('edges', 1, -3.5)$$);
84+
85+
RETURN QUERY
86+
SELECT lives_ok(stmt || $$('edges', 1, -3.5)$$);
87+
88+
RETURN QUERY
89+
SELECT lives_ok(stmt || $$('edges', 1, 0)$$);
90+
6191
END IF;
6292

63-
RETURN QUERY
64-
SELECT lives_ok(stmt || $$('edges', 1, 0)$$, fn || ': 0 is ok');
6593
END;
6694
$BODY$
6795
LANGUAGE plpgsql;
@@ -74,8 +102,8 @@ DECLARE
74102
BEGIN
75103

76104
IF min_lib_version('4.0.2') THEN
77-
78105
-- v4.0.2+: distance < 0, standardized message
106+
79107
RETURN QUERY
80108
SELECT throws_ok(stmt || $$('edges', 'points', 1, -3.5)$$);
81109

@@ -88,6 +116,7 @@ BEGIN
88116

89117
ELSIF min_lib_version('4.0.0') THEN
90118
-- v4.0.0-v4.0.1: distance <= 0, different message, distance=0 also throws
119+
91120
RETURN QUERY
92121
SELECT throws_ok(stmt || $$('edges', 'points', 1, -3.5)$$);
93122

@@ -96,7 +125,7 @@ BEGIN
96125
'XX000', $$Invalid value of 'distance'$$, fn || ': Negative distance throws');
97126

98127
RETURN QUERY
99-
SELECT throws_ok(stmt || $$('edges', 'points', 1, 0)$$, fn || ': 0 throws too');
128+
SELECT throws_ok(stmt || $$('edges', 'points', 1, 0)$$);
100129

101130
ELSE
102131
-- v3.0.0-v3.8.0: no check
@@ -120,7 +149,6 @@ DECLARE
120149
stmt TEXT = 'SELECT * FROM ' || fn;
121150
BEGIN
122151

123-
RAISE NOTICE '%', stmt;
124152
RETURN QUERY
125153
SELECT throws_ok(stmt || $$('edges', 1, -3.5)$$);
126154

@@ -156,10 +184,11 @@ BEGIN
156184
PREPARE points AS
157185
SELECT pid, edge_id, fraction, side from pointsOfInterest;
158186

159-
RETURN QUERY SELECT test_DD();
160187
RETURN QUERY SELECT test_mst('pgr_primDD');
161188
RETURN QUERY SELECT test_mst('pgr_kruskalDD');
189+
RETURN QUERY SELECT test_DD();
162190
RETURN QUERY SELECT test_withPDD();
191+
163192
END;
164193
$BODY$
165194
LANGUAGE plpgsql;

pgtap/withPoints/withPointsVia/edge_cases/issue-3110.pg

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,20 @@
55
BEGIN;
66
SET client_min_messages TO WARNING;
77

8-
SELECT CASE WHEN min_version('4.0.1') THEN plan(8) ELSE plan(1) END;
8+
SELECT CASE WHEN min_version('4.0.1') THEN plan(8) ELSE plan(8) END;
99

1010

1111
CREATE OR REPLACE FUNCTION test_function()
1212
RETURNS SETOF TEXT AS
1313
$BODY$
1414
BEGIN
15+
/*
1516
IF NOT min_version('4.0.1') THEN
1617
RETURN query
1718
SELECT skip(1, 'bad alloc error Fixed on 4.0.1');
1819
RETURN;
1920
END IF;
21+
*/
2022

2123
PREPARE edges AS
2224
SELECT *
@@ -34,31 +36,31 @@ BEGIN
3436
) AS t(pid, edge_id, fraction);
3537

3638
RETURN QUERY
37-
SELECT lives_ok($$SELECT * FROM pgr_withPointsVia('edges', 'points', ARRAY[1, 3, 4], 'r')$$,
39+
SELECT lives_ok($$SELECT * FROM pgr_withPointsVia('edges', 'points', ARRAY[1, 3, 4])$$,
3840
'withPointsVia lives when all via vertices exist in the graph');
3941
RETURN QUERY
40-
SELECT isnt_empty($$SELECT * FROM pgr_withPointsVia('edges', 'points', ARRAY[1, 3, 4], 'r')$$,
42+
SELECT isnt_empty($$SELECT * FROM pgr_withPointsVia('edges', 'points', ARRAY[1, 3, 4])$$,
4143
'withPointsVia returns results when all via vertices exist in the graph');
4244

4345
RETURN QUERY
44-
SELECT lives_ok($$SELECT * FROM pgr_withPointsVia('edges', 'points', ARRAY[1, 3, 5], 'r')$$,
46+
SELECT lives_ok($$SELECT * FROM pgr_withPointsVia('edges', 'points', ARRAY[1, 3, 5])$$,
4547
'withPointsVia lives when a via vertex does not exist in the graph');
4648
RETURN QUERY
47-
SELECT isnt_empty($$SELECT * FROM pgr_withPointsVia('edges', 'points', ARRAY[1, 3, 5], 'r')$$,
49+
SELECT isnt_empty($$SELECT * FROM pgr_withPointsVia('edges', 'points', ARRAY[1, 3, 5])$$,
4850
'withPointsVia returns results when a via vertex does not exist in the graph');
4951

5052
RETURN QUERY
51-
SELECT lives_ok($$SELECT * FROM pgr_withPointsVia('edges', 'points', ARRAY[1, 5, 4], 'r')$$,
53+
SELECT lives_ok($$SELECT * FROM pgr_withPointsVia('edges', 'points', ARRAY[1, 5, 4])$$,
5254
'withPointsVia handles via vertex missing between two valid vertices');
5355
RETURN QUERY
54-
SELECT is_empty($$SELECT * FROM pgr_withPointsVia('edges', 'points', ARRAY[1, 5, 4], 'r');$$,
56+
SELECT is_empty($$SELECT * FROM pgr_withPointsVia('edges', 'points', ARRAY[1, 5, 4]);$$,
5557
'withPointsVia returns empty when via vertex missing between two valid vertices');
5658

5759
RETURN QUERY
58-
SELECT lives_ok($$SELECT * FROM pgr_withPointsVia('edges', 'points', ARRAY[1, -1, 4], 'r')$$,
60+
SELECT lives_ok($$SELECT * FROM pgr_withPointsVia('edges', 'points', ARRAY[1, -1, 4])$$,
5961
'withPointsVia lives when via includes a point pid that exists');
6062
RETURN QUERY
61-
SELECT isnt_empty($$SELECT * FROM pgr_withPointsVia('edges', 'points', ARRAY[1, -1, 4], 'r')$$,
63+
SELECT isnt_empty($$SELECT * FROM pgr_withPointsVia('edges', 'points', ARRAY[1, -1, 4])$$,
6264
'withPointsVia returns results when via includes a point pid that exists');
6365
END
6466
$BODY$

0 commit comments

Comments
 (0)