LP#1787274 One active transit pgtap tests
authorBill Erickson <berickxx@gmail.com>
Tue, 18 Sep 2018 15:21:26 +0000 (11:21 -0400)
committerKathy Lussier <klussier@masslnc.org>
Tue, 18 Sep 2018 18:44:54 +0000 (14:44 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Kathy Lussier <klussier@masslnc.org>
Open-ILS/src/sql/Pg/live_t/lp1787274-no-dupe-transits.pg [new file with mode: 0644]

diff --git a/Open-ILS/src/sql/Pg/live_t/lp1787274-no-dupe-transits.pg b/Open-ILS/src/sql/Pg/live_t/lp1787274-no-dupe-transits.pg
new file mode 100644 (file)
index 0000000..41ec628
--- /dev/null
@@ -0,0 +1,39 @@
+-- Load the TAP functions.
+BEGIN;
+
+-- Plan the tests.
+SELECT plan(6);
+
+-- Run the tests.
+
+PREPARE insert_transit AS    
+    INSERT INTO action.transit_copy
+    (target_copy, source, dest, copy_status) VALUES (4003, 4, 7, 0);
+
+PREPARE insert_hold_transit AS
+    INSERT INTO action.hold_transit_copy
+    (target_copy, source, dest, copy_status) VALUES (4003, 4, 7, 8);
+
+PREPARE insert_reservation_transit AS
+    INSERT INTO action.reservation_transit_copy
+    (target_copy, source, dest, copy_status) VALUES (4003, 4, 7, 8);
+
+SELECT lives_ok('insert_transit', 'First transit inserts OK');
+
+SELECT is(
+    (SELECT COUNT(*) FROM action.transit_copy WHERE target_copy = 4003)::INT, 
+    1, 'Confirm a single transit exists'); 
+
+SELECT throws_ok('insert_transit');
+
+SELECT throws_ok('insert_hold_transit');
+
+SELECT throws_ok('insert_reservation_transit');
+
+SELECT is(
+    (SELECT COUNT(*) FROM action.transit_copy WHERE target_copy = 4003)::INT, 
+    1, 'Confirm a single transit exists'); 
+
+-- Finish the tests and clean up.
+SELECT * FROM finish();
+ROLLBACK;