-- Test country_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('country_code');
select domain_type_is('country_code', 'text');

select lives_ok($$ select 'FR'::country_code $$, 'Should be able to cast valid text to country code');

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

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

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

select *
from finish();

rollback;
