Add setup and teardown code for supabase db test
#13053
Unanswered
isaacharrisholt
asked this question in
Feature Requests
Replies: 2 comments 2 replies
|
I'd like this too! |
0 replies
|
It probably won't be a setup and teardown as such but we will allow you to include additional file which you can then write your functions in while putting them inside and since your tests rollback at the end they won't stay in the DB after the test ends. |
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
The problem
When running tests with
supabase db test, it's useful to be able to run SQL as an auth user as described in the docs for RLS.We don't want those functions to be in the database permanently for security reasons, so it would be good if they could be created at the start of the test then town down at the end.
Proposed solution
supabase db testcould look forsetup.sqlandteardown.sqlfiles in thesupabase/tests/databasedirectory and run them before and after the tests respectively.Currently, we have a procedure that creates these functions, and another to delete them, but it's a pain to have to call those at the start and end of each test.
All reactions