-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcomparison_find_related.pg
115 lines (91 loc) · 3.75 KB
/
comparison_find_related.pg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
------------------------------------------------------------------------------
-- Provide testing for buildings_bulk_load comparisons functions
-- with real world examples of previous comparison bugs
-- protects against the regression of 223
------------------------------------------------------------------------------
-- Turn off echo.
\set QUIET 1
-- Format the output nicely.
\pset format unaligned
\pset tuples_only true
\pset pager
-- Revert all changes on failure.
\set ON_ERROR_ROLLBACK 1
\set ON_ERROR_STOP true
BEGIN;
SELECT plan(9);
--1----------------------------------------------------------
-- Test find_added function on complex data
SELECT results_eq(
'SELECT bulk_load_outline_id FROM buildings_bulk_load.find_added(6) ORDER BY bulk_load_outline_id',
$$VALUES (2091), (2095)$$,
'Check return of buildings bulk load find_added function'
);
--2----------------------------------------------------------
-- Test find_matched function on complex data
SELECT results_eq(
'SELECT building_outline_id, bulk_load_outline_id FROM buildings_bulk_load.find_matched(6) ORDER BY building_outline_id, bulk_load_outline_id',
$$VALUES (1804, 2093)$$,
'Check return of buildings_bulk_load find_matched function'
);
--3----------------------------------------------------------
-- Test find_related in complex data
SELECT results_eq(
'SELECT building_outline_id, bulk_load_outline_id FROM buildings_bulk_load.find_related(6) ORDER BY building_outline_id, bulk_load_outline_id',
$$VALUES (1801, 2089), (1801, 2090),
(1802, 2094), (1802, 2096),
(1803, 2096), (1805, 2096),
(1806, 2092), (1806, 2094)$$,
'Check return of buildings_bulk_load find related function'
);
--4----------------------------------------------------------
-- Test comparisons function inputs complex added outlines
SELECT set_has(
'SELECT bulk_load_outline_id FROM buildings_bulk_load.added',
$$VALUES (2091), (2095)$$,
'Check added outlines after comparisons function has run'
);
--5----------------------------------------------------------
-- Test comparisons function inputs complex matched outlines
-- by building_outline_id
SELECT set_has(
'SELECT building_outline_id FROM buildings_bulk_load.matched',
$$VALUES (1804)$$,
'Check building_outline_id of matched table after comparisons function has run'
);
--6----------------------------------------------------------
-- Test comparsisons function inputs complex related outlines
-- by bulk_load_outline id
SELECT set_has(
'SELECT bulk_load_outline_id FROM buildings_bulk_load.matched',
$$VALUES (2093)$$,
'Check bulk_load_outline_ids of matched table after comparisons function has run'
);
--7----------------------------------------------------------
-- Test comparisons function inputs complex related outlines
-- by building_outline_id
SELECT set_has(
'SELECT building_outline_id FROM buildings_bulk_load.related',
$$VALUES (1801), (1802),
(1803), (1805),
(1806)$$,
'Check building_outline_id of related table after comparisons function has run'
);
--8----------------------------------------------------------
-- Test comparisons function inputs complex related outlines
-- by bulk_load_outline_id
SELECT set_has(
'SELECT bulk_load_outline_id FROM buildings_bulk_load.related',
$$VALUES (2089), (2090),
(2094), (2096),
(2092)$$,
'Check bulk_load_outline_id of related table after comparisons function has run'
);
--9-----------------------------------------------------------
-- Test comparisons function does not input added outlines
-- to related table
SELECT set_hasnt(
'SELECT building_outline_id FROM buildings_bulk_load.related',
$$VALUES (2091), (2095)$$,
'Check bulk_load_outline_id of related table after comparisons function has run'
);