Skip to content

Commit 3bb4f73

Browse files
committed
fix(db): use set lookup to identify test files vs imports
1 parent 4eda876 commit 3bb4f73

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

internal/db/test/test.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ func Run(ctx context.Context, testFiles []string, config pgconn.Config, fsys afe
3838
if err != nil {
3939
return err
4040
}
41+
testFileSet := make(map[string]struct{}, len(testFiles))
42+
for _, tf := range testFiles {
43+
testFileSet[tf] = struct{}{}
44+
}
4145
binds := make([]string, len(allFiles))
4246
cmd := []string{"pg_prove", "--ext", ".pg", "--ext", ".sql", "-r"}
4347
var workingDir string
@@ -52,11 +56,11 @@ func Run(ctx context.Context, testFiles []string, config pgconn.Config, fsys afe
5256
workingDir = path.Dir(dockerPath)
5357
}
5458
}
55-
relPath := dockerPath
56-
if path.Ext(dockerPath) != "" {
57-
relPath = path.Base(dockerPath)
58-
}
59-
if i < len(testFiles) {
59+
if _, isTestFile := testFileSet[allFiles[i]]; isTestFile {
60+
relPath := dockerPath
61+
if path.Ext(dockerPath) != "" {
62+
relPath = path.Base(dockerPath)
63+
}
6064
cmd = append(cmd, relPath)
6165
}
6266
binds[i] = fmt.Sprintf("%s:%s:ro", fp, dockerPath)

0 commit comments

Comments
 (0)