Skip to content

Commit c703497

Browse files
committed
test: a tmp test for this branch to test older versions
1 parent 3d203ed commit c703497

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

.github/workflows/testinfra-nix.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,22 @@ jobs:
9494
sudo rm -rf /tmp/* # Clean temporary files
9595
df -h / # Display available space
9696
97+
- name: Patch stage2-nix-psql.pkr.hcl to create pg_extensions.json
98+
run: |
99+
cat >> stage2-nix-psql.pkr.hcl << 'EOF'
100+
# Add provisioner to create pg_extensions.json
101+
provisioner "shell" {
102+
inline = [
103+
"echo '{\"pg_cron\":\"1.3.1\"}' | sudo tee /root/pg_extensions.json",
104+
"sudo chmod 644 /root/pg_extensions.json",
105+
"echo 'Created pg_extensions.json with content:' && sudo cat /root/pg_extensions.json"
106+
]
107+
}
108+
EOF
109+
# Display the modified file to verify
110+
echo "Modified stage2-nix-psql.pkr.hcl:"
111+
tail -n 10 stage2-nix-psql.pkr.hcl
112+
97113
- name: Build AMI stage 2
98114
run: |
99115
packer init stage2-nix-psql.pkr.hcl

testinfra/test_ami_nix.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,3 +476,27 @@ def test_postgrest_ending_empty_key_query_parameter_is_removed(host):
476476
},
477477
)
478478
assert res.ok
479+
480+
481+
def test_pg_cron_extension(host):
482+
# Connect as supabase_admin and create the extension
483+
with host.sudo("postgres"):
484+
result = host.run('psql -U supabase_admin -d postgres -c "CREATE EXTENSION pg_cron WITH SCHEMA pg_catalog VERSION \'1.3.1\';"')
485+
assert result.rc == 0, f"Failed to create pg_cron extension: {result.stderr}"
486+
487+
# Create test table
488+
result = host.run('psql -U supabase_admin -d postgres -c "CREATE TABLE cron_test_log (id SERIAL PRIMARY KEY, message TEXT, log_time TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP);"')
489+
assert result.rc == 0, f"Failed to create test table: {result.stderr}"
490+
491+
# Schedule a job
492+
result = host.run('psql -U supabase_admin -d postgres -c "SELECT cron.schedule(\'* * * * *\', \'INSERT INTO cron_test_log (message) VALUES (\\\'Hello from pg_cron!\\\');\');"')
493+
assert result.rc == 0, f"Failed to schedule job: {result.stderr}"
494+
assert "1" in result.stdout, "Expected schedule ID 1"
495+
496+
# Verify job is scheduled
497+
result = host.run('psql -U supabase_admin -d postgres -c "SELECT * FROM cron.job;"')
498+
assert result.rc == 0, f"Failed to query cron.job: {result.stderr}"
499+
assert "* * * * *" in result.stdout, "Expected cron schedule pattern"
500+
assert "INSERT INTO cron_test_log" in result.stdout, "Expected cron command"
501+
assert "postgres" in result.stdout, "Expected postgres username"
502+
assert "postgres" in result.stdout, "Expected postgres database"

0 commit comments

Comments
 (0)