]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/sql/Pg/live_t/lp1787274-no-dupe-transits.pg
LP#1787274 One active transit pgtap tests
[working/Evergreen.git] / Open-ILS / src / sql / Pg / live_t / lp1787274-no-dupe-transits.pg
1 -- Load the TAP functions.
2 BEGIN;
3
4 -- Plan the tests.
5 SELECT plan(6);
6
7 -- Run the tests.
8
9 PREPARE insert_transit AS    
10     INSERT INTO action.transit_copy
11     (target_copy, source, dest, copy_status) VALUES (4003, 4, 7, 0);
12
13 PREPARE insert_hold_transit AS
14     INSERT INTO action.hold_transit_copy
15     (target_copy, source, dest, copy_status) VALUES (4003, 4, 7, 8);
16
17 PREPARE insert_reservation_transit AS
18     INSERT INTO action.reservation_transit_copy
19     (target_copy, source, dest, copy_status) VALUES (4003, 4, 7, 8);
20
21 SELECT lives_ok('insert_transit', 'First transit inserts OK');
22
23 SELECT is(
24     (SELECT COUNT(*) FROM action.transit_copy WHERE target_copy = 4003)::INT, 
25     1, 'Confirm a single transit exists'); 
26
27 SELECT throws_ok('insert_transit');
28
29 SELECT throws_ok('insert_hold_transit');
30
31 SELECT throws_ok('insert_reservation_transit');
32
33 SELECT is(
34     (SELECT COUNT(*) FROM action.transit_copy WHERE target_copy = 4003)::INT, 
35     1, 'Confirm a single transit exists'); 
36
37 -- Finish the tests and clean up.
38 SELECT * FROM finish();
39 ROLLBACK;