From e174b43ef179828e32f60e71b4c56b691e3e85e0 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 30 Sep 2015 12:13:21 -0400 Subject: [PATCH] LP#838525 DoB as date PGTAP test Signed-off-by: Bill Erickson Signed-off-by: Mike Rylander --- Open-ILS/src/sql/Pg/t/dob-as-date.pg | 38 ++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 Open-ILS/src/sql/Pg/t/dob-as-date.pg diff --git a/Open-ILS/src/sql/Pg/t/dob-as-date.pg b/Open-ILS/src/sql/Pg/t/dob-as-date.pg new file mode 100644 index 0000000000..a1f726f2b0 --- /dev/null +++ b/Open-ILS/src/sql/Pg/t/dob-as-date.pg @@ -0,0 +1,38 @@ +BEGIN; + +SELECT plan(5); + +SELECT col_type_is('actor', 'usr', 'dob', 'date', 'Check dob column type'); + +SELECT is( + (SELECT ( + '2011-02-28 23:00:00-05'::timestamptz + '3 hours'::interval)::date), + '2011-03-01', + 'Confirming date translation on hour-23 dates' +); + +SELECT is( + (SELECT dob FROM actor.usr WHERE id = 1), + '1979-01-22', -- DoB of admin user + 'Checking admin default dob' +); + +UPDATE actor.usr SET dob = '2011-03-01 00:00:00-10' WHERE id = 1; + +SELECT is( + (SELECT dob FROM actor.usr WHERE id = 1), + '2011-03-01', + 'Date truncation with timezone v1' +); + +UPDATE actor.usr SET dob = '2011-06-01 00:00:00+10' WHERE id = 1; + +SELECT is( + (SELECT dob FROM actor.usr WHERE id = 1), + '2011-06-01', + 'Date truncation with timezone v2' +); + +-- Finish the tests and clean up. +SELECT * FROM finish(); +ROLLBACK; -- 2.43.2