camper/test/input_is_valid_phone.sql

33 lines
1.3 KiB
PL/PgSQL

-- Test input_is_valid_phone
set client_min_messages to warning;
create extension if not exists pgtap;
reset client_min_messages;
begin;
select plan(12);
set search_path to camper, public;
select has_function('public', 'input_is_valid_phone', array ['text', 'text']);
select function_lang_is('public', 'input_is_valid_phone', array ['text', 'text'], 'plpgsql');
select function_returns('public', 'input_is_valid_phone', array ['text', 'text'], 'boolean');
select isnt_definer('public', 'input_is_valid_phone', array ['text', 'text']);
select volatility_is('public', 'input_is_valid_phone', array ['text', 'text'], 'stable');
select function_privs_are('public', 'input_is_valid_phone', array ['text', 'text'], 'guest', array ['EXECUTE']);
select function_privs_are('public', 'input_is_valid_phone', array ['text', 'text'], 'employee', array ['EXECUTE']);
select function_privs_are('public', 'input_is_valid_phone', array ['text', 'text'], 'admin', array ['EXECUTE']);
select function_privs_are('public', 'input_is_valid_phone', array ['text', 'text'], 'authenticator', array ['EXECUTE']);
select is( input_is_valid_phone('555-555-5555', 'US'), true );
select is( input_is_valid_phone('555-555-5555555555', 'US'), false );
select is( input_is_valid_phone('555-555-55555555555', 'US'), false );
select *
from finish();
rollback;