-
Notifications
You must be signed in to change notification settings - Fork 367
fix(db): support arbitrary test directories #4590
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
Conversation
when running supabase db test from a docker-outside-of-docker environment, test file paths may be absolute host paths while utils.DbTestsDir is relative. filepath.Rel fails when the base path is relative and the target is absolute. this change converts both paths to absolute before computing the relative path, which handles all path combinations correctly: relative+relative, absolute+absolute, and mixed scenarios like docker-outside-of-docker. closes supabase#3194
|
Improved the command to support arbitrary test directories passed in via command line args. |
|
@7ttp @sweatybridge - We have a use case where we execute the test on 1 files but need some extra files imported via |
|
@franck-ada and all: we just hit this issue in a project as well. The patch in our case was to go from: \i _utils/mocks/payload.sql.mockto: \ir ../../_utils/mocks/payload.sql.mockIdeally |
|
@lightstrike - thanks a lot for your comment this fix seems to work when you give a full directory (and your file is in it). |
| "PGDATABASE=" + config.Database, | ||
| }, | ||
| Cmd: cmd, | ||
| WorkingDir: dstPath, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel the issue is coming from removing this part
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you are right. We need to set working dir supabase/tests for \i to work consistently inside and outside of docker.
|
@franck-ada Did you try this as a workaround? Changing: \i init-function.sqlto: \ir ./init-function.sql |
when running
supabase db testfrom a docker-outside-of-docker environment, test file paths may be absolute host paths whileutils.DbTestsDiris relative.filepath.Relfails when the base path is relative and the target is absolute, producing the error:Rel: can't make /path/to/supabase/tests relative to supabase/tests. this change converts both paths to absolute before computing the relative path, which handles all path combinations correctly.cc @sweatybridge
closes #4523