campingmontagut/test/booking_option.sql
jordi fita mas b2ee4dfea3 Add marshal_payment and unmarshal_booking functions
The idea is that we will marshal the payment, send it to the campsite’s
instance by email, and then unmarshal it as a booking, that way we can
have a one way replication from the internal to the public instance with
a way back to send the payments.

For testing purposes, i just create the booking in the same instance.

Had to change the booking relation’s permissions to allow insert from
a guest, much like for payments, because the notification from Redsys
comes as a guest connection.  I need this even with all the
marshal/unmarshal shenanigans because not everyone will have an internal
instance, thus need to allow bookings from guest connections.
2024-04-29 20:59:22 +02:00

50 lines
1.9 KiB
PL/PgSQL

-- Test booking_option
set client_min_messages to warning;
create extension if not exists pgtap;
reset client_min_messages;
begin;
select plan(27);
set search_path to camper, public;
select has_table('booking_option');
select has_pk('booking_option');
select col_is_pk('booking_option', array['booking_id', 'campsite_type_option_id']);
select table_privs_are('booking_option', 'guest', array['SELECT', 'INSERT']);
select table_privs_are('booking_option', 'employee', array['SELECT', 'INSERT', 'UPDATE', 'DELETE']);
select table_privs_are('booking_option', 'admin', array['SELECT', 'INSERT', 'UPDATE', 'DELETE']);
select table_privs_are('booking_option', 'authenticator', array[]::text[]);
select has_column('booking_option', 'booking_id');
select col_is_fk('booking_option', 'booking_id');
select fk_ok('booking_option', 'booking_id', 'booking', 'booking_id');
select col_type_is('booking_option', 'booking_id', 'integer');
select col_not_null('booking_option', 'booking_id');
select col_hasnt_default('booking_option', 'booking_id');
select has_column('booking_option', 'campsite_type_option_id');
select col_is_fk('booking_option', 'campsite_type_option_id');
select fk_ok('booking_option', 'campsite_type_option_id', 'campsite_type_option', 'campsite_type_option_id');
select col_type_is('booking_option', 'campsite_type_option_id', 'integer');
select col_not_null('booking_option', 'campsite_type_option_id');
select col_hasnt_default('booking_option', 'campsite_type_option_id');
select has_column('booking_option', 'units');
select col_type_is('booking_option', 'units', 'positive_integer');
select col_not_null('booking_option', 'units');
select col_hasnt_default('booking_option', 'units');
select has_column('booking_option', 'subtotal');
select col_type_is('booking_option', 'subtotal', 'nonnegative_integer');
select col_not_null('booking_option', 'subtotal');
select col_hasnt_default('booking_option', 'subtotal');
select *
from finish();
rollback;