From f962d6488570995a3fed7ffc8a87793acbbc0e3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20de=20la=20Pe=C3=B1a?= Date: Wed, 18 Sep 2024 22:20:42 +0200 Subject: [PATCH] chore: terminate container on end This is not relevant for this PR, as Ryuk is responsible for terminating containers after the test session finishes --- clickhouse/clickhouse_test.go | 5 +++++ couchbase/couchbase_test.go | 5 +++++ minio/minio_test.go | 5 +++++ mongodb/mongodb_test.go | 5 +++++ mssql/mssql_test.go | 5 +++++ mysql/mysql_test.go | 5 +++++ postgres/postgres_test.go | 5 +++++ 7 files changed, 35 insertions(+) diff --git a/clickhouse/clickhouse_test.go b/clickhouse/clickhouse_test.go index 7a63975c..062659c9 100644 --- a/clickhouse/clickhouse_test.go +++ b/clickhouse/clickhouse_test.go @@ -42,6 +42,11 @@ func getTestConnection(t testing.TB, cfg Config) (*Storage, error) { if err != nil { return nil, err } + t.Cleanup(func() { + if c != nil { + require.NoError(t, c.Terminate(ctx)) + } + }) hostPort, err := c.ConnectionHost(ctx) if err != nil { diff --git a/couchbase/couchbase_test.go b/couchbase/couchbase_test.go index 7b3e85bd..af72d539 100644 --- a/couchbase/couchbase_test.go +++ b/couchbase/couchbase_test.go @@ -39,6 +39,11 @@ func newTestStore(t testing.TB) (*Storage, error) { if err != nil { return nil, err } + t.Cleanup(func() { + if c != nil { + require.NoError(t, c.Terminate(ctx)) + } + }) conn, err := c.ConnectionString(ctx) if err != nil { diff --git a/minio/minio_test.go b/minio/minio_test.go index a2ab8605..ace3581c 100644 --- a/minio/minio_test.go +++ b/minio/minio_test.go @@ -37,6 +37,11 @@ func newTestStore(t testing.TB) (*Storage, error) { if err != nil { return nil, err } + t.Cleanup(func() { + if c != nil { + require.NoError(t, c.Terminate(ctx)) + } + }) conn, err := c.ConnectionString(ctx) if err != nil { diff --git a/mongodb/mongodb_test.go b/mongodb/mongodb_test.go index b3f8db41..189e5b93 100644 --- a/mongodb/mongodb_test.go +++ b/mongodb/mongodb_test.go @@ -32,6 +32,11 @@ func newTestStore(t testing.TB) (*Storage, error) { if err != nil { return nil, err } + t.Cleanup(func() { + if c != nil { + require.NoError(t, c.Terminate(ctx)) + } + }) conn, err := c.ConnectionString(ctx) if err != nil { diff --git a/mssql/mssql_test.go b/mssql/mssql_test.go index 780ce9a1..7b6bc5c2 100644 --- a/mssql/mssql_test.go +++ b/mssql/mssql_test.go @@ -38,6 +38,11 @@ func newTestStore(t testing.TB) (*Storage, error) { if err != nil { return nil, err } + t.Cleanup(func() { + if c != nil { + require.NoError(t, c.Terminate(ctx)) + } + }) conn, err := c.ConnectionString(ctx) if err != nil { diff --git a/mysql/mysql_test.go b/mysql/mysql_test.go index 895dd53e..91aae00f 100644 --- a/mysql/mysql_test.go +++ b/mysql/mysql_test.go @@ -52,6 +52,11 @@ func mustStartMySQL(t testing.TB) *mysql.MySQLContainer { mysql.WithDatabase(mysqlDatabase), ) require.NoError(t, err) + t.Cleanup(func() { + if c != nil { + require.NoError(t, c.Terminate(ctx)) + } + }) return c } diff --git a/postgres/postgres_test.go b/postgres/postgres_test.go index 94cc72a5..93b70b8b 100644 --- a/postgres/postgres_test.go +++ b/postgres/postgres_test.go @@ -43,6 +43,11 @@ func newTestStore(t testing.TB) (*Storage, error) { ), ) require.NoError(t, err) + t.Cleanup(func() { + if c != nil { + require.NoError(t, c.Terminate(ctx)) + } + }) conn, err := c.ConnectionString(ctx, "sslmode=disable") if err != nil {