]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/sql/Pg/t/text_concat.pg
LP#1470957: provide pgTAP test for expected pubdate normalization
[Evergreen.git] / Open-ILS / src / sql / Pg / t / text_concat.pg
1 -- Load the TAP functions.
2 BEGIN;
3
4 -- Plan the tests.
5 SELECT plan(6);
6
7 SELECT is(public.text_concat('foo','bar'), 'foo bar', '2 Strings');
8 SELECT is(public.text_concat('åbçdéñœöîøæ', 'ÇıÂÅÍÎÏÔÔÒÚÆŒè'), 
9     'åbçdéñœöîøæ ÇıÂÅÍÎÏÔÔÒÚÆŒè', '2 More Strings');
10 SELECT is(public.text_concat('foo',NULL), 'foo', 'string + NULL');
11 SELECT is(public.text_concat(NULL, 'bar'), 'bar', 'NULL + string');
12 SELECT is(public.text_concat(NULL, NULL), NULL, 'NULL + NULL');
13
14 -- test aggregate use
15
16 INSERT INTO config.billing_type (name, owner, default_price) VALUES
17 ('pgtap 1', 1, DEFAULT),
18 ('pgtap 2', 1, '3.34'),
19 ('pgtap 3', 1, '4.56');
20
21 SELECT is(
22     (SELECT agg_text(subq.default_price::text) FROM 
23         (SELECT * FROM config.billing_type 
24             WHERE name ~ 'pgtap' ORDER BY name) subq),
25     '3.34 4.56',
26     'agg_text() aggregates some text'
27 );
28
29 -- Finish the tests and clean up.
30 SELECT * FROM finish();
31 ROLLBACK;