Skip to content
8 changes: 6 additions & 2 deletions internal/db/test/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,18 @@ func Run(ctx context.Context, testFiles []string, config pgconn.Config, fsys afe
fp = filepath.Join(utils.CurrentDirAbs, fp)
}
dockerPath := utils.ToDockerPath(fp)
cmd = append(cmd, dockerPath)
binds[i] = fmt.Sprintf("%s:%s:ro", fp, dockerPath)
if workingDir == "" {
workingDir = dockerPath
if path.Ext(dockerPath) != "" {
workingDir = path.Dir(dockerPath)
}
}
relPath := dockerPath
if path.Ext(dockerPath) != "" {
relPath = path.Base(dockerPath)
}
cmd = append(cmd, relPath)
binds[i] = fmt.Sprintf("%s:%s:ro", fp, dockerPath)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if the file imported by \ir imports another file using \ir?

To support this properly, we need to traverse all the files imported. Easiest way is to use a regex expression. You can refer to this example https://github.com/supabase/cli/blob/develop/pkg/function/deno.go#L114

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you end up implementing that, please also write a unit test to cover these cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 💚😅!
Added traverseImports with regex pattern matching and unit tests for nested imports, circular imports and relative paths

}
if viper.GetBool("DEBUG") {
cmd = append(cmd, "--verbose")
Expand Down
Loading