|
| 1 | +#!/bin/bash |
| 2 | +set -e |
| 3 | + |
| 4 | +DB_CONTAINER="postgres" |
| 5 | +DB_NAME="flow" |
| 6 | +API_URL="http://localhost:8081" |
| 7 | +SECRET_ID="0123456789abcdef" |
| 8 | + |
| 9 | +echo "=== 1. Setting up Test Data in DB '$DB_NAME' ===" |
| 10 | + |
| 11 | +# Adding the location column if missing |
| 12 | +docker exec -i $DB_CONTAINER psql -U postgres -d $DB_NAME -c " |
| 13 | +DO \$\$ |
| 14 | +BEGIN |
| 15 | + BEGIN |
| 16 | + ALTER TABLE user_schedule ADD COLUMN location text; |
| 17 | + EXCEPTION |
| 18 | + WHEN duplicate_column THEN RAISE NOTICE 'column location already exists in user_schedule'; |
| 19 | + END; |
| 20 | +END \$\$;" |
| 21 | + |
| 22 | +# Insert test data |
| 23 | +docker exec -i $DB_CONTAINER psql -U postgres -d $DB_NAME <<EOF |
| 24 | +-- Create Test User |
| 25 | +INSERT INTO "user" (secret_id, first_name, last_name, join_source) |
| 26 | +VALUES ('$SECRET_ID', 'Test', 'User', 'email') |
| 27 | +ON CONFLICT (secret_id) DO NOTHING; |
| 28 | +
|
| 29 | +DELETE FROM section_meeting WHERE section_id = 1; |
| 30 | +
|
| 31 | +INSERT INTO section_meeting ( |
| 32 | + section_id, location, start_date, end_date, start_seconds, end_seconds, days, |
| 33 | + is_cancelled, is_closed, is_tba |
| 34 | +) |
| 35 | +VALUES ( |
| 36 | + 1, 'RCH 301', '2025-09-01', '2025-12-20', 36000, 39600, '{"M", "W", "F"}', |
| 37 | + false, false, false |
| 38 | +); |
| 39 | +
|
| 40 | +
|
| 41 | +INSERT INTO user_schedule (user_id, section_id) |
| 42 | +SELECT id, 1 FROM "user" WHERE secret_id = '$SECRET_ID' |
| 43 | +ON CONFLICT DO NOTHING; |
| 44 | +EOF |
| 45 | + |
| 46 | +echo "=== 2. Downloading Calendar ===" |
| 47 | +curl -f "$API_URL/calendar/$SECRET_ID.ics" -o test_output.ics |
| 48 | + |
| 49 | +echo "" |
| 50 | +echo "=== DONE ===" |
| 51 | +echo "Check the test_output.ics file generated." |
0 commit comments