numerus/test/tax_rate.sql

35 lines
798 B
PL/PgSQL
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- 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;