LP#1793802 Aged billings/payments PGTAP tests
authorBill Erickson <berickxx@gmail.com>
Fri, 21 Sep 2018 19:53:23 +0000 (15:53 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Fri, 6 Sep 2019 21:38:53 +0000 (17:38 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Chris Sharp <csharp@georgialibraries.org>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/sql/Pg/live_t/lp1793802-aged-billings-payments.pg [new file with mode: 0644]

diff --git a/Open-ILS/src/sql/Pg/live_t/lp1793802-aged-billings-payments.pg b/Open-ILS/src/sql/Pg/live_t/lp1793802-aged-billings-payments.pg
new file mode 100644 (file)
index 0000000..cce5ce1
--- /dev/null
@@ -0,0 +1,47 @@
+-- Load the TAP functions.
+BEGIN;
+
+-- Plan the tests.
+SELECT plan(8);
+
+SELECT is(
+    (SELECT COUNT(*) FROM money.billing WHERE xact = 9),
+    1::BIGINT, 'Confirm billing for xact exists'
+);
+
+SELECT is(
+    (SELECT COUNT(*) FROM money.payment WHERE xact = 9),
+    1::BIGINT, 'Confirm payment for xact exists'
+);
+
+PREPARE age_circ AS DELETE FROM action.circulation WHERE id = 9;
+SELECT lives_ok('age_circ', 'Age circulation without errors');
+
+SELECT is(
+    (SELECT COUNT(*) FROM action.aged_circulation WHERE id = 9),
+    1::BIGINT, 'Confirm circ aged'
+);
+
+SELECT is(
+    (SELECT COUNT(*) FROM money.aged_billing WHERE xact = 9),
+    1::BIGINT, 'Confirm aged billing created'
+);
+
+SELECT is(
+    (SELECT COUNT(*) FROM money.aged_payment WHERE xact = 9),
+    1::BIGINT, 'Confirm aged payment created'
+);
+
+SELECT is(
+    (SELECT COUNT(*) FROM money.billing WHERE xact = 9),
+    0::BIGINT, 'Confirm source billing deleted'
+);
+
+SELECT is(
+    (SELECT COUNT(*) FROM money.payment WHERE xact = 9),
+    0::BIGINT, 'Confirm source payment deleted'
+);
+
+-- Finish the tests and clean up.
+SELECT * FROM finish();
+ROLLBACK;