78 lines
2.5 KiB
PL/PgSQL
78 lines
2.5 KiB
PL/PgSQL
-- Test user
|
|
set client_min_messages to warning;
|
|
create extension if not exists pgtap;
|
|
reset client_min_messages;
|
|
|
|
begin;
|
|
|
|
select plan(51);
|
|
|
|
set search_path to auth, public;
|
|
|
|
select has_table('user');
|
|
select has_pk('user');
|
|
select table_privs_are('user', 'guest', array []::text[]);
|
|
select table_privs_are('user', 'publisher', array []::text[]);
|
|
select table_privs_are('user', 'admin', array []::text[]);
|
|
select table_privs_are('user', 'authenticator', array []::text[]);
|
|
|
|
select has_column('user', 'user_id');
|
|
select col_is_pk('user', 'user_id');
|
|
select col_type_is('user', 'user_id', 'integer');
|
|
select col_not_null('user', 'user_id');
|
|
select col_has_default('user', 'user_id');
|
|
select col_default_is('user', 'user_id', 'nextval(''user_user_id_seq''::regclass)');
|
|
|
|
select has_column('user', 'email');
|
|
select col_is_unique('user', 'email');
|
|
select col_type_is('user', 'email', 'tipus.email');
|
|
select col_not_null('user', 'email');
|
|
select col_hasnt_default('user', 'email');
|
|
|
|
select has_column('user', 'name');
|
|
select col_type_is('user', 'name', 'text');
|
|
select col_not_null('user', 'name');
|
|
select col_hasnt_default('user', 'name');
|
|
|
|
select has_column('user', 'password');
|
|
select col_type_is('user', 'password', 'text');
|
|
select col_not_null('user', 'password');
|
|
select col_hasnt_default('user', 'password');
|
|
|
|
select has_column('user', 'role');
|
|
select col_type_is('user', 'role', 'name');
|
|
select col_not_null('user', 'role');
|
|
select col_hasnt_default('user', 'role');
|
|
|
|
select has_column('user', 'lang_tag');
|
|
select col_is_fk('user', 'lang_tag');
|
|
select fk_ok('user', 'lang_tag', 'language', 'lang_tag');
|
|
select col_type_is('user', 'lang_tag', 'text');
|
|
select col_not_null('user', 'lang_tag');
|
|
select col_has_default('user', 'lang_tag');
|
|
select col_default_is('user', 'lang_tag', 'und');
|
|
|
|
select has_column('user', 'cookie');
|
|
select col_type_is('user', 'cookie', 'text');
|
|
select col_not_null('user', 'cookie');
|
|
select col_has_default('user', 'cookie');
|
|
select col_default_is('user', 'cookie', '');
|
|
|
|
select has_column('user', 'cookie_expires_at');
|
|
select col_type_is('user', 'cookie_expires_at', 'timestamp with time zone');
|
|
select col_not_null('user', 'cookie_expires_at');
|
|
select col_has_default('user', 'cookie_expires_at');
|
|
select col_default_is('user', 'cookie_expires_at', '-infinity'::timestamp);
|
|
|
|
select has_column('user', 'created_at');
|
|
select col_type_is('user', 'created_at', 'timestamp with time zone');
|
|
select col_not_null('user', 'created_at');
|
|
select col_has_default('user', 'created_at');
|
|
select col_default_is('user', 'created_at', current_timestamp);
|
|
|
|
|
|
select *
|
|
from finish();
|
|
|
|
rollback;
|