35 lines
802 B
PL/PgSQL
35 lines
802 B
PL/PgSQL
-- Test tax_rate
|
||
set client_min_messages to warning;
|
||
create extension if not exists pgtap;
|
||
reset client_min_messages;
|
||
|
||
begin;
|
||
|
||
select plan(7);
|
||
|
||
set search_path to numerus, public;
|
||
|
||
select has_domain('tax_rate');
|
||
select domain_type_is('tax_rate', 'numeric');
|
||
|
||
select lives_ok($$ select 0.21::tax_rate $$, 'Should be able to cast valid positive decimals to tax rate');
|
||
select lives_ok($$ select (-0.15)::tax_rate $$, 'Should be able to cast valid negative decimals to tax rate');
|
||
select lives_ok($$ select 0::tax_rate $$, 'Should be able to cast valid zero to tax rate');
|
||
|
||
select throws_ok(
|
||
$$ SELECT 1::tax_rate $$,
|
||
23514, null,
|
||
'Should reject 100 % tax rate'
|
||
);
|
||
|
||
select throws_ok(
|
||
$$ SELECT (-1)::tax_rate $$,
|
||
23514, null,
|
||
'Should reject -100 % tax rate'
|
||
);
|
||
|
||
select *
|
||
from finish();
|
||
|
||
rollback;
|