fix(db): support arbitrary test directories#4590
fix(db): support arbitrary test directories#4590sweatybridge merged 4 commits intosupabase:developfrom
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.
I feel the issue is coming from removing this part
There was a problem hiding this comment.
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