chore: simplify testing panics

This commit is contained in:
Manuel de la Peña
2024-12-12 06:28:19 +01:00
parent 8ee81305a1
commit bff5333d67
2 changed files with 14 additions and 20 deletions

View File

@@ -231,18 +231,15 @@ func Test_MSSQL_Non_UTF8(t *testing.T) {
} }
func Test_SslRequiredMode(t *testing.T) { func Test_SslRequiredMode(t *testing.T) {
defer func() { require.Panics(t, func() {
if recover() == nil { _ = New(Config{
require.Equalf(t, true, nil, "Connection was established with a `require`") Database: "fiber",
} Username: "username",
}() Password: "password",
_ = New(Config{ Reset: true,
Database: "fiber", SslMode: "require",
Username: "username", })
Password: "password", }, "Expected panic when connecting to MSSQL with SSL mode set to require")
Reset: true,
SslMode: "require",
})
} }
func Test_MSSQL_Close(t *testing.T) { func Test_MSSQL_Close(t *testing.T) {

View File

@@ -236,14 +236,11 @@ func Test_Postgres_Non_UTF8(t *testing.T) {
} }
func Test_SslRequiredMode(t *testing.T) { func Test_SslRequiredMode(t *testing.T) {
defer func() { require.Panics(t, func() {
if recover() == nil { _ = New(Config{
require.Equalf(t, true, nil, "Connection was established with a `require`") Reset: true,
} })
}() }, "Expected panic when connecting to Postgres with SSL mode set to require")
_ = New(Config{
Reset: true,
})
} }
func Test_Postgres_Conn(t *testing.T) { func Test_Postgres_Conn(t *testing.T) {