test: fix incorrectly placed cleanup defer in dbtestutil (#15987)

This commit is contained in:
Mathias Fredriksson
2024-12-31 16:28:29 +02:00
committed by GitHub
parent cc98bab30f
commit ca96e670ed

View File

@ -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",