3 -- Turn off echo and keep things quiet.
5 -- Format the output for nice TAP.
10 -- Revert all changes on failure.
11 \set ON_ERROR_ROLLBACK 1
12 \set ON_ERROR_STOP true
15 -- let's do this thing
20 -- The effect of this will be rolled back, so don't worry.
21 DELETE FROM actor.org_unit_proximity_adjustment;
23 -- Tests in the directory where we are rely on stock and Concerto data being
25 INSERT INTO actor.org_unit_proximity_adjustment (
26 item_circ_lib, hold_pickup_lib, absolute_adjustment, prox_adjustment
27 ) VALUES (2, 2, true, 0);
30 (SELECT pickup_lib = 5 FROM action.hold_request WHERE id = 3),
32 'Data suitable for test: hold #3 has pickup_lib 5'
36 (SELECT pickup_lib = 9 FROM action.hold_request WHERE id = 4),
38 'Data suitable for test: hold #4 has pickup_lib 9'
42 (SELECT circ_lib = 4 FROM asset.copy WHERE id = 2884),
44 'Data suitable for test: copy #2884 has circ_lib 4'
48 (SELECT aou.parent_ou = 2 AND aout.depth = 2
49 FROM actor.org_unit aou
50 JOIN actor.org_unit_type aout ON (aout.id = aou.ou_type)
53 'Data suitable for test: ou #5 has parent_ou 2 and depth 2'
57 (SELECT aou.parent_ou <> 2 AND aout.depth >= 2
58 FROM actor.org_unit aou
59 JOIN actor.org_unit_type aout ON (aout.id = aou.ou_type)
62 'Data suitable for test: ou #9 doesn''t have parent_ou 2, does have depth at least 2'
66 action.hold_copy_calculated_proximity (3, 2884)::INT,
68 'Org unit proximity adjustment takes effect when it should'
72 action.hold_copy_calculated_proximity (4, 2884)::INT,
74 '(regression test) Org unit proximity adjustment doesn''t take effect when it shouldn''t'
77 SELECT * FROM finish();