Skip to content

Commit

Permalink
fix(tests): subtest syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
danimarinBG committed Aug 19, 2024
1 parent 44857fe commit d69d8c3
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/upsert/ud/test_cat.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ SELECT plan(3);

-- Subtest 1: Testing cat_work operations | insert/update/delete
SELECT subtest('cat_work operations', $$
BEGIN;
SELECT plan(4);

-- 1. INSERT
Expand All @@ -32,14 +33,19 @@ SELECT subtest('cat_work operations', $$
DELETE FROM cat_work WHERE id = 'work5';
SELECT is((SELECT count(*)::integer FROM cat_work WHERE id = 'work5'), 0, 'DELETE: cat_work "work5" was deleted');

SELECT * FROM finish();
ROLLBACK;
END;
$$);

-- Subtest 2: Testing cat_feature_node operations | insert/update/delete (junction, circ_manhole, sewer_storage)
SELECT subtest('cat_feature_node operations', $$
BEGIN;
SELECT plan(3);

-- JUNCTION
SELECT subtest('cat_feature_node junction operations', $$
BEGIN;
-- 1. INSERT
INSERT INTO cat_feature_node (id, "type", epa_default, num_arcs, choose_hemisphere, isarcdivide, isprofilesurface, isexitupperintro, double_geom)
VALUES('JUNCTION2', 'JUNCTION', 'JUNCTION', 2, true, true, true, 0, '{"activated":false,"value":1}'::json);
Expand All @@ -58,10 +64,15 @@ SELECT subtest('cat_feature_node operations', $$
-- 4. DELETE
DELETE FROM cat_feature_node WHERE id = 'JUNCTION2';
SELECT is((SELECT count(*)::integer FROM cat_feature_node WHERE id = 'JUNCTION2'), 0, 'DELETE: cat_feature_node "JUNCTION2" was deleted');

SELECT * FROM finish();
ROLLBACK;
END;
$$);

-- CIRC_MANHOLE
SELECT subtest('cat_feature_node circ_manhole operations', $$
BEGIN;
-- 1. INSERT
INSERT INTO cat_feature_node (id, "type", epa_default, num_arcs, choose_hemisphere, isarcdivide, isprofilesurface, isexitupperintro, double_geom)
VALUES('CIRC_MANHOLE2', 'MANHOLE', 'JUNCTION', 2, true, true, true, 0, '{"activated":false,"value":1}'::json);
Expand All @@ -80,10 +91,15 @@ SELECT subtest('cat_feature_node operations', $$
-- 4. DELETE
DELETE FROM cat_feature_node WHERE id = 'CIRC_MANHOLE2';
SELECT is((SELECT count(*)::integer FROM cat_feature_node WHERE id = 'CIRC_MANHOLE2'), 0, 'DELETE: cat_feature_node "CIRC_MANHOLE2" was deleted');

SELECT * FROM finish();
ROLLBACK;
END;
$$);

-- SEWER_STORAGE
SELECT subtest('cat_feature_node sewer_storage operations', $$
BEGIN;
-- 1. INSERT
INSERT INTO cat_feature_node (id, "type", epa_default, num_arcs, choose_hemisphere, isarcdivide, isprofilesurface, isexitupperintro, double_geom)
VALUES('SEWER_STORAGE2', 'SEWER_STORAGE', 'SEWER_STORAGE', 2, true, true, false, 0, '{"activated":false,"value":1}'::json);
Expand All @@ -102,7 +118,15 @@ SELECT subtest('cat_feature_node operations', $$
-- 4. DELETE
DELETE FROM cat_feature_node WHERE id = 'SEWER_STORAGE2';
SELECT is((SELECT count(*)::integer FROM cat_feature_node WHERE id = 'SEWER_STORAGE2'), 0, 'DELETE: cat_feature_node "SEWER_STORAGE2" was deleted');

SELECT * FROM finish();
ROLLBACK;
END;
$$);

SELECT * FROM finish();
ROLLBACK;
END;
$$);

-- Subtest 3: Testing cat_feature_arc operations | insert/update/delete (conduit, siphon, waccel, pump_pipe)
Expand Down
10 changes: 10 additions & 0 deletions test/upsert/ud/test_doc.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ SELECT plan(2);

-- Subtest 1: Testing doc_type operations
SELECT subtest('doc_type operations', $$
BEGIN;
SELECT plan(4);

-- 1. INSERT
Expand All @@ -30,10 +31,15 @@ SELECT subtest('doc_type operations', $$
-- 4. DELETE
DELETE FROM doc_type WHERE id = 'AS_BUILT2';
SELECT is((SELECT count(*)::integer FROM doc_type WHERE id = 'AS_BUILT2'), 0, 'DELETE: doc_type AS_BUILT2 was deleted');

SELECT * FROM finish();
ROLLBACK;
END;
$$);

-- Subtest 2: Testing doc operations
SELECT subtest('doc operations', $$
BEGIN;
SELECT plan(4);

-- 1. INSERT
Expand All @@ -54,6 +60,10 @@ SELECT subtest('doc operations', $$
-- 4. DELETE
DELETE FROM doc WHERE id = 'Demo document 4';
SELECT is((SELECT count(*)::integer FROM doc WHERE id = 'Demo document 4'), 0, 'DELETE: doc "Demo document 4" was deleted');

SELECT * FROM finish();
ROLLBACK;
END;
$$);

SELECT * FROM finish();
Expand Down
24 changes: 24 additions & 0 deletions test/upsert/ws/test_cat.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ SELECT plan(3);

-- Subtest 1: Testing cat_work operations | insert/update/delete
SELECT subtest('cat_work operations', $$
BEGIN;
SELECT plan(4);

-- 1. INSERT
Expand All @@ -32,14 +33,19 @@ SELECT subtest('cat_work operations', $$
DELETE FROM cat_work WHERE id = 'work5';
SELECT is((SELECT count(*)::integer FROM cat_work WHERE id = 'work5'), 0, 'DELETE: cat_work "work5" was deleted');

SELECT * FROM finish();
ROLLBACK;
END;
$$);

-- Subtest 2: Testing cat_feature_node operations | insert/update/delete (junction, circ_manhole, sewer_storage)
SELECT subtest('cat_feature_node operations', $$
BEGIN;
SELECT plan(3);

-- JUNCTION
SELECT subtest('cat_feature_node junction operations', $$
BEGIN;
-- 1. INSERT
INSERT INTO cat_feature_node (id, "type", epa_default, num_arcs, choose_hemisphere, isarcdivide, graph_delimiter, isprofilesurface, double_geom)
VALUES('JUNCTION2', 'JUNCTION', 'JUNCTION', 2, true, true, 'NONE', false, '{"activated":false,"value":1}'::json);
Expand All @@ -58,10 +64,15 @@ SELECT subtest('cat_feature_node operations', $$
-- 4. DELETE
DELETE FROM cat_feature_node WHERE id = 'JUNCTION2';
SELECT is((SELECT count(*)::integer FROM cat_feature_node WHERE id = 'JUNCTION2'), 0, 'DELETE: cat_feature_node "JUNCTION2" was deleted');

SELECT * FROM finish();
ROLLBACK;
END;
$$);

-- CIRC_MANHOLE
SELECT subtest('cat_feature_node circ_manhole operations', $$
BEGIN;
-- 1. INSERT
INSERT INTO cat_feature_node (id, "type", epa_default, num_arcs, choose_hemisphere, isarcdivide, graph_delimiter, isprofilesurface, double_geom)
VALUES('CIRC_MANHOLE2', 'CIRC_MANHOLE', 'CIRC_MANHOLE', 2, true, true, 'NONE', false, '{"activated":false,"value":1}'::json);
Expand All @@ -80,10 +91,15 @@ SELECT subtest('cat_feature_node operations', $$
-- 4. DELETE
DELETE FROM cat_feature_node WHERE id = 'CIRC_MANHOLE2';
SELECT is((SELECT count(*)::integer FROM cat_feature_node WHERE id = 'CIRC_MANHOLE2'), 0, 'DELETE: cat_feature_node "CIRC_MANHOLE2" was deleted');

SELECT * FROM finish();
ROLLBACK;
END;
$$);

-- SEWER_STORAGE
SELECT subtest('cat_feature_node sewer_storage operations', $$
BEGIN;
-- 1. INSERT
INSERT INTO cat_feature_node (id, "type", epa_default, num_arcs, choose_hemisphere, isarcdivide, graph_delimiter, isprofilesurface, double_geom)
VALUES('SEWER_STORAGE2', 'SEWER_STORAGE', 'SEWER_STORAGE', 2, true, true, 'NONE', false, '{"activated":false,"value":1}'::json);
Expand All @@ -102,7 +118,15 @@ SELECT subtest('cat_feature_node operations', $$
-- 4. DELETE
DELETE FROM cat_feature_node WHERE id = 'SEWER_STORAGE2';
SELECT is((SELECT count(*)::integer FROM cat_feature_node WHERE id = 'SEWER_STORAGE2'), 0, 'DELETE: cat_feature_node "SEWER_STORAGE2" was deleted');

SELECT * FROM finish();
ROLLBACK;
END;
$$);

SELECT * FROM finish();
ROLLBACK;
END;
$$);

-- Subtest 3: Testing cat_feature_arc operations | insert/update/delete (conduit, siphon, waccel, pump_pipe)
Expand Down
10 changes: 10 additions & 0 deletions test/upsert/ws/test_doc.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ SELECT plan(2);

-- Subtest 1: Testing doc_type operations
SELECT subtest('doc_type operations', $$
BEGIN;
SELECT plan(4);

-- 1. INSERT
Expand All @@ -30,10 +31,15 @@ SELECT subtest('doc_type operations', $$
-- 4. DELETE
DELETE FROM doc_type WHERE id = 'AS_BUILT2';
SELECT is((SELECT count(*)::integer FROM doc_type WHERE id = 'AS_BUILT2'), 0, 'DELETE: doc_type AS_BUILT2 was deleted');

SELECT * FROM finish();
ROLLBACK;
END;
$$);

-- Subtest 2: Testing doc operations
SELECT subtest('doc operations', $$
BEGIN;
SELECT plan(4);

-- 1. INSERT
Expand All @@ -54,6 +60,10 @@ SELECT subtest('doc operations', $$
-- 4. DELETE
DELETE FROM doc WHERE id = 'Demo document 4';
SELECT is((SELECT count(*)::integer FROM doc WHERE id = 'Demo document 4'), 0, 'DELETE: doc "Demo document 4" was deleted');

SELECT * FROM finish();
ROLLBACK;
END;
$$);

SELECT * FROM finish();
Expand Down

0 comments on commit d69d8c3

Please sign in to comment.