Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Running pgTAP Tests with Custom Extension Schemas #2690

Open
istarkov opened this issue Sep 17, 2024 · 1 comment
Open

Support Running pgTAP Tests with Custom Extension Schemas #2690

istarkov opened this issue Sep 17, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@istarkov
Copy link

istarkov commented Sep 17, 2024

Problem Description

Currently, when creating the pgtap extension with a custom schema:

CREATE EXTENSION IF NOT EXISTS pgtap WITH SCHEMA pgtap; -- <== CUSTOM schema 

there is no straightforward way (or I have not found) to run supabase test db with a custom --search_path option (e.g., --search_path=pgtap,public).

Proposed Solution

Allow setting PGOPTIONS in the Supabase CLI, which would enable setting a custom search path. For example:

PGOPTIONS='--search_path=pgtap,public' supabase test db --db-url 'conn-string'

The following Docker command works seamlessly for running tests with a custom search_path

docker run --rm --network host \
-v ./supabase/tests:/tests \
-e PGOPTIONS='--search_path=pgtap,public' \
supabase/pg_prove:3.36 \
pg_prove -d "postgresql://postgres:pass@localhost/webstudio" /tests/latest-builds_test.sql

Alternatively, provide a mechanism to pass flags directly to the pg_prove CLI.

Alternative Solutions Considered

Currently, I am setting the search path within test files using:

SET LOCAL search_path = pgtap, public;

Anyway gonna move on

docker run --rm --network host \
-v ./supabase/tests:/tests \
-e PGOPTIONS='--search_path=pgtap,public' \
supabase/pg_prove:3.36 \
pg_prove -d "postgresql://postgres:pass@localhost/webstudio" /tests/latest-builds_test.sql

While this works, it's not ideal for managing multiple tests or maintaining clean code.

@istarkov
Copy link
Author

The issue with the PGOPTIONS workaround is that it only works with direct connections.
Corresponding issue: supabase/supavisor#206

@sweatybridge sweatybridge added the enhancement New feature or request label Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants