From dce363536beaeedbcc19f67b48ac58866232807b Mon Sep 17 00:00:00 2001 From: Mathias Fredriksson Date: Tue, 31 Dec 2024 13:17:20 +0000 Subject: [PATCH] test: fix incorrectly placed cleanup defer in dbtestutil --- coderd/database/dbtestutil/postgres.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/coderd/database/dbtestutil/postgres.go b/coderd/database/dbtestutil/postgres.go index a58ffb570763f..c0b35a03529ca 100644 --- a/coderd/database/dbtestutil/postgres.go +++ b/coderd/database/dbtestutil/postgres.go @@ -464,14 +464,14 @@ func openContainer(t TBSubset, opts DBContainerOptions) (container, func(), erro // The user is responsible for calling the returned cleanup function. func OpenContainerized(t TBSubset, opts DBContainerOptions) (string, func(), error) { container, containerCleanup, err := openContainer(t, opts) + if err != nil { + return "", nil, xerrors.Errorf("open container: %w", err) + } defer func() { if err != nil { containerCleanup() } }() - if err != nil { - return "", nil, xerrors.Errorf("open container: %w", err) - } dbURL := ConnectionParams{ Username: "postgres", Password: "postgres",