chore: use cleanup function

This commit is contained in:
Manuel de la Peña
2024-12-12 12:12:56 +01:00
parent b074e83e98
commit cac4fd5e8d
7 changed files with 13 additions and 35 deletions

View File

@@ -8,6 +8,7 @@ import (
"time"
"github.com/stretchr/testify/require"
"github.com/testcontainers/testcontainers-go"
"github.com/testcontainers/testcontainers-go/modules/mysql"
)
@@ -51,12 +52,8 @@ func mustStartMySQL(t testing.TB) *mysql.MySQLContainer {
mysql.WithUsername(mysqlUser),
mysql.WithDatabase(mysqlDatabase),
)
testcontainers.CleanupContainer(t, c)
require.NoError(t, err)
t.Cleanup(func() {
if c != nil {
require.NoError(t, c.Terminate(ctx))
}
})
return c
}