2023-01-28 13:18:58 +00:00
|
|
|
|
-- 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');
|
2023-02-10 18:00:46 +00:00
|
|
|
|
select lives_ok($$ select (-0.15)::tax_rate $$, 'Should be able to cast valid negative decimals to tax rate');
|
2023-01-28 13:18:58 +00:00
|
|
|
|
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(
|
2023-02-10 18:00:46 +00:00
|
|
|
|
$$ SELECT (-1)::tax_rate $$,
|
2023-01-28 13:18:58 +00:00
|
|
|
|
23514, null,
|
|
|
|
|
'Should reject -100 % tax rate'
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
select *
|
|
|
|
|
from finish();
|
|
|
|
|
|
|
|
|
|
rollback;
|