Skip to content

Commit ca96e67

Browse files
authored
test: fix incorrectly placed cleanup defer in dbtestutil (coder#15987)
1 parent cc98bab commit ca96e67

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

coderd/database/dbtestutil/postgres.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -464,14 +464,14 @@ func openContainer(t TBSubset, opts DBContainerOptions) (container, func(), erro
464464
// The user is responsible for calling the returned cleanup function.
465465
func OpenContainerized(t TBSubset, opts DBContainerOptions) (string, func(), error) {
466466
container, containerCleanup, err := openContainer(t, opts)
467+
if err != nil {
468+
return "", nil, xerrors.Errorf("open container: %w", err)
469+
}
467470
defer func() {
468471
if err != nil {
469472
containerCleanup()
470473
}
471474
}()
472-
if err != nil {
473-
return "", nil, xerrors.Errorf("open container: %w", err)
474-
}
475475
dbURL := ConnectionParams{
476476
Username: "postgres",
477477
Password: "postgres",

0 commit comments

Comments
 (0)