Mercurial > gemma
view schema/import_tests.sql @ 5654:358130887c72
Added tag v5.7.1 for changeset 9b3779f649c2
author | Sascha Wilde <wilde@sha-bang.de> |
---|---|
date | Tue, 08 Aug 2023 15:07:00 +0200 |
parents | 52f7264265bb |
children |
line wrap: on
line source
-- This is Free Software under GNU Affero General Public License v >= 3.0 -- without warranty, see README.md and license for details. -- SPDX-License-Identifier: AGPL-3.0-or-later -- License-Filename: LICENSES/AGPL-3.0.txt -- Copyright (C) 2019 by via donau -- – Österreichische Wasserstraßen-Gesellschaft mbH -- Software engineering by Intevation GmbH -- Author(s): -- * Tom Gottfried <tom@intevation.de> -- -- pgTAP test script for import queue -- \set imp_id 99 PREPARE insert_gms AS WITH gms AS ( INSERT INTO waterway.gauge_measurements ( location, measure_date, country_code, sender, language_code, date_issue, reference_code, water_level, date_info, source_organization ) SELECT ('AT', 'XXX', '00001', 'G0001', 1)::isrs, t, 'AT', 'test', 'DE', current_timestamp, 'ZPG', 0, current_timestamp, 'test' FROM generate_series( current_timestamp - '12 h'::interval, current_timestamp - '6 h'::interval, '15 min'::interval) AS times (t) RETURNING id), imps AS ( INSERT INTO import.imports (id, kind, username) VALUES ( $1, 'test', 'test_admin_ro') RETURNING id) INSERT INTO import.track_imports (import_id, relation, key) SELECT imps.id, 'waterway.gauge_measurements', gms.id FROM imps, gms; EXECUTE insert_gms(:imp_id); EXECUTE insert_gms(:imp_id + 1); SELECT ok((SELECT count(*) FROM waterway.gauge_measurements WHERE id IN(SELECT key FROM import.track_imports WHERE import_id IN(:imp_id, :imp_id + 1)) ) = (SELECT count(*) FROM import.track_imports WHERE import_id IN(:imp_id, :imp_id + 1)), 'Tracked entries of test imports exist'); SELECT import.del_import(:imp_id); SELECT ok(0 = (SELECT count(*) FROM waterway.gauge_measurements WHERE id IN(SELECT key FROM import.track_imports WHERE import_id = :imp_id)), 'Tracked entries of first test import are deleted'); SELECT ok((SELECT count(*) FROM waterway.gauge_measurements WHERE id IN(SELECT key FROM import.track_imports WHERE import_id = :imp_id + 1) ) = (SELECT count(*) FROM import.track_imports WHERE import_id = :imp_id + 1), 'Tracked entries of second test import still exist');