-- Test currency_code
set client_min_messages to warning;
create extension if not exists pgtap;
reset client_min_messages;

begin;

select plan(6);

set search_path to camper, public;

select has_domain('currency_code');
select domain_type_is('currency_code', 'text');

select lives_ok($$ select 'EUR'::currency_code $$, 'Should be able to cast valid text to currency code');

select throws_ok(
	$$ SELECT '123'::currency_code $$,
	23514, null,
	'Should reject numeric text'
);

select throws_ok(
	$$ SELECT 'eur'::currency_code $$,
	23514, null,
	'Should reject lowecase text'
);

select throws_ok(
	$$ SELECT 'EURO'::currency_code $$,
	23514, null,
	'Should reject text longer than three letters'
);


select *
from finish();

rollback;
