2024-01-13 00:15:24 +00:00
|
|
|
-- Test order_services
|
|
|
|
set client_min_messages to warning;
|
|
|
|
create extension if not exists pgtap;
|
|
|
|
reset client_min_messages;
|
|
|
|
|
|
|
|
begin;
|
|
|
|
|
|
|
|
select plan(11);
|
|
|
|
|
|
|
|
set search_path to camper, public;
|
|
|
|
|
|
|
|
select has_function('camper', 'order_services', array['integer[]']);
|
|
|
|
select function_lang_is('camper', 'order_services', array['integer[]'], 'sql');
|
|
|
|
select function_returns('camper', 'order_services', array['integer[]'], 'void');
|
|
|
|
select isnt_definer('camper', 'order_services', array['integer[]']);
|
|
|
|
select volatility_is('camper', 'order_services', array['integer[]'], 'volatile');
|
|
|
|
select function_privs_are('camper', 'order_services', array ['integer[]'], 'guest', array[]::text[]);
|
|
|
|
select function_privs_are('camper', 'order_services', array ['integer[]'], 'employee', array[]::text[]);
|
|
|
|
select function_privs_are('camper', 'order_services', array ['integer[]'], 'admin', array['EXECUTE']);
|
|
|
|
select function_privs_are('camper', 'order_services', array ['integer[]'], 'authenticator', array[]::text[]);
|
|
|
|
|
|
|
|
set client_min_messages to warning;
|
|
|
|
truncate service cascade;
|
|
|
|
truncate company cascade;
|
|
|
|
reset client_min_messages;
|
|
|
|
|
2024-01-14 01:09:17 +00:00
|
|
|
insert into company (company_id, business_name, vatin, trade_name, phone, email, web, address, city, province, postal_code, rtc_number, tourist_tax, country_code, currency_code, default_lang_tag)
|
|
|
|
values (1, 'Company 2', 'XX123', '', '555-555-555', 'a@a', '', '', '', '', '', '', 60, 'ES', 'EUR', 'ca')
|
2024-01-13 00:15:24 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
insert into service (service_id, company_id, icon_name, name, description)
|
|
|
|
values (4, 1, 'baby', '1', '<p>a</p>')
|
|
|
|
, (5, 1, 'nopet', '2', '<p>b</p>')
|
|
|
|
, (6, 1, 'castle', '3', '<p>c</p>')
|
|
|
|
, (7, 1, 'area', '4', '<p>d</p>')
|
|
|
|
, (8, 1, 'campfire', '5', '<p>e</p>')
|
|
|
|
;
|
|
|
|
|
|
|
|
select lives_ok(
|
|
|
|
$$ select order_services('{6,8,7,4,5}') $$,
|
|
|
|
'Should be able to sort services using their ID'
|
|
|
|
);
|
|
|
|
|
|
|
|
select bag_eq(
|
|
|
|
$$ select service_id, position from service $$,
|
|
|
|
$$ values (6, 1)
|
|
|
|
, (8, 2)
|
|
|
|
, (7, 3)
|
|
|
|
, (4, 4)
|
|
|
|
, (5, 5)
|
|
|
|
$$,
|
|
|
|
'Should have sorted all services.'
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
select *
|
|
|
|
from finish();
|
|
|
|
|
|
|
|
rollback;
|