From d7e5c7734d9e7fbd1d740e2a0a6dbe57e593e8a5 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Wed, 4 Nov 2015 21:27:14 +0000 Subject: [PATCH] LP#1501471: add some unit tests for batch OU retrieval Signed-off-by: Galen Charlton Signed-off-by: Bill Erickson --- Open-ILS/src/sql/Pg/live_t/aous_batch.pg | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 Open-ILS/src/sql/Pg/live_t/aous_batch.pg diff --git a/Open-ILS/src/sql/Pg/live_t/aous_batch.pg b/Open-ILS/src/sql/Pg/live_t/aous_batch.pg new file mode 100644 index 0000000000..4a0dabd33e --- /dev/null +++ b/Open-ILS/src/sql/Pg/live_t/aous_batch.pg @@ -0,0 +1,31 @@ +BEGIN; + +SELECT plan(3); + +INSERT INTO config.org_unit_setting_type (name, label) VALUES ('foo', 'Turn on foo'); +INSERT INTO config.org_unit_setting_type (name, label) VALUES ('bar', 'Turn on bar'); + +INSERT INTO actor.org_unit_setting (org_unit, name, value) VALUES (1, 'foo', '"foo 1"'); +INSERT INTO actor.org_unit_setting (org_unit, name, value) VALUES (2, 'foo', '"foo 2"'); +INSERT INTO actor.org_unit_setting (org_unit, name, value) VALUES (2, 'bar', '"bar 2"'); + +SELECT results_eq( + $$ SELECT name, value FROM actor.org_unit_ancestor_setting_batch(1, 'foo', 'bar') $$, + $$ VALUES ('foo', '"foo 1"') $$, + 'can retrieve batch of org unit settings' +); + +SELECT results_eq( + $$ SELECT name, value FROM actor.org_unit_ancestor_setting_batch(2, 'foo', 'bar') $$, + $$ VALUES ('foo', '"foo 2"'), ('bar', '"bar 2"') $$, + 'can retrieve batch of org unit settings at lower level' +); + +DELETE FROM actor.org_unit_setting WHERE name = 'foo' AND org_unit = 2; +SELECT results_eq( + $$ SELECT name, value FROM actor.org_unit_ancestor_setting_batch(2, 'foo', 'bar') $$, + $$ VALUES ('foo', '"foo 1"'), ('bar', '"bar 2"') $$, + 'can retrieve batch of org unit settings with fallback' +); + +ROLLBACK; -- 2.11.0