Skip to content

Commit 193af7d

Browse files
committed
fix: do not return nil cleanup func
Signed-off-by: Danny Kopping <danny@coder.com>
1 parent 6117f46 commit 193af7d

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

coderd/database/dbtestutil/postgres.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ func openContainer(t TBSubset, opts DBContainerOptions) (container, func(), erro
352352
nameHashStr := hex.EncodeToString(nameHash[:])
353353
lock := flock.New(filepath.Join(os.TempDir(), "coder-postgres-container-"+nameHashStr[:8]))
354354
if err := lock.Lock(); err != nil {
355-
return container{}, nil, xerrors.Errorf("lock: %w", err)
355+
return container{}, func() {}, xerrors.Errorf("lock: %w", err)
356356
}
357357
defer func() {
358358
err := lock.Unlock()
@@ -364,7 +364,7 @@ func openContainer(t TBSubset, opts DBContainerOptions) (container, func(), erro
364364

365365
pool, err := dockertest.NewPool("")
366366
if err != nil {
367-
return container{}, nil, xerrors.Errorf("create pool: %w", err)
367+
return container{}, func() {}, xerrors.Errorf("create pool: %w", err)
368368
}
369369

370370
var resource *dockertest.Resource
@@ -376,7 +376,7 @@ func openContainer(t TBSubset, opts DBContainerOptions) (container, func(), erro
376376
if resource == nil {
377377
tempDir, err = os.MkdirTemp(os.TempDir(), "postgres")
378378
if err != nil {
379-
return container{}, nil, xerrors.Errorf("create tempdir: %w", err)
379+
return container{}, func() {}, xerrors.Errorf("create tempdir: %w", err)
380380
}
381381
runOptions := dockertest.RunOptions{
382382
Repository: "gcr.io/coder-dev-1/postgres",
@@ -421,14 +421,14 @@ func openContainer(t TBSubset, opts DBContainerOptions) (container, func(), erro
421421
}
422422
})
423423
if err != nil {
424-
return container{}, nil, xerrors.Errorf("could not start resource: %w", err)
424+
return container{}, func() {}, xerrors.Errorf("could not start resource: %w", err)
425425
}
426426
}
427427

428428
hostAndPort := resource.GetHostPort("5432/tcp")
429429
host, port, err := net.SplitHostPort(hostAndPort)
430430
if err != nil {
431-
return container{}, nil, xerrors.Errorf("split host and port: %w", err)
431+
return container{}, func() {}, xerrors.Errorf("split host and port: %w", err)
432432
}
433433

434434
for r := retry.New(50*time.Millisecond, 15*time.Second); r.Wait(context.Background()); {
@@ -443,7 +443,7 @@ func openContainer(t TBSubset, opts DBContainerOptions) (container, func(), erro
443443
}
444444
}
445445
if err != nil {
446-
return container{}, nil, xerrors.Errorf("pg_isready: %w", err)
446+
return container{}, func() {}, xerrors.Errorf("pg_isready: %w", err)
447447
}
448448

449449
return container{
@@ -470,7 +470,7 @@ func OpenContainerized(t TBSubset, opts DBContainerOptions) (string, func(), err
470470
}
471471
}()
472472
if err != nil {
473-
return "", nil, xerrors.Errorf("open container: %w", err)
473+
return "", func() {}, xerrors.Errorf("open container: %w", err)
474474
}
475475
dbURL := ConnectionParams{
476476
Username: "postgres",

0 commit comments

Comments
 (0)