P7: advanced_testing.sql

File advanced_testing.sql, 3.0 KB (added by 193284, 8 days ago)
Line 
1-- 1. Existing venue booking used for overlap testing
2INSERT INTO venue_booking(
3 "date",
4 start_time,
5 end_time,
6 status,
7 price,
8 venue_id,
9 wedding_id
10)
11VALUES (
12 '2026-06-20',
13 '18:00',
14 '22:00',
15 'confirmed',
16 5000,
17 1,
18 1
19);
20
21-- Overlap case 1: starts inside existing interval
22SELECT is_venue_available(1, '2026-06-20', '19:00', '23:00');
23-- Expected result: FALSE
24
25-- Overlap case 2: ends inside existing interval
26SELECT is_venue_available(1, '2026-06-20', '16:00', '19:00');
27-- Expected result: FALSE
28
29-- Overlap case 3: fully contains existing interval
30SELECT is_venue_available(1, '2026-06-20', '17:00', '23:00');
31-- Expected result: FALSE
32
33-- Overlap case 4: fully inside existing interval
34SELECT is_venue_available(1, '2026-06-20', '19:00', '21:00');
35-- Expected result: FALSE
36
37-- Non-overlap case 1: ends before existing interval
38SELECT is_venue_available(1, '2026-06-20', '14:00', '17:00');
39-- Expected result: TRUE
40
41-- Non-overlap case 2: starts after existing interval
42SELECT is_venue_available(1, '2026-06-20', '22:00', '23:00');
43-- Expected result: TRUE
44
45
46-- 2. Existing photographer booking used for overlap testing
47INSERT INTO photographer_booking(
48 "date",
49 start_time,
50 end_time,
51 status,
52 photographer_id,
53 wedding_id
54)
55VALUES (
56 '2026-06-20',
57 '18:00',
58 '22:00',
59 'confirmed',
60 1,
61 1
62);
63
64-- Photographer exact overlap test
65SELECT is_photographer_available(1, '2026-06-20', '18:00', '22:00');
66-- Expected result: FALSE
67
68-- Photographer fully inside overlap test
69SELECT is_photographer_available(1, '2026-06-20', '19:00', '21:00');
70-- Expected result: FALSE
71
72
73-- 3. Existing band booking used for overlap testing
74INSERT INTO band_booking(
75 "date",
76 start_time,
77 end_time,
78 status,
79 band_id,
80 wedding_id
81)
82VALUES (
83 '2026-06-20',
84 '18:00',
85 '22:00',
86 'confirmed',
87 1,
88 1
89);
90
91-- Band exact overlap test
92SELECT is_band_available(1, '2026-06-20', '18:00', '22:00');
93-- Expected result: FALSE
94
95-- Band fully contains overlap test
96SELECT is_band_available(1, '2026-06-20', '17:00', '23:00');
97-- Expected result: FALSE
98
99
100-- 4. RSVP / attendance validation test
101INSERT INTO attendance(
102 status,
103 table_number,
104 role,
105 guest_id,
106 event_id
107)
108VALUES (
109 'attending',
110 3,
111 'Guest',
112 1,
113 1
114);
115
116-- Expected result:
117-- Declined guests cannot be marked as attending.
118
119
120-- 5. View tests
121SELECT *
122FROM vw_wedding_financial_summary;
123
124SELECT *
125FROM vw_rsvp_overview;
126
127SELECT *
128FROM vw_vendor_booking_overview;
129
130SELECT *
131FROM vw_upcoming_weddings;
132
133
134-- 6. Constraint validation test
135INSERT INTO event_rsvp(
136 guest_id,
137 event_id,
138 status
139)
140VALUES (
141 1,
142 1,
143 'invalid_status'
144);
145
146-- Expected result:
147-- CHECK constraint violation
148
149
150-- 7. Procedure test
151CALL generate_rsvp_summary(1);
152
153-- Expected result:
154-- NOTICE messages for accepted, declined, and pending RSVP counts