LP#1483508 PGTAP tests for text_concat / agg_text
authorBill Erickson <berickxx@gmail.com>
Fri, 14 Aug 2015 15:17:55 +0000 (11:17 -0400)
committerKathy Lussier <klussier@masslnc.org>
Thu, 12 Nov 2015 01:39:34 +0000 (20:39 -0500)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Josh Stompro <stomproj@larl.org>
Signed-off-by: Kathy Lussier <klussier@masslnc.org>
Open-ILS/src/sql/Pg/t/text_concat.pg [new file with mode: 0644]

diff --git a/Open-ILS/src/sql/Pg/t/text_concat.pg b/Open-ILS/src/sql/Pg/t/text_concat.pg
new file mode 100644 (file)
index 0000000..bcbd7ac
--- /dev/null
@@ -0,0 +1,31 @@
+-- Load the TAP functions.
+BEGIN;
+
+-- Plan the tests.
+SELECT plan(6);
+
+SELECT is(public.text_concat('foo','bar'), 'foo bar', '2 Strings');
+SELECT is(public.text_concat('åbçdéñœöîøæ', 'ÇıÂÅÍÎÏÔÔÒÚÆŒè'), 
+    'åbçdéñœöîøæ ÇıÂÅÍÎÏÔÔÒÚÆŒè', '2 More Strings');
+SELECT is(public.text_concat('foo',NULL), 'foo', 'string + NULL');
+SELECT is(public.text_concat(NULL, 'bar'), 'bar', 'NULL + string');
+SELECT is(public.text_concat(NULL, NULL), NULL, 'NULL + NULL');
+
+-- test aggregate use
+
+INSERT INTO config.billing_type (name, owner, default_price) VALUES
+('pgtap 1', 1, DEFAULT),
+('pgtap 2', 1, '3.34'),
+('pgtap 3', 1, '4.56');
+
+SELECT is(
+    (SELECT agg_text(subq.default_price::text) FROM 
+        (SELECT * FROM config.billing_type 
+            WHERE name ~ 'pgtap' ORDER BY name) subq),
+    '3.34 4.56',
+    'agg_text() aggregates some text'
+);
+
+-- Finish the tests and clean up.
+SELECT * FROM finish();
+ROLLBACK;