5 -- Workstations to use for tests:
6 \set BR1_ws_name 'BR1-lp1883171-pgtap-live_t'
7 \set BR4_ws_name 'BR4-lp1883171-pgtap-live_t'
9 -- Fixed timestamp to check for duplicates:
10 \set fixed_ts '2021-10-24 11:52:33.604067-04'
16 -- Copy from BR3 to test floating.
19 -- A name for a floating group to test floating.
20 \set SYS2_floating_group_name 'SYS2 Float Group'
22 -- Create workstations:
23 INSERT INTO actor.workstation
29 -- Create the floating group and define its members
30 INSERT INTO config.floating_group
32 VALUES (:'SYS2_floating_group_name');
34 INSERT INTO config.floating_group_member
35 (floating_group, org_unit, stop_depth)
37 FROM config.floating_group
38 WHERE name = :'SYS2_floating_group_name';
40 -- Let the copy at BR3 float to SYS2
42 SET floating = floating_group.id
43 FROM config.floating_group
44 WHERE copy.id = :BR3_copy_id
45 AND floating_group.name = :'SYS2_floating_group_name';
47 PREPARE insert_null_all AS INSERT INTO asset.copy_inventory (inventory_workstation, inventory_date, copy)
48 VALUES (NULL, :'fixed_ts', :BR1_copy_id),
49 (NULL, :'fixed_ts', :BR3_copy_id),
50 (NULL, :'fixed_ts', :BR4_copy_id);
51 SELECT lives_ok('insert_null_all', 'NULL workstation should succeed');
53 PREPARE insert_br1_br1 AS INSERT INTO asset.copy_inventory(inventory_workstation, copy)
54 SELECT id, :BR1_copy_id
55 FROM actor.workstation
56 WHERE name = :'BR1_ws_name';
57 SELECT lives_ok('insert_br1_br1', 'BR1 at BR1 should succeed');
59 PREPARE insert_br1_br4 AS INSERT INTO asset.copy_inventory (inventory_workstation, copy)
60 SELECT id, :BR1_copy_id
61 FROM actor.workstation
62 WHERE name = :'BR4_ws_name';
63 SELECT throws_ok('insert_br1_br4');
65 PREPARE insert_br4_br1 AS INSERT INTO asset.copy_inventory (inventory_workstation, copy)
66 SELECT id, :BR4_copy_id
67 FROM actor.workstation
68 WHERE name = :'BR1_ws_name';
69 SELECT throws_ok('insert_br4_br1');
71 PREPARE insert_br3_br1 AS INSERT INTO asset.copy_inventory (inventory_workstation, copy)
72 SELECT id, :BR3_copy_id
73 FROM actor.workstation
74 WHERE name = :'BR1_ws_name';
75 SELECT throws_ok('insert_br3_br1');
77 PREPARE insert_br4_br4 AS INSERT INTO asset.copy_inventory(inventory_workstation, copy)
78 SELECT id, :BR4_copy_id
79 FROM actor.workstation
80 WHERE name = :'BR4_ws_name';
81 SELECT lives_ok('insert_br4_br4', 'BR4 at BR4 should succeed');
83 PREPARE insert_br3_br4 AS INSERT INTO asset.copy_inventory(inventory_workstation, copy)
84 SELECT id, :BR3_copy_id
85 FROM actor.workstation
86 WHERE name = :'BR4_ws_name';
87 SELECT lives_ok('insert_br3_br4', 'BR3 at BR4 should succeed');
89 PREPARE dup_insert_br3_br4 AS INSERT INTO asset.copy_inventory (inventory_workstation, inventory_date, copy)
90 SELECT id, :'fixed_ts', :BR3_copy_id
91 FROM actor.workstation
92 WHERE name = :'BR4_ws_name';
93 SELECT throws_ok('dup_insert_br3_br4', 23505);
95 SELECT throws_ok('insert_null_all', 23505);
97 SELECT * FROM finish();