-- 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; 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') ; insert into service (service_id, company_id, icon_name, name, description) values (4, 1, 'baby', '1', '
a
') , (5, 1, 'nopet', '2', 'b
') , (6, 1, 'castle', '3', 'c
') , (7, 1, 'area', '4', 'd
') , (8, 1, 'campfire', '5', 'e
') ; 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;