From ca96e670ed688ca7cf69f016139f241acd08786e Mon Sep 17 00:00:00 2001 From: Mathias Fredriksson Date: Tue, 31 Dec 2024 16:28:29 +0200 Subject: [PATCH] test: fix incorrectly placed cleanup defer in dbtestutil (#15987) --- 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 a58ffb5707..c0b35a0352 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",