From 1c3ba718a31c53fe4e14d0d3566e9db95a32d8e2 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Fri, 14 Aug 2015 11:17:55 -0400 Subject: [PATCH] LP#1483508 PGTAP tests for text_concat / agg_text Signed-off-by: Bill Erickson Signed-off-by: Josh Stompro Signed-off-by: Kathy Lussier --- Open-ILS/src/sql/Pg/t/text_concat.pg | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 Open-ILS/src/sql/Pg/t/text_concat.pg 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 index 0000000000..bcbd7ac018 --- /dev/null +++ b/Open-ILS/src/sql/Pg/t/text_concat.pg @@ -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; -- 2.11.0