numerus/test/tag_name.sql

60 lines
1.5 KiB
MySQL
Raw Normal View History

-- Test tag_name
set client_min_messages to warning;
create extension if not exists pgtap;
reset client_min_messages;
begin;
select plan(12);
set search_path to numerus, public;
select has_domain('tag_name');
select domain_type_is('tag_name', 'text');
select lives_ok($$ select 'abcdefghijklmnopqrstuvwxyz012345678'::tag_name $$, 'Should be able to cast strings with up to 35 lowercase alphanumeric characters to tag_name');
select lives_ok($$ select 'a'::tag_name $$, 'Should be able to cast strings with a single letter to tag_name');
select lives_ok($$ select '1'::tag_name $$, 'Should be able to cast strings with a single number to tag_name');
select lives_ok($$ select 'a-long-tag'::tag_name $$, 'Should be able to cast strings with dashes to tag_name');
select throws_ok(
$$ SELECT 'abcdefghijklmnopqrstuvwxyz0123456789'::tag_name $$,
23514, null,
'Should reject tag names with more than 35 characters'
);
select throws_ok(
$$ SELECT 'aB'::tag_name $$,
23514, null,
'Should reject tag names with uppercase characters'
);
select throws_ok(
$$ SELECT 'a$'::tag_name $$,
23514, null,
'Should reject tag names with symbols'
);
select throws_ok(
$$ SELECT 'a a'::tag_name $$,
23514, null,
'Should reject tag names with spaces'
);
select throws_ok(
$$ SELECT '-aa'::tag_name $$,
23514, null,
'Should reject tag names starting with a dash'
);
select throws_ok(
$$ SELECT ''::tag_name $$,
23514, null,
'Should reject empty tag names'
);
select *
from finish();
rollback;